#include <iostream>
#include <cstdio>
#include <algorithm>
#include <stack>
using namespace std;
char toRight(char ch){
switch(ch){
case '{': return '}';
case '[': return ']';
case '(': return ')';
case '<': return '>';
default :return ' ';
}
}
bool isLeft(char ch){
return ch=='{'||ch=='('||ch=='['||ch=='<';
}
bool isRight(char ch){
return ch=='}'||ch==')'||ch==']'||ch=='>';
}
int main(){
stack<char> stk;
char ch;
while(cin>>ch){
cout<<ch<<endl;
if(isLeft(ch)){
stk.push(ch);
}
else if(isRight(ch)){
if(stk.empty()||toRight(stk.top())!=ch){
cout<<"error"<<endl;
return 0;
}
else
stk.pop();
}
}
if(stk.empty()){
cout<<"ok"<<endl;
}
else{
while(!stk.empty()){
cout<<toRight(stk.top());
stk.pop();
}
}
return 0;
}