3850: Another Chess Problem

内存限制:128 MB 时间限制:1.000 S
评测方式:文本比较 命题人:
提交:1 解决:1

题目描述

You are given an infinite set S={(x,y)|x,y∈Z,¬∃i,j∈Zs.t.x=2i+j,y=i−2j} and two pairs (x1,y1),(x2,y2)∈S

You have a pair (x,y) in your right pocket which equals to (x1,y1) in the beginning. You can pay Y_UME a coin at a time and then change (x,y) to one element in S whose distance to (x,y) is 1. The distance between (a1,b1) and (a2,b2) is defined as |a1−a2|+|b1−b2|

You expect to get (x2,y2) and minimize the number of coins given to Y_UME. Output the minimum number of coins and output the number of different ways to achieve the goal modulo 998244353.

Note that two ways differ if and only if there exsits some i such that i-th steps in the two ways are different.

输入

The first line contains one positive integer T(T≤2×105) denoting the number of test cases.

Each case starts with a line containing four integers x1,y1,x2,y2(−105≤x1,y1,x2,y2≤105).

输出

For each test case, output one line containing two integers denoting the minimum number of coins and the number of different ways modulo 998244353.

样例输入 复制

3
1 1 5 2
1 1 2 5
1 1 1 1

样例输出 复制

7 5
5 1
0 1

来源/分类