#include #include using namespace atcoder; using mint = modint998244353; using namespace std; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf 1000000001 vector f(1000000,true); bool check(int a,int b){ string s = to_string(a); s += to_string(b); return f[stoi(s)]; } int main() { int n; cin>>n; vector a(n),b(n); rep(i,n){ cin>>a[i]>>b[i]; } f[1] = false; for(int i=2;i