#include <bits/stdc++.h>
#define debug(x) cout << #x << ": " << x << endl
#define all(x) begin(x),end(x)
#define rall(x) rbegin(x),rend(x)
#define fi first
#define se second
using namespace std;
using ll = long long;
using pii = pair<int, int>;
void solve() {
int n;
cin >> n;
vector<int> v(n);
vector<bool> has(n+1, 0);
int s = 0;
bool uniq = 1;
for (int i = 0; i < n; ++i) {
cin >> v[i];
s += v[i];
uniq &= !has[v[i]];
has[v[i]] = 1;
}
if (s % n != 0) {
cout << "NO\n";
return;
}
cout << "YES\n";
if (n <= 8) {
sort(all(v));
vector<int> p(n);
iota(all(p), 0);
do {
vector<int> q(n);
for (int i = 0; i < n; ++i) q[i] = (i + v[i]) % n;
sort(all(q));
if (p == q) {
for (int i = 0; i < n; ++i) cout << v[i] << " \n"[i == n-1];
return;
}
} while (next_permutation(all(a)));
} else if (uniq) {
for (int i = 1; i <= n; ++i) cout << i << " \n"[i == n];
} else {
}
}
int main() {
cin.tie(0) -> sync_with_stdio(0);
int t;
cin >> t;
while (t--) solve();
return 0;
}