public static void main(String[] args) throws Throwable{
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		for (String ln; (ln = in.readLine().trim()) != null; ) {
			String[] arr = ln.split(" +");
			if(arr[0].equals("0")&&arr[1].equals("0")&&arr[2].equals("0"))break;
			char res[] = new char[Math.min(1050, parseInt(arr[2]) + 50)];
			System.arraycopy(arr[0].toCharArray(), 0, res, 0, arr[0].length());
			char temp[] = new char[res.length];
			for (int i = 0; i < parseInt(arr[1]) - 1; i++){
				char ant = res[0];
				int cont = 0;
				int pos = 0;
				for (int j = 0; j < res.length && res[j] != '\0'; j++) {
					if(res[j]==ant)cont++;
					else{
						System.arraycopy((cont + "" + ant).toCharArray(), 0, temp, pos, Math.min((cont + "" + ant).length(), temp.length - pos));
						pos = Math.min(pos + (cont + "" + ant).length(), res.length);
						cont = 1;
						ant = res[j];
					}
				}
				System.arraycopy((cont + "" + ant).toCharArray(), 0, temp, pos, Math.min((cont + "" + ant).length(), temp.length - pos));
				pos = Math.min(pos + (cont + "" + ant).length(), res.length);
				System.arraycopy(temp, 0, res, 0, pos);
			}
			System.out.println(res[parseInt(arr[2]) - 1]);
		}
	}