{"problem":{"name":"Cards","description":{"content":"There are $N$ cards numbered $1,\\ldots,N$. Card $i$ has $P_i$ written on the front and $Q_i$ written on the back.   Here, $P=(P_1,\\ldots,P_N)$ and $Q=(Q_1,\\ldots,Q_N)$ are permutations of $(1, 2, \\dot","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"abc247_f"},"statements":[{"statement_type":"Markdown","content":"There are $N$ cards numbered $1,\\ldots,N$. Card $i$ has $P_i$ written on the front and $Q_i$ written on the back.  \nHere, $P=(P_1,\\ldots,P_N)$ and $Q=(Q_1,\\ldots,Q_N)$ are permutations of $(1, 2, \\dots, N)$.\nHow many ways are there to choose some of the $N$ cards such that the following condition is satisfied? Find the count modulo $998244353$.\nCondition: every number $1,2,\\ldots,N$ is written on at least one of the chosen cards.\n\n## Constraints\n\n*   $1 \\leq N \\leq 2\\times 10^5$\n*   $1 \\leq P_i,Q_i \\leq N$\n*   $P$ and $Q$ are permutations of $(1, 2, \\dots, N)$.\n*   All values in input are integers.\n\n## Input\n\nInput is given from Standard Input in the following format:\n\n$N$\n$P_1$ $P_2$ $\\ldots$ $P_N$\n$Q_1$ $Q_2$ $\\ldots$ $Q_N$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"abc247_f","tags":[],"sample_group":[["3\n1 2 3\n2 1 3","3\n\nFor example, if you choose Cards $1$ and $3$, then $1$ is written on the front of Card $1$, $2$ on the back of Card $1$, and $3$ on the front of Card $3$, so this combination satisfies the condition.\nThere are $3$ ways to choose cards satisfying the condition: ${1,3},{2,3},{1,2,3}$."],["5\n2 3 5 4 1\n4 2 1 3 5","12"],["8\n1 2 3 4 5 6 7 8\n1 2 3 4 5 6 7 8","1"]],"created_at":"2026-03-03 11:01:13"}}