logo AlgoBeat OnlineJudge
登录 注册

#213871. [CERC 2021] Lines in a grid

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

题目描述

Suppose that we are given a integer grid, e.g. . Let be the number of different lines that intersect with at least two points on the grid.

For , there are exactly 20 such lines, as drawn on the image below.

:::align{center} :::

Compute for all given .

输入格式

First line contains an integer – the number of queries. The second line contains space-separated integers .

输出格式

Print numbers , each in its own line. Since can be large, print them modulo .

样例

样例输入 1

3
1 3 2

样例输出 1

0
20
6

数据范围与提示

Input limits