------
## 最终结论
```python
def read_input():
    import sys
    input = sys.stdin.read
    data = input().splitlines()
    
    t = int(data[0])  # number of test cases
    test_cases = []
    
    index = 1
    for _ in range(t):
        n = int(data[index])  # length of the permutation
        p = list(map(int, data[index + 1].split()))  # the permutation itself
        test_cases.append((n, p))
        index += 2
    
    return test_cases

def generate_new_permutation(test_cases):
    new_permutations = []
    
    for n, p in test_cases:
        # Generate a new permutation by swapping the first two elements
        if n > 2:
            new_p = p[:]
            new_p[0], new_p[1] = new_p[1], new_p[0]  # swap first two elements
        else:
            new_p = p[::-1]  # simply reverse if n == 2
        
        new_permutations.append(new_p)
    
    return new_permutations

def verify_fingerprint(test_cases, new_permutations):
    results = []
    
    for (n, p), p_new in zip(test_cases, new_permutations):
        # Calculate fingerprint F(p)
        original_fingerprint = sorted([p[i] + p[i + 1] for i in range(n - 1)])
        
        # Calculate fingerprint F(p')
        new_fingerprint = sorted([p_new[i] + p_new[i + 1] for i in range(n - 1)])
        
        # Verify if fingerprints are the same
        if original_fingerprint == new_fingerprint:
            results.append(p_new)
        else:
            raise ValueError("Fingerprints do not match!")
    
    return results

def output_results(new_permutations):
    for p_new in new_permutations:
        print(' '.join(map(str, p_new)))

if __name__ == "__main__":
    test_cases = read_input()
    new_permutations = generate_new_permutation(test_cases)
    verified_results = verify_fingerprint(test_cases, new_permutations)
    output_results(verified_results)
```