#define _CRT_SECURE_NO_WARNINGS #include #include #include #include #include using namespace std; //순열 사이클 int arr[1001]; bool check[1001]; void cycledfs(int node) { check[node] = true; int next = arr[node]; if (check[next] == false) { cycledfs(next); } else return; } int main() { int t; cin >> t; while (t--) { int n; cin >> n; for (int i = 1; i