Elaine is in charge of assigning classrooms for her new school. She has n different grades, each with k distinct students in each grade. Thus, Elaine has a total of n × k distinct students.
Elaine wants to arrange the classrooms in a line. She does this as follows.
Elaine wonders how many different arrangements she can create. Two arrangements are different if one of the conditions holds:
Help Elaine count the number of valid arrangements. Print this number modulo 167772161.
Input format:
The first and only line of input will contain two integers n,k.
Output format:
The output will be just one line, representing the number of ways modulo 167772161.
Constraints:
18 pts:
1 ≤ n ≤ 3
1 ≤ k ≤ 3
25 pts:
1 ≤ n ≤ 10,000
1 ≤ k ≤ 2
40 pts:
1 ≤ n ≤ 50
1 ≤ k ≤ 50
17 pts:
1 ≤ n ≤ 10,000
1 ≤ k ≤ 50
Call the grades A and B. Let A1,A2 be the students from grade A, and B1,B2 be the students from B. In the following notation, brackets denote a classroom. The fourteen distinct ways are as follows:
The following arrangements are either invalid, or equivalent to one of the ways above: