Counting Triangles 2

Xem dạng PDF

Gửi bài giải


Điểm: 0,87 (OI)
Giới hạn thời gian: 1.0s
Giới hạn bộ nhớ: 256M
Input: stdin
Output: stdout

Nguồn bài:
From CT problem
Dạng bài
Ngôn ngữ cho phép
C, C++, Go, Java, Kotlin, Pascal, PyPy, Python, Rust, Scratch

This is a new version of problem CT with the new limit and the result will be written in modulo ~2009~ Consider a 2D integer grid with lower left corner at ~(0~, ~0)~ and upper right corner at ~(X~, ~Y)~. We are interested in isosceles right triangles which all the ~3~ corners at the grid node (integer coordinates). Your task is to count the number of those triangles.

Input

The input begins with ~C~ -- number of test cases.

Each test case consists of ~X~, ~Y~.

Output

For each test case, output the result in a line.

Giới hạn

~X~, ~Y \le 10000~

~C \le 200~

Sample Input

2
0 3
1 1

Sample Output

0
4

Bình luận

Hãy đọc nội quy trước khi bình luận.


Không có bình luận tại thời điểm này.