It's a loving community!
There are
n residents in the community, and each resident
i (1≤i≤n) in the community has a unique resident
ai (1≤i≤n) in the community whom he/she loves so much. Each two residents love different residents. A resident can love himself / herself. It is guaranteed that
n is even.
One day, a bad thing happens: They need to choose
2 residents to be forbidden to get married forever.
And to prevent such a thing from happening in the future, the rest
n−2 residents decide to get married as
n/2−1 couples, each couple consisting of
2 persons (of course). It makes no sense that a couple consists of resident
x and resident
y while neither
x loves
y nor
y loves
x, so such a thing never happens.
So, as the planner, you need to figure out how you can arrange this. You want to know the number of different marriage plans. Two marriage plans are considered different if at least one of the following conditions is satisfied:
-
In one plan, a person i is married, and in the other, he/she is not.
-
In one plan, a person i is married to j, and in the other, he/she is not married to j.
As the number of plans can be quite enormous, output it modulo 998 244 353.