시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB24141050.000%

문제

Compute the number of ways to choose two subsets $X, Y \subseteq \{2, 3, \dots, n\}$ such that there does not exist $x \in X, y \in Y$ such that $x$ and $y$ are not relatively prime. The sets $X, Y$ may be empty. Output the number of ways modulo $p$.

입력

The input contains the integer $n$ and the modulo $p$ separated by a space.

출력

Output the number of ways to choose the subsets $X, Y \subseteq \{2, 3, \dots, n\}$ satisfying the condition above.

제한

  • $2 \le n \le 500$
  • $0 < p \le 1\,000\,000\,000$

예제 입력 1

3 10000

예제 출력 1

9

예제 입력 2

4 10000

예제 출력 2

21

예제 입력 3

100 100000000

예제 출력 3

3107203