#include<bits/stdc++.h>
using namespace std;
struct z{
int b=0,r=0,id;
};
bool comp(z a, z b){
return a.r < b.r;
}
bool comp2(z a, z b){
return a.r+a.b > b+r-b.b;
}
int main(){
int n;
cin >> n;
vector<z> pos,neg;
for(int i = 1; i <= n; i++){
string s;
cin >> s;
z c;
c.id = i;
for(int j = 0; j < s.length(); j++){
if(s[j]=='('){
c.b++;
}else{
c.b--;
}
c.r = min(c.r, c.b);
}
c.r = abs(c.r);
if(c.b >= 0){
pos.push_back(c);
}else{
neg.push_back(c);
}
}
sort(pos.begin(), pos.end(), comp);
sort(neg.begin(), neg.end(), comp2);
int b=0;
vector<int> ans;
for(z i:pos){
if(i.r > b){
cout << -1;
return 0;
}
ans.push_back(i.id);
b+=i.b;
}
for(z i:neg){
/*if(i.r > b || b < 0){
cout << -1;
return 0;
}*/
ans.push_back(i.id);
b+=i.b;
}
if(b != 0){
cout << "-1";
return 0;
}
for(int i:ans){
cout << i << " ";
}
}
exit status 1
main.cpp: In function 'bool comp2(z, z)':
main.cpp:11:24: error: 'r' was not declared in this scope
11 | return a.r+a.b > b+r-b.b;
| ^
Exited with error status 1