#define int long long constint N = 2010, P = 998244353; int n, k, x[N], y[N];
intqmi(int a, int k){ int res = 1; while (k) { if (k & 1) res = res * a % P; a = a * a % P; k >>= 1; } return res; }
signedmain(){ cin >> n >> k; for (int i = 1; i <= n; i++) cin >> x[i] >> y[i]; int res = 0; for (int i = 1; i <= n; i++) { int val = 1; for (int j = 1; j <= n; j++) if (i != j) val = val * qmi(x[i] - x[j], P-2) % P * (k - x[j]) % P; res = (res + y[i] * val) % P; } if (res < 0) res += P; cout << res << endl; return0; }
#define int long long constint K = 1000010, P = 1e9+7; int n, k, f[K], pn[K], sn[K], ifact[K];
intqmi(int a, int k){ int res = 1; while (k) { if (k & 1) res = res * a % P; a = a * a % P; k >>= 1; } return res; }
signedmain(){ cin >> n >> k; int m = k+2, factm = 1; for (int i = 1; i <= m; i++) f[i] = (f[i-1] + qmi(i, k)) % P, factm = factm * i % P; ifact[m] = qmi(factm, P-2); for (int i = m-1; i >= 0; i--) ifact[i] = ifact[i+1] * (i+1) % P; pn[0] = sn[m+1] = 1; // 这里 n 如果很大 可能导致溢出 n %= P; for (int i = 1; i <= m; i++) pn[i] = pn[i-1] * (n - i) % P; for (int i = m; i >= 0; i--) sn[i] = sn[i+1] * (n - i) % P; int res = 0; for (int i = 1; i <= m; i++) { int v1 = f[i] * pn[i-1] % P * sn[i+1] % P * ifact[m-i] % P * ifact[i-1] % P; if ((m - i) % 2) v1 = -v1; if (v1 < 0) v1 += P; res = (res + v1) % P; } cout << res << endl; return0; }