#NC2401A. A Bit Common

A Bit Common

题目描述

Given two integers nn and mm, among all the sequences containing nn non-negative integers less than 2m2^m, you need to count the number of such sequences AA that there exists a non-empty subsequence of AA in which the bitwise AND of the integers is 11.

Note that a non-empty subsequence of a sequence AA is a non-empty sequence that can be obtained by deleting zero or more elements from AA and arranging the remaining elements in their original order.

Since the answer may be very large, output it modulo a positive integer qq.

The bitwise AND of non-negative integers AA and BB, A & BA\ \&\ B is defined as follows:

  • When A & BA\ \&\ B is written in base two, the digit in the 2d2^d's place (d0d≥0) is 11 if those of AA and BB are both 11, and 00 otherwise.

For example, we have 4 & 64\ \&\ 6 = 44 (in base two: 100 & 110100\ \&\ 110 = 100100).

Generally, the bitwise AND of kk non-negative integers p1,p2,,pkp_1,p_2,…,p_k is defined as (((p1 & p2) & p3)&& pk)(…((p_1\ \&\ p_2)\ \&\ p_3)\& … \&\ p_k) and we can prove that this value does not depend on the order of p1,p2,,pkp_1,p_2,…,p_k.

输入格式

The only line contains three integers nn (1n5000)(1≤n≤5000), mm (1m5000)(1≤m≤5000) and qq (1q109)(1≤q≤10^9).

输出格式

Output a line containing an integer, denoting the answer.

2 3 998244353
17
5000 5000 998244353
2274146