#include using namespace std; #define REP(i,a,n) for(int i=(a); i<(int)(n); i++) #define rep(i,n) REP(i,0,n) #define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it) #define ALLOF(c) (c).begin(), (c).end() typedef long long ll; typedef unsigned long long ull; int roma2arab(const string& str){ int ret = 0; int i = 0; while(i0){ if(x>=1000){ ret += "M"; x -= 1000; } else if(x>=900){ ret += "CM"; x -= 900; } else if(x>=500){ ret += "D"; x -= 500; } else if(x>=400){ ret += "CD"; x -= 400; } else if(x>=100){ ret += "C"; x -= 100; } else if(x>=90){ ret += "XC"; x -= 90; } else if(x>=50){ ret += "L"; x -= 50; } else if(x>=40){ ret += "XL"; x -= 40; } else if(x>=10){ ret += "X"; x -= 10; } else if(x>=9){ ret += "IX"; x -= 9; } else if(x>=5){ ret += "V"; x -= 5; } else if(x>=4){ ret += "IV"; x -= 4; } else if(x>=1){ ret += "I"; x -= 1; } } return ret; } int main(){ int N; cin >> N; int sum = 0; rep(i,N){ string str; cin >> str; sum += roma2arab(str); } if(sum >= 4000){ cout << "ERROR" << endl; }else{ cout << arab2roma(sum) << endl; } return 0; }