#P6899. Xor

    ID: 5756 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: (无) 上传者: 标签>2020中国大学生程序设计竞赛(CCPC) - 网络选拔赛

Xor

Problem Description

Given $A,B,K,W$, Kanade wants to know the number of $(x,y)$ which satisfies the following conditions:

1. $x,y$ are integers

2. $x\in [0,A],y\in [0,B]$

3. $|x-y|\leq K$

4. $x~xor~y\leq W$

Input

There are $T$ test cases in this problem.

The first line has 1 integer $T$.

Then for every test case, the first line has 4 integers $A,B,K,W$

$1\leq T\leq 2000$

$0\leq A,B,K,W\leq 10^9$

Output

For every test case, output the answer in a line.

3 3 3 1 2 10 10 3 7 998244353 998244353 114514 123456789
8 53 228430202591616