using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
        return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
    public static long[] ReadLongArray()
    {
        return ReadLine().Split().Select(x => long.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
        const int M = 1000000007;

        var tmp = ReadIntArray();
        int n = tmp[0], m = tmp[1];

        long[] x = ReadLongArray();
        long[] y = ReadLongArray();

        long dx = (x[n-1] - x[0]) % M;
        long dy = (y[m-1] - y[0]) % M;

        long mx = (1L << (n-2));
        long my = (1L << (m-2));

        long ans = dx * dy % M * mx % M * my % M;
        WriteLine(ans);
    }
}