#include <bits/stdc++.h>
using namespace std;
struct memory {
vector<int> values;
unordered_map<int, memory> mem;
// for root
memory() {
this->mem = unordered_map<int, memory>();
this->values = vector<int>();
}
memory(vector<int>& chairs, vector<int>& values, uint64_t idx) {
if (idx == values.size()) {
this->values = values;
this->mem = unordered_map<int, memory>();
} else {
this->values = vector<int>();
this->mem = unordered_map<int, memory>();
memory n = memory(chairs, values, idx + 1);
this->mem.insert(make_pair(chairs[idx], n));
}
}
pair<int*, uint64_t> find(vector<int>& finding, uint64_t idx) {
if (idx == finding.size()) {
return make_pair(values.data(), values.size());
}
auto f = mem.find(finding[idx]);
if (f == mem.end()) {
return make_pair(nullptr, 0);
} else {
return f->second.find(finding, idx + 1);
}
}
void insert(vector<int>& chairs, vector<int>& values, uint64_t idx) {
auto f = mem.find(values[idx]);
if (f == mem.end()) {
memory n(chairs, values, idx + 1);
this->mem.insert(make_pair(chairs[idx], n));
} else {
f->second.insert(chairs, values, idx + 1);
}
}
};
int main() {
int t;
cin >> t;
memory root_mem = memory();
while (t--) {
int n;
cin >> n;
vector<int> chairs(n);
vector<int> perm(n);
for (int i = 0; i < n; i++) {
cin >> chairs[i];
perm[i] = i;
}
sort(chairs.begin(), chairs.end());
auto f = root_mem.find(chairs, 0);
if (f.first != nullptr) {
if (f.second == 0) {
cout << "NO" << endl;
} else {
cout << "YES" << endl;
for (int* ptr = f.first; ptr < (f.first + f.second); ptr++) {
cout << chairs[*ptr] << " ";
}
cout << endl;
}
continue;
}
bool flag = false;
do {
vector<bool> marker(n, false);
bool f = false;
for (int i = 0; i < n; i++) {
int pos = (i + chairs[perm[i]]) % n;
if (marker[pos]) {
f = true;
break;
} else {
marker[pos] = true;
}
}
if (f) {
continue;
}
flag = true;
break;
} while (next_permutation(perm.begin(), perm.end()));
if (flag) {
cout << "YES" << endl;
root_mem.insert(chairs, perm, 0);
for (int i = 0; i < n; i++) {
cout << chairs[perm[i]] << " ";
}
cout << endl;
} else {
root_mem.insert(chairs, perm, 0);
cout << "NO" << endl;
}
}
}