#include using namespace std; using Int = long long; template inline void chmin(T1 &a,T2 b){if(a>b) a=b;} template inline void chmax(T1 &a,T2 b){if(a rev; int decode(string s){ assert(rev.count(s)); return rev[s]; } string encode(int x){ string &res=dp[x]; if(!res.empty()) return res; int a=(x/1000)%10; int b=(x/ 100)%10; int c=(x/ 10)%10; int d=(x/ 1)%10; for(int i=0;i=5) res+="D",b-=5; for(int i=0;i=5) res+="L",c-=5; for(int i=0;i=5) res+="V",d-=5; for(int i=0;i>n; int res=0; while(n--){ string s; cin>>s; res+=decode(s); } if(res>3999){ cout<<"ERROR"<