#include <map>#include <string>#include <iostream>#include <stdlib.h>using namespace std;class MySort{ public: bool operator ()(const string A,const string B) const { if(A.length() < B.length() ) return true; else if( A.length() == B.length() && A < B ) return true; return false; }};map<string,int,MySort> Tree;bool Insert(string str){ string temp = str.substr(1,str.length()-2); int pos = temp.find(','); string key = temp.substr(pos+1); string t = temp.substr(0,pos); int value = atoi( t.c_str() ); if( Tree.find(key)!=Tree.end() ) return false; else { Tree.insert( map<string,int,MySort>::value_type(key,value) ); return true; }}bool HaveRoot(){ for(map<string,int,MySort>::iterator i=Tree.begin();i!=Tree.end();i++) { string str = i->first;if( str.length() == 0 ) continue; if( Tree.find(str.substr(0,str.length()-1)) == Tree.end() ) return false; } return true;}int main(){ string str; bool flag = true; while( cin>>str ) { if(str == "()") { if( flag && HaveRoot() ) { map<string,int,MySort>::iterator i; for( i=Tree.begin();i!=Tree.end();i++ ) { if( i!=Tree.begin() ) cout << ' '; cout << (*i).second ; } cout << endl; } else { cout << "not complete"<<endl; } Tree.clear(); flag = true; } else { if( !Insert(str) ) flag = false; } } return 0;}