#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define INF ((ll)1e9+7ll)
#define fo(i, n) for(ll i = 0; i<((ll)n); i++)
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define deb(x) cout << #x << " = " << (x) << endl
#define deb2(x, y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> pl;
typedef vector<pl> vpl;
vl v;
// vvl memo;
ll n;
// int dp(int pos, int mask = 0){
// if(pos == n) return 1;
// if(memo[pos][mask]) return 0;
// memo[pos][mask] = 1;
// }
ll best;
vl current;
bool check(){
vl res(n, 0);
fo(i, n){
if(res[(i+v[i])%n]){
if(i>best){
current = v;
best = i;
}
return 0;
}
res[(i+v[i])%n] = 1;
}
return 1;
}
int main(){
cin.tie(0)->sync_with_stdio(0);
ll t, tt;
cin >> t;
tt = t;
ll ver = 0;
ll startTime = chrono::steady_clock::now().time_since_epoch().count();
srand(3)
while(t--){
cin >> n;
ver++;
v.assign(n, 0);
// current.assign(n, 0);
fo(i, n){
cin >> v[i];
}
bool fail = 1;
best = -1;
current = v;
// deb(1);
// memo.assign(n, vl((1<<n), 0));
while((chrono::steady_clock::now().time_since_epoch().count()-startTime)/1000 <(900000/tt)*ver){
// deb((chrono::steady_clock::now().time_since_epoch().count()-startTime)/1000);
if(check()){
// deb(t);
fail = 0;
break;
}
v = current;
fo(ii, 3) swap(v[best], v[rand()%n]);
}
// deb(fail);
if(fail) cout << "NO\n";
else{
cout << "YES\n";
fo(i, n) cout << v[i] << " ";
cout << "\n";
}
// if(!dp(0, 0)) cout << "NO\n";
}
return 0;
}