logo AlgoBeat OnlineJudge
登录 注册

#212923. [NERC 2020 Online] Geometrical Combinatorics

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

题目描述

Grace is developing a brand new theory of geometrical combinatorics --- a study about geometrical properties of combinatoric objects.

Consider two triangles on plane --- a Pascal's triangle and an ordinary triangle. Pascal's triangle is drawn with it's root at point (0, 0), and two sides along diagonals of upper-halfplane quarters. Formally, there are 1's written in points and , and between them at point there is a number equal to the sum of numbers at and at for all from to . An ordinary triangle is drawn as just a triangle with vertices at , , .

Grace defines an of Pascal's triangle and an ordinary triangle as the sum of values of Pascal's triangle inside or on the border of the ordinary triangle. Can you develop a program that calculates this intersection value?

输入格式

On the first line there is an integer () --- the number of tests to process. Each of the next lines contains 6 integers , , , , , (). Three points in each test do not lie on a line.

输出格式

For each test output an integer --- the intersection value modulo .

样例

样例输入 1

2
0 -1 -4 3 4 3
5 4 0 1 3 -2

样例输出 1

15
2