using System;

public class Hello
{
    public const long SS = 1000000007;
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var m = int.Parse(line[1]);
        line = Console.ReadLine().Trim().Split(' ');
        var x = Array.ConvertAll(line, long.Parse);
        line = Console.ReadLine().Trim().Split(' ');
        var y = Array.ConvertAll(line, long.Parse);
        var w1 = (x[n - 1] - x[0]) % SS;
        var w2 = (y[m - 1] - y[0]) % SS;
        var w3 = (w1 * w2) % SS;
        var w4 = ((long)Math.Pow(2, n - 2)) % SS;
        var w5 = ((long)Math.Pow(2, m - 2)) % SS;
        var w6 = (w4 * w5) % SS;
        var w7 = (w3 * w6) % SS;
        Console.WriteLine(w7);
    }
}