8566: The Pool

内存限制:1024 MB 时间限制:2 S 标准输入输出
题目类型:传统 评测方式:文本比较 上传者:
提交:1 通过:0

题目描述

链接:https://ac.nowcoder.com/acm/contest/33192/D
来源:牛客网
Marisa wants to build an n×mn \times mn×m rectangular swimming pool for Alice. To do this, Marisa can select four integral points on an infinite 2D-grid and cast magic. For example, the following picture shows three possible ways to build a 5×55 \times 55×5 swimming pool.



Marisa soon learns that there are many ways to build the pool since four sides of the pool can be non-parallel to coordinate axis. Here two ways are considered different if and only if the pool in one way can't be translated (moved without rotation and flipping) to the pool in the other way. Now Marisa becomes curious about the total numbers of complete 1×11 \times 11×1 squares inside the pool for all possible ways. As the result can be very large, you should print it modulo 998244353998\,244\,353998244353.

输入格式


In the first line, there is one integer TTT (1≤T≤1041\leq T\leq 10^41T104), denoting the number of test cases.
For each test case, there is one line containing two numbers nnn and mmm (1≤n,m≤10181\leq n,m\leq 10^{18}1n,m1018), denotes the size of swimming pool.
It is guaranteed that there are at most 10 cases that max(n,m)>109max(n,m) > 10^9max(n,m)>109.

输出格式



For each test case, print one number, denoting the total number of complete 1×11 \times 11×1 squares inside the pool for all possible ways (modulo 998244353998\,244\,353998244353).).

输入样例 复制

5
5 5
2 3
5 10
2197525579 1145141
91 65

输出样例 复制

51
12
228
438744975
34722

分类标签