QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 512 MB Total points: 100 Hackable ✓

#5495. Sushi Banquet

Statistics

To celebrate the successful opening of NOI, the organizers have prepared a sushi banquet. Xiao G and Xiao W, as participants of NOI, have also been invited to the sushi banquet.

At the banquet, the organizers provide $n-1$ different types of sushi, numbered $1, 2, 3, \dots, n-1$, where the $i$-th type of sushi has a deliciousness of $i+1$ (i.e., the deliciousness ranges from $2$ to $n$).

Now, Xiao G and Xiao W each wish to choose some types of sushi to taste. They define a tasting scheme as "disharmonious" if and only if: there exists a sushi with deliciousness $x$ among the types Xiao G tastes, and a sushi with deliciousness $y$ among the types Xiao W tastes, such that $x$ and $y$ are not coprime.

Xiao G and Xiao W wish to count the total number of "harmonious" sushi tasting schemes (modulo a given positive integer $p$). Note that a person may choose to eat no sushi at all.

Input

The first line contains two positive integers $n$ and $p$, separated by a single space, representing that there are $n$ types of sushi (with deliciousness up to $n$), and the final number of harmonious schemes should be taken modulo $p$.

Output

Output a single integer representing the result of the required number of schemes modulo $p$.

Constraints

Test Case ID $n$ Range Constraints
1 $2 \le n \le 30$ $0 < p \le 10,000,000,000$
2 $2 \le n \le 30$
3 $2 \le n \le 30$
4 $2 \le n \le 100$
5 $2 \le n \le 100$
6 $2 \le n \le 200$
7 $2 \le n \le 200$
8 $2 \le n \le 200$
9 $2 \le n \le 500$
10 $2 \le n \le 500$

Examples

Input 1

3 10000

Output 1

9

Input 2

4 10000

Output 2

21

Input 3

100 100000000

Output 3

3107203

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.