#P13561. 「WWOI R1」WsW 的笔
「WWOI R1」WsW 的笔
Background
WsW is planning to give some pens to bln.
Problem Description
WsW has pens. Each pen has a unique integer label in the range . He decides to give some of the pens to bln and keep the rest for himself.
When all pens satisfy the following conditions, WsW considers the plan an excellent pen-giving plan:
- If the pen labeled is given to bln, then the pen labeled must be kept by WsW.
- If the pen labeled is kept by WsW, then the pen labeled must be given to bln.
Of course, these conditions only apply if WsW has a pen labeled .
WsW believes that if a pen with some label is given away in one plan but kept in another plan, then these two pen-giving plans are different.
Now all pens have been labeled. WsW wants to know how many different excellent pen-giving plans there are in total.
Since the answer may be very large, you only need to output the total number of plans modulo .
Input Format
This problem contains multiple test cases.
The first line contains a positive integer , which is the number of test cases.
Then follow test cases. Each test case is formatted as follows:
The first line contains a positive integer .
The second line contains two positive integers , which specify the range of pen labels.
Output Format
For each test case, output one line containing an integer, indicating the number of different excellent pen-giving plans. Output the answer modulo .
1
2
2 2
2
1
3
1 4
8
1
114
514 1919810
532406817
Hint
Sample Explanation
| Plan | Given labels | Kept labels |
|---|---|---|
| None | ||
| None |
There are different excellent pen-giving plans in total.
Sample Explanation
| Plan | Given labels | Kept labels |
|---|---|---|
There are different excellent pen-giving plans in total.
Constraints
This problem uses bundled tests.
For all testdata, it is guaranteed that , , .
| Subtask ID | Special Property | Score | |
|---|---|---|---|
| None | |||
| B | |||
| None | |||
| A | |||
| B | |||
| None | |||
| A | |||
| B | |||
| None |
- Special Property A: .
- Special Property B: .
Translated by ChatGPT 5