#include <bits/stdc++.h>
int main() {
  int mod = 1000000007;
  int n, m, sum = 0;
  scanf("%d %d", &n, &m);
  int x[n], y[m];
  for (int i = 0; i < n; i++) scanf("%d", &x[i]);
  for (int i = 0; i < m; i++) scanf("%d", &y[i]);
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      for (int k = 0; k < m; k++) {
        for (int l = k + 1; l < m; l++) {
          sum += ((y[l] ^ y[k]) * (x[j] - x[i])) % mod;
        }
      }
    }
  }
  printf("%d", sum);
  return 0;
}
