{"raw_statement":[{"iden":"problem statement","content":"Let $S$ be a set composed of all integers from $1$ through $N$.\n$f$ is a function from $S$ to $S$. You are given the values $f(1), f(2), \\cdots, f(N)$ as $f_1, f_2, \\cdots, f_N$.\nFind the number, modulo $998244353$, of non-empty subsets $T$ of $S$ satisfying both of the following conditions:\n\n*   For every $a \\in T$, $f(a) \\in T$.\n    \n*   For every $a, b \\in T$, $f(a) \\neq f(b)$ if $a \\neq b$."},{"iden":"constraints","content":"*   $1 \\leq N \\leq 2 \\times 10^5$\n*   $1 \\leq f_i \\leq N$\n*   All values in input are integers."},{"iden":"input","content":"Input is given from Standard Input in the following format:\n\n$N$\n$f_1$ $f_2$ $\\ldots$ $f_N$"},{"iden":"sample input 1","content":"2\n2 1"},{"iden":"sample output 1","content":"1\n\nWe have $f(1) = 2, f(2) = 1$. Since $f(1) \\neq f(2)$, the second condition is always satisfied, but the first condition requires $T$ to contain $1$ and $2$ simultaneously."},{"iden":"sample input 2","content":"2\n1 1"},{"iden":"sample output 2","content":"1\n\nWe have $f(1) = f(2) = 1$. The first condition requires $T$ to contain $1$, and the second condition forbids $T$ to contain $2$."},{"iden":"sample input 3","content":"3\n1 2 3"},{"iden":"sample output 3","content":"7\n\nWe have $f(1) = 1, f(2) = 2, f(3) = 3$. Both of the conditions are always satisfied, so all non-empty subsets of $T$ count."}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}