#AGC044F. [AGC044F] Name-Preserving Clubs

[AGC044F] Name-Preserving Clubs

Score : 24002400 points

Problem Statement

There are NN people (with different names) and KK clubs. For each club you know the list of members (so you have KK unordered lists). Each person can be a member of many clubs (and also 00 clubs) and two different clubs might have exactly the same members. The value of the number KK is the minimum possible such that the following property can be true for at least one configuration of clubs. If every person changes her name (maintaining the property that all names are different) and you know the new KK lists of members of the clubs (but you don't know which list corresponds to which club), you are sure that you would be able to match the old names with the new ones.

Count the number of such configurations of clubs (or say that there are more than 10001000). Two configurations of clubs that can be obtained one from the other if the NN people change their names are considered equal.

Formal statement: A club is a (possibly empty) subset of {1,,N}\{1,\dots, N\} (the subset identifies the members, assuming that the people are indexed by the numbers 1,2,,N1, 2,\dots, N). A configuration of clubs is an unordered collection of KK clubs (not necessarily distinct). Given a permutation σ(1),,σ(N)\sigma(1), \dots, \sigma(N) of {1,,N}\{1,\dots, N\} and a configuration of clubs L={C1,C2,,CK}L=\{C_1, C_2, \dots, C_K\}, we denote with σ(L)\sigma(L) the configuration of clubs {σ(C1),σ(C2),,σ(CK)}\{\sigma(C_1), \sigma(C_2), \dots, \sigma(C_K)\} (if CC is a club, σ(C)={σ(x):xC}\sigma(C)=\{\sigma(x):\, x\in C\}). A configuration of clubs LL is name-preserving if for any pair of distinct permutations στ\sigma\not=\tau, it holds σ(L)τ(L)\sigma(L)\not=\tau(L).

You have to count the number of name-preserving configurations of clubs with the minimum possible number of clubs (so KK is minimum). Two configurations L1,L2L_1, L_2 such that L2=σ(L1)L_2=\sigma(L_1) (for some permutation σ\sigma) are considered equal. If there are more than 10001000 such configurations, print 1-1.

Constraints

  • 2N210182 \le N \le 2\cdot10^{18}

Input

The input is given from Standard Input in the format

NN

Output

If ansans is the number of configurations with the properties described in the statement, you should print on Standard Output

ansans

If there are more than 10001000 such configurations, print 1-1.

2
1

The value of KK is 11 and the unique name-preserving configuration of clubs is {{1}}\{\{1\}\} (the configuration {{2}}\{\{2\}\} is considered the same).

3
1

The value of KK is 22 and the unique (up to permutation) name-preserving configuration of clubs is {{1},{1,2}}\{\{1\}, \{1, 2\}\}.

4
7

The value of KK is 33 and the name-preserving configurations of clubs with 33 clubs are:

  • {{1},{2},{1,3}}\{\{1\}, \{2\}, \{1, 3\}\}
  • {{1},{1,2},{2,3}}\{\{1\}, \{1, 2\}, \{2, 3\}\}
  • {{1,2},{1,2},{1,3}}\{\{1, 2\}, \{1, 2\}, \{1, 3\}\}
  • {{1},{1,2},{1,2,3}}\{\{1\}, \{1, 2\}, \{1, 2, 3\}\}
  • {{1},{2,3},{1,2,4}}\{\{1\}, \{2, 3\}, \{1, 2, 4\}\}
  • {{1,2},{1,3},{1,2,4}\{\{1, 2\}, \{1, 3\}, \{1, 2, 4\}
  • {{1,2},{1,2,3},{2,3,4}}\{\{1, 2\}, \{1, 2, 3\}, \{2, 3, 4\}\}
13
6
26
-1
123456789123456789
-1