Festivals in JOI Kingdom 2

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

문제

In JOI Kingdom, a national festival is held once a year. During the period of the festival, there are NN events in total. The schedule for each event is already fixed. The schedule of the NN events are described by sequences aa, bb of length NN satisfying the following conditions.

  • Every integer between 11 and 2N2N, inclusive, appears as an element of aa or bb.
  • a_i<b_ia\_i < b\_i (1iN1 ≤ i ≤ N).
  • a_i<a_i+1a\_i < a\_{i+1} (1iN11 ≤ i ≤ N - 1).

The ii-th event will start at a_ia\_i minutes after the beginning of the festival, and end at b_ib\_i minutes after the beginning of the festival.

Participants of the festival may choose any events in which they will participate. However, it is not allowed to participate in two events whose schedules overlap. (Note that the starting times and the ending times of the events are different from each other.)

JOI-kun wants to participate in as many events as possible. Until last year, he chose the events in which he participated by the following procedures on a computer.

  • For i=1,2,,Ni = 1, 2, \dots , N, the following are done in this order.
    • If the schedule of the ii-th event does not overlap the schedules of the other events in which he already chose to participate, he will participate in the ii-th event. Otherwise, he will not participate in the ii-th event.

However, after studying computer science, JOI-kun noticed that the above algorithm does not necessarily maximize the number of events in which JOI-kun will participate. From this year, JOI-kun will use an improved algorithm. Using the improved algorithm, JOI-kun will be able to maximize the number of events in which JOIkun will participate.

JOI-kun wants to know the number of cases where the improved algorithm produces a larger number of events.

Write a program which, given the integer NN and a large prime number PP, calculates the number of pairs of sequences aa, bb describing the schedules of the NN events for which the improved algorithm produces a larger number of events. Since the answer can be very large, your program should output the remainder of the answer when divided by PP.

입력

Read the following data from the standard input.

NN PP

출력

Write one line to the standard output. The output should contain the remainder of the answer, the number of pairs of sequences aa, bb describing the schedules of the NN events for which the improved algorithm produces a larger number of events, when divided by PP.

제한

  • 1N20,0001 ≤ N ≤ 20\\,000.
  • 108<P<10910^8 < P < 10^9.
  • PP is a prime number.
  • Given values are all integers.