**Mathematical Circus solution codeforces** – A new entertainment has appeared in Buryatia — a mathematical circus! The magician shows two numbers to the audience — 𝑛n and 𝑘k, where 𝑛n is even. Next, he takes all the integers from 11 to 𝑛n, and splits them all into pairs (𝑎,𝑏)(a,b) (each integer must be in exactly one pair) so that for each pair the integer (𝑎+𝑘)⋅𝑏(a+k)⋅b is divisible by 44 (note that the order of the numbers in the pair matters), or reports that, unfortunately for viewers, such a split is impossible.

## Mathematical Circus solution codeforces

Burenka really likes such performances, so she asked her friend Tonya to be a magician, and also gave him the numbers 𝑛n and 𝑘k.

Tonya is a wolf, and as you know, wolves do not perform in the circus, even in a mathematical one. Therefore, he asks you to help him. Let him know if a suitable splitting into pairs is possible, and if possible, then tell it.

The first line contains one integer 𝑡t (1≤𝑡≤1041≤t≤104) — the number of test cases. The following is a description of the input data sets.

The single line of each test case contains two integers 𝑛n and 𝑘k (2≤𝑛≤2⋅1052≤n≤2⋅105, 0≤𝑘≤1090≤k≤109, 𝑛n is even) — the number of integers and the number being added 𝑘k.

It is guaranteed that the sum of 𝑛n over all test cases does not exceed 2⋅1052⋅105.

## Mathematical Circus solution codeforces

For each test case, first output the string “YES” if there is a split into pairs, and “NO” if there is none.

If there is a split, then in the following 𝑛2n2 lines output pairs of the split, in each line print 22 numbers — first the integer 𝑎a, then the integer 𝑏b.

YES 1 2 3 4 NO YES 3 4 7 8 11 12 2 1 6 5 10 9 YES 1 2 3 4 5 6 7 8 9 10 11 12 13 14

## Mathematical Circus solution codeforces

In the first test case, splitting into pairs (1,2)(1,2) and (3,4)(3,4) is suitable, same as splitting into (1,4)(1,4) and (3,2)(3,2).

In the second test case, (1+0)⋅2=1⋅(2+0)=2(1+0)⋅2=1⋅(2+0)=2 is not divisible by 44, so there is no partition.