#include #include #define rep(i,n) for (int i = 0; i < int(n); ++i) #define repb(i,n) for (int i = int(n)-1; i >= 0; --i) using namespace std; using namespace atcoder; using ll = long long; using mint = modint998244353; int main(){ int n; cin >> n; ll X; cin >> X; mint z = X; vector x(n); vector y(n); rep(i,n){ ll a, b; cin >> a >> b; x[i] = a; y[i] = b; } vector lrui(n+1,1); vector rrui(n+1,1); rep(i,n) lrui[i+1] = lrui[i] * (z - x[i]); repb(i,n) rrui[i] = rrui[i+1] * (z - x[i]); vector dxs(n,1); rep(i,n) rep(j,n){ if (i == j) continue; dxs[i] *= x[i] - x[j]; } rep(i,n) dxs[i] = mint(1) / dxs[i]; mint a = 0, b = 0, c = 0; rep(i,n) a += y[i] * lrui[i] * rrui[i+1] * dxs[i]; a *= n; rep(i,n) b += y[i] * dxs[i]; rep(i,n) c += lrui[i] * rrui[i+1]; mint ans = a - b * c; cout << ans.val() << endl; }