## GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

## [Solution] Permutation Weight (Easy Version) Codeforces Solution | Codeforces Problem Solution 2022

F. Permutation Weight (Easy Version)
time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard output

This is an easy version of the problem. The difference between the easy and hard versions is that in this version, you can output any permutation with the smallest weight.

You are given a permutation p1,p2,…,pn of integers from 1 to n.

Let's define the weight of the permutation q1,q2,…,qn of integers from 1 to n as
|q1−pq2|+|q2−pq3|+…+|qn−1−pqn|+|qn−pq1|

You want your permutation to be as lightweight as possible. Find any permutation q with the smallest possible weight.

Input
The first line of the input contains a single integer t (1≤t≤100)  — the number of test cases. The description of the test cases follows.

The first line of each test case contains a single integer n (2≤n≤200)  — the size of the permutation.

The second line of each test case contains n integers p1,p2,…,pn (1≤pi≤n, all pi are distinct)  — the elements of the permutation.

The sum of n over all test cases doesn't exceed 400.

Output
For each test case, output n integers q1,q2,…,qn (1≤qi≤n, all qi are distinct)  — one of the permutations with the smallest weight.