#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m, xd, yd;
  unsigned long long s, sum = 0, w = pow(10, 9) + 8;
  cout << w << endl;
  vector<long long> x, y;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> xd;
    x.push_back(xd);
  }
  for (int j = 0; j < m; j++) {
    cin >> yd;
    y.push_back(yd);
  }
  for (int i = 0; i < x.size() - 1; i++) {
    for (int j = i + 1; j < x.size(); j++) {
      for (int k = 0; k < y.size() - 1; k++) {
        for (int l = k + 1; l < y.size(); l++) {
          xd = (x[j] - x[i]) % w;
          yd = (y[l] - y[k]) % w;
          s = (xd * yd) % w;
          sum += s;
          if (sum > w) {
            sum %= w;
          }
        }
      }
    }
  }
  cout << sum << endl;
  return 0;
}
