Subspace

아직 제출이 없습니다시간 제한1초메모리 제한512 MB

문제

bobo is a big fan of linear algebra! He plans to count the number of kk-dimension subspaces in F_qn\mathbb{F}\_q^n modulo pp.

For those who are not familiar with linear algebra:

  • F_q\mathbb{F}\_q is the set 0,1,,q1\\{0, 1, \dots, q - 1\\}, with addition and multiplication modulo qq defined on;
  • F_qn\mathbb{F}\_q^n is the nn-dimension vector space (x_1,x_2,,x_n):x_1,x_2,,x_nF_q\\{(x\_1, x\_2, \dots, x\_n) : x\_1, x\_2, \dots, x\_n \in \mathbb{F}\_q\\};
  • A subset KF_qnK \subseteq \mathbb{F}\_q^n is a subspace, if and only if for all p,qK\mathbf{p}, \mathbf{q} \in K, p+qK\mathbf{p} + \mathbf{q} \in K;
  • The dimension of subspace KK is the cardinality of the maximal independent subset;
  • A subset p_1,p_2,,p_kK\\{\mathbf{p}\_1, \mathbf{p}\_2, \dots, \mathbf{p}\_k\\} \subseteq K is called independent if and only if equation c_1p_1+c_2p_2++c_kp_k=0c\_1 \cdot \mathbf{p}\_1 + c\_2 \cdot \mathbf{p}\_2 + \dots + c\_k \cdot \mathbf{p}\_k = 0 has only solution c_1=c_2==c_k=0c\_1 = c\_2 = \dots = c\_k = 0.

입력

44 integers q,n,k,pq, n, k, p (2q109,1kn109,2p21052 \leq q \leq 10^9, 1 \leq k \leq n \leq 10^9, 2 \leq p \leq 2 \cdot 10^5).

It is guaranteed that pp and qq are prime numbers.

출력

A single integer denotes the number of subspaces.