package chelper; import io.InputReader; import io.OutputWriter; import misc.SimpleSavingChelperSolution; public class TaskA extends SimpleSavingChelperSolution { public void solve(int testNumber, InputReader in, OutputWriter out) { wrapSolve(testNumber, in, out); } int getType(char c) { if ('A' <= c && c <= 'Z') { return 0; } if ('a' <= c && c <= 'z') { return 1; } if ('0' <= c && c <= '9') { return 2; } throw new RuntimeException(); } char getChar(int type) { if (type == 0) { return 'A'; } if (type == 1) { return 'a'; } if (type == 2) { return '0'; } throw new RuntimeException(); } boolean isOk(int[] a) { int[] counts = new int[3]; for (int i : a) { counts[i]++; } return counts[0] > 0 && counts[1] > 0 && counts[2] > 0; } @Override public void solve(int testNumber) { String s = in.nextString(); int n = s.length(); char[] chars = s.toCharArray(); int[] types = new int[n]; int[] counts = new int[3]; for (int i = 0; i < n; i++) { types[i] = getType(chars[i]); counts[types[i]]++; } if (isOk(types)) { out.println(s); return; } int[] t = new int[n]; for (int i = 0; i < n; i++) { for (int j = 0; j < 3; j++) { for (int k = 0; k < n; k++) { t[k] = types[k]; } t[i] = j; if (isOk(t)) { chars[i] = getChar(j); out.println(new String(chars)); return; } } } for (int i = 0; i < n - 1; i++) { for (int j1 = 0; j1 < 3; j1++) { for (int j2 = j1 + 1; j2 < 3; j2++) { for (int k = 0; k < n; k++) { t[k] = types[k]; } t[i] = j1; t[i + 1] = j2; if (isOk(t)) { chars[i] = getChar(j1); chars[i + 1] = getChar(j2); out.println(new String(chars)); return; } } } } } }