{"raw_statement":[{"iden":"problem statement","content":"For an integer sequence $X=(X_1,X_2,\\dots,X_N)$ of length $N$ whose elements are all between $1$ and $N$ (inclusive), consider the question below, and let $f(X)$ be the answer.\n\n> There is an undirected graph $G$ with $N$ vertices (and possibly multi-edges and self-loops). $G$ has $N$ edges, the $i$\\-th of which connects Vertex $i$ and Vertex $X_i$. Find the number of connected components in $G$.\n\nYou are given an integer sequence $A=(A_1,A_2,\\dots,A_N)$ of length $N$, where each $A_i$ is an integer between $1$ and $N$ (inclusive) or $-1$.\nConsider an integer sequence $X=(X_1,X_2,\\dots,X_N)$ of length $N$ whose elements are all between $1$ and $N$ such that $A_i \\neq -1 \\Rightarrow A_i = X_i$. Find the sum of $f(X)$ over all such $X$, modulo $998244353$."},{"iden":"constraints","content":"*   $1 \\le N \\le 2000$\n*   $A_i$ is between $1$ and $N$ (inclusive) or $-1$.\n*   All values in input are integers."},{"iden":"input","content":"Input is given from Standard Input in the following format:\n\n$N$\n$A_1$ $A_2$ $\\dots$ $A_N$"},{"iden":"sample input 1","content":"3\n-1 1 3"},{"iden":"sample output 1","content":"5\n\nThere are three sequences $X$ satisfying the requirement, as follows.\n\n*   $X=(1,1,3)$, for which the answer to the question is $2$.\n*   $X=(2,1,3)$, for which the answer to the question is $2$.\n*   $X=(3,1,3)$, for which the answer to the question is $1$.\n\nThus, the answer is $2+2+1=5$."},{"iden":"sample input 2","content":"1\n1"},{"iden":"sample output 2","content":"1"},{"iden":"sample input 3","content":"8\n-1 3 -1 -1 8 -1 -1 -1"},{"iden":"sample output 3","content":"433760"}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}