War is cruel .Every one has a boss except LvBu. LvBu want to rally the troops to make his army stronger .
The rule is: everyone may have 0~2 deputy generals and must have only one boss(except LvBu).Everyone has his own level(all levels are different),and his deputy generals' level must less than his. You can assume no one is more levelful than LvBu.
For example , LvBu's level is 4,ChenGong's level is 3,ZhangLiao's level is 2 and GaoShun's level is 1.So,We can make five way :
Now ,give you the number of generals in LvBu's army.Please tell me the number of possible methods?
The answer might be very large. Output your answers mod k.
Each line contains two integers n and k, indicating the number of LvBu's generals (including LvBu).
1<= n <= 1000;2<=k<=1,000,000,000
For each case, output an answer mod k.