#include <cstdio>
#include <iostream>
#include <vector>

using namespace std;

const int MSK[10] = {
	0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x6f
};

int clk[55][4], broke[4], n;
vector<int> ans;

void print_tm(int tm){
	int h = tm / 60, m = tm % 60;
	printf("%02d:%02d", h, m);
}

bool gao2(int tm, int id){
	int should[4];
	int h = tm / 60, m = tm % 60;
	should[0] = h / 10; should[1] = h % 10;
	should[2] = m / 10; should[3] = m % 10;
	for(int i = 0; i < 4; i++) should[i] = MSK[should[i]];
	for(int i = 0; i < 4; i++){
		if(broke[i] & clk[id][i]) return false;
		int brk_now = should[i] ^ clk[id][i];
		for(int j = 0; j <= id; j++)
			if(brk_now & clk[j][i]) return false;
		broke[i] |= brk_now;
	}
	return true;
}

bool gao(int tm){
	for(int i = 0; i < 4; i++) broke[i] = 0;
	for(int i = 0; i < n; i++){
		if(gao2((tm + i)%(24*60), i) == false) return false;
	}
	return true;
}

int main(){
	while(1 == scanf("%d", &n)){
		for(int i = 0; i < n; i++){
			int h, m;
			scanf("%d:%d", &h, &m);
			clk[i][0] = h/10; clk[i][1] = h%10;
			clk[i][2] = m/10; clk[i][3] = m%10;
			for(int j = 0; j < 4; j++){
				clk[i][j] = MSK[clk[i][j]];
			}
		}
		ans.clear();
		for(int i = 0; i < 24 * 60; i++){
			if(gao(i)) ans.push_back(i);
		}
		if(ans.size() == 0){
			puts("none");
			continue;
		}
		for(int i = 0; i < ans.size(); i++){
			if(i != 0) printf(" ");
			print_tm(ans[i]);
		}
		puts("");
	}
	return 0;
}
