#pragma GCC optimize("Ofast") #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long int ll; typedef unsigned long long ull; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); ll myRand(ll B) { return (ull)rng() % B; } inline double time() { return static_cast(chrono::duration_cast(chrono::steady_clock::now().time_since_epoch()).count()) * 1e-9; } constexpr ll mod = 998244353; int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); int n,x,y; cin >> n >> x >> y; vector a(x),b(y); for(int i=0;i> a[i]; } for(int i=0;i> b[i]; } ll res = 0; for(int i=0;i<18;i++){ array dp; dp[0] = 1; dp[1] = 0; ll z = 0, o = 0; for(int j:a){ if((1< ndp; ndp[1] = (dp[0]+dp[1])*o + dp[1]*z; ndp[1] %= mod; ndp[0] = dp[0]*z; ndp[0] %= mod; swap(dp,ndp); } { array ndp; ndp[1] = dp[1]*oo; ndp[1] %= mod; ndp[0] = (dp[0]+dp[1])*zz + dp[0]*oo; ndp[0] %= mod; swap(dp,ndp); } } res += dp[1] * (1LL<