logo AlgoBeat OnlineJudge
登录 注册

#217584. [ICPC 2019 Yinchuan R] Easy Problem

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

题目描述

A sequence is -good if and .

Given four integers , , and , you are asked to calculate the sum of for each -good sequence , where for the sequence .

Since the answer could be very large, you only need to output the answer modulo .

输入格式

The first line is an integer , which is the number of test cases.

For each test case, the first line contains four integers , , , , which are described in the problem description.

输出格式

For each test case, output a line containing a single integer.

样例

样例输入 1

1
3 3 3 1

样例输出 1

27