public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String line = "";
		StringBuilder out = new StringBuilder();
		do {
			line = in.readLine();
			if (line == null || line.length() == 0)
				break;
			int times = Integer.parseInt(line);
			for (int i = 0; i < times; i++) {
				String[] w = in.readLine().trim().split(":");
				int[] hm = new int[2];
				hm[0] = Integer.parseInt(w[0]);
				hm[1] = Integer.parseInt(w[1]);
				do {
					if (hm[1] + 1 == 60) {
						hm[1] = 0;
						if (hm[0] + 1 == 24)
							hm[0] = 0;
						else
							hm[0]++;
					} else
						hm[1]++;
				} while (!date(hm[0], hm[1]));
				out.append(format(hm[0]) + ":" + format(hm[1]) + "\n");
			}
		} while (line != null && line.length() != 0);
		System.out.print(out);
	}