# P3807 [Template] Lucas Theorem ## 题目背景 This is a template problem. ## 题目描述 Given integers $n, m, p$, compute $C_{n + m}^n \bmod p$. The input guarantees that $p$ is prime. Note: $C$ denotes the binomial coefficient. ## 输入格式 This problem contains multiple test cases. The first line contains an integer $T$, the number of test cases. For each test case: One line with three integers $n, m, p$. ## 输出格式 For each test case, output one line with one integer, the required value. ## 输入输出样例 #1 ### 输入 #1 ``` 2 1 2 5 2 1 5 ``` ### 输出 #1 ``` 3 3 ``` ## 说明/提示 For $100\%$ of the testdata, $1 \leq n, m, p \leq 10^5$, $1 \leq T \leq 10$. Translated by ChatGPT 5