logo AlgoBeat OnlineJudge
登录 注册

#217364. [ICPC 2026 Xi'an I] Unreachable Land

内存限制:1024 MiB 时间限制:2000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

Yuki dreams of reaching the unreachable land. After years of hard work, only this problem remains before her.

Given three integers . You need to perform rounds of operations. In the -th round, you can either set or choose not to modify . Find the number of ways to make after rounds, modulo .

Two schemes are considered different if and only if there exists some such that in one scheme you performed a modification in the -th round, while in the other you did not. Note that choosing to perform is considered a modification, regardless of whether the value of changes after the operation.

You once dreamed of reaching the unreachable land that only exists in fairy tales. Now that Yuki has a chance to realize this dream, you must help her.

输入格式

This problem contains multiple test cases.

The first line contains a positive integer , representing the number of test cases.

For each test case:

  • A single line contains three integers .

It is guaranteed that the sum of over all test cases does not exceed .

输出格式

For each test case, output a single line containing an integer representing the answer modulo .

样例

样例输入 1

5
5 0 5
5 2 3
10 1 7
10 6 10
100000 114 514

样例输出 1

25
1
14
0
837481226

数据范围与提示

For the first test case:

  • One valid operation scheme is to perform modifications in the -rd and -th rounds.
  • Another valid operation scheme is to perform modifications in all rounds from to .

For the second test case:

  • The only valid operation scheme is to perform a modification in the -rd round.

For the fourth test case:

  • It can be proven that no valid operation scheme exists.