#include <iostream>
#include <vector>
using namespace std;
int t;
int n;
int main() {
	cin >> t;
	while (t--) {
		cin >> n;
		vector<int> a(n);
		for (int i = 0; i < n; i++) cin >> a[i];
		for (int i = 0; i < n; i++) {
			if (i == 0) cout << n - 1 << " ";
			else cout << i - 1 << " ";
		}
		cout << "\n";
	}
}