아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Matching Numbers

시간 제한1초메모리 제한1024 MB

요약
1부터 2n까지의 정수를 짝지어 n개의 합이 서로 다른 연속된 값이 되도록 만들고, 불가능하면 No를 출력한다.
난이도

보통10점 중 4점

유형
수학, 그리디, 구현, 완전 탐색
정답자
아직 제출이 없습니다

문제

You are given an integer nn. Pair the integers 11 to 2n2n (i.e. each integer should be in exactly one pair) so that each sum of matched pairs is consecutive and distinct.

Formally, let (a_i,b_i)(a\_i, b\_i) be the pairs that you matched. a_1,b_1,a_2,b_2,…,a_n,b_n\\{a\_1, b\_1, a\_2, b\_2, \ldots, a\_n, b\_n\\} should be a permutation of 1,2,…,2n\\{1, 2, \ldots, 2n\\}. Let the sorted list of a_1+b_1,a_2+b_2,…,a_n+b_n\\{a\_1+b\_1, a\_2+b\_2, \ldots, a\_n+b\_n\\} be s_1<s_2<…<s_ns\_1 < s\_2 < \ldots < s\_n. We must have s_i+1−s_i=1s\_{i+1}-s\_i = 1 for 1≤i≤n−11 \le i \le n - 1.

입력

Each test contains multiple test cases. The first line contains the number of test cases tt (1≤t≤5001 \le t \le 500). The description of the test cases follows.

For each test case, a single integer nn (1≤n≤1051 \leq n \leq 10^5) is given.

It is guaranteed that the sum of nn over all test cases doesn't exceed 10510^5.

출력

For each test case, if it is impossible to make such a pairing, print "No".

Otherwise, print "Yes" followed by nn lines.

At each line, print two integers that are paired.

You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.

If there are multiple solutions, print any.

예제1

  1. 예제 1

    입력
    4
    1
    2
    3
    4
    
    예상 출력
    Yes
    1 2
    No
    Yes
    1 6
    3 5
    4 2
    No