#include <bits/stdc++.h>
int n, m;
long long int x[10001], y[10001];
unsigned long long int ans = 0;
unsigned long long int mem[50][50][50][50];
bool memf[50][50][50][50] = {};
unsigned long long int area(int XL, int XD, int YL, int YD);
int main() {
  scanf("%d %d", &n, &m);
  for (int l = 0; l < n; l++) {
    scanf("%lld", &x[l]);
  }
  for (int l = 0; l < m; l++) {
    scanf("%lld", &y[l]);
  }
  for (int xl = 0; xl < n - 1; xl++) {
    for (int xd = 1; xd < (n - xl); xd++) {
      for (int yl = 0; yl < n - 1; yl++) {
        for (int yd = 1; yd < (n - yl); yd++) {
          ans = (ans + area(xl, xd, yl, yd)) % 1000000007;
        }
      }
    }
  }
  printf("%lld", ans);
  return 0;
}
unsigned long long int area(int XL, int XD, int YL, int YD) {
  printf("Carea %d %d %d %d ", XL, XD, YL, YD);
  unsigned long long int ret;
  if (memf[XL][XD][YL][YD]) {
    printf("mem");
    ret = mem[XL][XD][YL][YD];
  } else {
    if (XD == 1 && YD == 1) {
      printf("cal");
      ret = ((x[XL + XD] - x[XL]) < 0 ? -(x[XL + XD] - x[XL])
                                      : (x[XL + XD] - x[XL])) *
            ((y[YL + YD] - y[YL]) < 0 ? -(y[YL + YD] - y[YL])
                                      : (y[YL + YD] - y[YL]));
    } else if (XD == 0 || YD == 0) {
      printf("zero");
      ret = 0;
    } else {
      printf("div\n");
      ret = area(XL, XD / 2, YL, YD / 2) +
            area(XL + XD / 2, XD - XD / 2, YL, YD / 2) +
            area(XL, XD / 2, YL + YD / 2, YD - YD / 2) +
            area(XL + XD / 2, XD - XD / 2, YL + YD / 2, YD - YD / 2);
    }
    memf[XL][XD][YL][YD] = true;
    mem[XL][XD][YL][YD] = ret;
  }
  printf("\n");
  return ret;
}
