#include using namespace std; const int mod = 1e9 + 7; int n, m, i, j, q, sc, ans; int f[2002][2005]; int s[2002 * 2002]; int fwt[2002 * 2002]; int la[2002 * 2002]; int a[2002], b[2002]; inline int access(int x) { if (la[x] < q) return 0; return fwt[x]; } inline int compress(int x) { return (lower_bound(s + 1, s + sc + 1, x) - (s + 1)) + 2; } inline void modify(int x, int v) { for (; x <= sc + 4; x = (x | (x - 1)) + 1) { fwt[x] = (access(x) + v) % mod; la[x] = q; } } inline int findsum(int x) { int s = 0; for (; x; x &= (x - 1)) { s = (s + access(x)) % mod; } return s; } int main() { //freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout); scanf("%d%d", &n, &m); for (int i = 1; i <= n; i++) scanf("%d", a + i); for (int i = 1; i <= m; i++) scanf("%d", b + i); q++; for (int i = 1; i <= n; i++) f[i][1] = 1; for (int i = 2; i <= m; i++) { sc = 0; for (int j = 1; j <= n; j++) s[++sc] = a[j] + b[i - 1]; for (int j = 1; j <= n; j++) s[++sc] = a[j] + b[i]; sort(s + 1, s + sc + 1); q++; for (int j = 1; j <= n; j++) { f[j][i] = findsum(compress(a[j] + b[i])); modify(compress(a[j] + b[i - 1]), f[j][i - 1]); } } ans = 0; for (int i = 1; i <= n; i++) ans = (ans + f[i][m]) % mod; printf("%d\n", ans); return 0; }