codeforces solution find the permutation
codeforces solution find the permutation
h>
while (b > 0) {
if (b & 1) {
res = res * a;
a = a * a;
b >>= 1;
return res;
ll res = 1;
if (exp % 2 == 1) {
exp /= 2;
return res;
void precompute(int n) {
factorial.resize(n + 1);
inverse.resize(n + 1);
factorial[0] = 1;
for (int i = 1; i <= n; i++) {
ll nCr(int n, int r) {
if (r > n || r < 0) {
return 0;
void solve(){
int n;
cin>>n;
vector<string> g(n);
cin>>g[i];
vector<int> perm(n);
if (g[i][j] == '1') {
++pairs[i].second;
sort(pairs.begin(), pairs.end(),
});
perm[i] = pairs[i].first;
cout<<endl;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t;
cin >> t;
while (t--) {
solve();
return 0;