import java.io.*; import java.util.*; public class Main_yukicoder518 { private static Scanner sc; private static Printer pr; private static void solve() { int n = sc.nextInt(); String[] r = new String[n]; int ret = 0; for (int i = 0; i < n; i++) { r[i] = sc.next(); ret += conv(r[i]); } if (ret > 3999) { pr.println("ERROR"); } else { pr.println(rconv(ret)); // pr.println(ret); } } private static String[] xxx = {"MMM", "MM", "M", "CM", "DCCC", "DCC", "DC", "D", "CD", "CCC", "CC", "C", "XC", "LXXX", "LXX", "LX", "L", "XL", "XXX", "XX", "X", "IX", "VIII", "VII", "VI", "V", "IV", "III", "II", "I"}; private static int[] xxi = {3000, 2000, 1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1}; private static int conv(String r) { int ret = 0; while (r.length() > 0) { for (int i = 0, size = xxx.length; i < size; i++) { if (r.startsWith(xxx[i])) { ret += xxi[i]; r = r.substring(xxx[i].length()); break; } } } return ret; } private static String rconv(int r) { StringBuilder ret = new StringBuilder(); while (r > 0) { for (int i = 0, size = xxi.length; i < size; i++) { if (r >= xxi[i]) { ret.append(xxx[i]); r -= xxi[i]; break; } } } return ret.toString(); } // --------------------------------------------------- public static void main(String[] args) { sc = new Scanner(System.in); pr = new Printer(System.out); solve(); pr.close(); sc.close(); } private static class Printer extends PrintWriter { Printer(PrintStream out) { super(out); } } }