#include <iostream> #include <atcoder/modint> using namespace std; using namespace atcoder; using mint = modint998244353; mint x[10010],y[10010],z[10010],sumL[10010],sumR[10010],dif[10010]; int main(){ int i,j,n; cin >> n; int a; cin >> a; mint X = a; for(i=0;i<n;i++){ int b,c; cin >> b >> c; x[i] = b; y[i] = c; } for(i=0;i<n;i++){ dif[i] = 1; for(j=0;j<n;j++){ if(j==i) continue; dif[i] *= (x[i] - x[j]); } } sumL[0] = 1; for(i=1;i<=n;i++) sumL[i] = sumL[i - 1]*(X - x[i]); sumR[n] = 1; for(i=n - 1;i>=0;i--) sumR[i] = sumR[i + 1]*(X - x[i]); mint ans = 0; for(i=0;i<n;i++){ ans += y[i]*sumL[i]*sumR[i + 1]/dif[i]; } ans *= (mint)(n - 1); for(i=0;i<n;i++) z[i] = y[i]/dif[i]; mint sum = 0; for(i=0;i<n;i++) sum += z[i]; for(i=0;i<n;i++){ ans -= (sum - z[i])*sumL[i]*sumR[i + 1]; } cout << ans.val() << "\n"; }