import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
StringBuffer sb = new StringBuffer("");
String m = "";
int cases = Integer.parseInt(br.readLine());
for (int i = 0; i < cases; i++) {
m = br.readLine();
char temp = ' ';
boolean flag = true;
StringBuilder num = new StringBuilder();
int n;
sb.append("Case ").append((i + 1)).append(": ");
for (int j = 0; j < m.length(); j++) {
if (m.charAt(j) >= 'A' && m.charAt(j) <= 'Z') {
if (j > 0) {
n = Integer.valueOf(num.toString());
num = new StringBuilder();
for (int z = 0; z < n; z++) {
sb.append(temp);
}
}
temp = m.charAt(j);
flag = false;
} else {
num.append(m.charAt(j));
}
}
n = Integer.valueOf(num.toString());
for (int z = 0; z < n; z++) {
sb.append(temp);
}
sb.append("\n");
}
System.out.print(sb);
}
}
No comments:
Post a Comment