p8774
include<bits/stdc++.h>
using namespace std;
define int long long
define f(i, a, b) for(int i = (a); i <= (b); i++)
define cl(i, n) i.clear(),i.resize(n);
define endl '\n'
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
const int inf = 1e9;
void cmax(int &x, int y) {if(x < y) x = y;}
void cmin(int &x, int y) {if(x > y) x = y;}
int x[100100], y[100010];
const int mod = 998244353;
int p[100010], q[100010], c[100010];
int qpow(int x, int k) {
int ans = 1;
while(k){
if(k&1) ans=ansx%mod;
x=xx%mod;
k>>=1;
}
return ans;
}
signed main() {
ios::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
time_t start = clock();
//think twice,code once.
//think once,debug forever.
int n; cin >> n;
f(i, 0, n - 1) {
cin >> x[i] >> y[i];
p[i] = x[i] * qpow(y[i], mod - 2) % mod;
}
q[n-1]=p[n-1];
c[n - 1] = 1;
for(int i = n - 2; i >= 0; i--) {
q[i] = ((1 - p[i] + mod) % mod) * q[i + 1] % mod + p[i];
q[i] %= mod;
c[i] = (1 - p[i] + mod) %mod*c[i+1]%mod + 1;
}
cout << c[0] * qpow((1 - q[0] + mod) % mod, mod - 2) % mod;
time_t finish = clock();
//cout << "time used:" << (finish-start) * 1.0 / CLOCKS_PER_SEC <<"s"<< endl;
return 0;
}