#include<cstdio> #include<algorithm> using LL = longlong; using DB = double; constint N = 2000 + 100, P = 1e9 + 9; int n, m, ans = 0; int f[N], a[N], b[N], c[N], fac[N], ifac[N]; voidadj(int &x){ x += (x >> 31) & P; } intqpow(int x, int y = P - 2) { int res = 1; for (; y; y >>= 1, x = LL(x) * x % P) if (y & 1) res = LL(res) * x % P; return res; } voidprev() { fac[0] = fac[1] = ifac[0] = ifac[1] = 1; for (int i = 2; i <= n; ++i) fac[i] = LL(i) * fac[i - 1] % P; ifac[n] = qpow(fac[n]); for (int i = n - 1; i > 1; --i) ifac[i] = LL(i + 1) * ifac[i + 1] % P; } intC(int x, int y) { if (x < y) return0; returnLL(fac[x]) * ifac[y] % P * ifac[x - y] % P; } intmain() { scanf("%d %d", &n, &m); if ((n + m) & 1) returnputs("0"), 0; m = (n + m) >> 1; for (int i = 1; i <= n; ++i) scanf("%d", a + i); for (int i = 1; i <= n; ++i) scanf("%d", b + i); prev(); std::sort(a + 1, a + n + 1); std::sort(b + 1, b + n + 1); for (int i = 1, j = 0; i <= n; ++i) { while (j < n && a[i] > b[j + 1]) ++j; c[i] = j; } f[0] = 1; for (int i = 1; i <= n; ++i) for (int j = std::min(c[i], i); j; --j) adj(f[j] += LL(c[i] - (j - 1)) * f[j - 1] % P - P); for (int i = 0; i <= n; ++i) f[i] = LL(f[i]) * fac[n - i] % P; for (int i = m; i <= n; ++i) if ((i - m) & 1) adj(ans -= LL(f[i]) * C(i, m) % P); elseadj(ans += LL(f[i]) * C(i, m) % P - P); printf("%d\n", ans); return0; }