#include #define MAX 120 #define MIN 1440 int pocet[MAX][2500]; int rozsah[MAX][2]; char dig[11][8] = /*{ {" - ", " . ", " - ", " - ", " . ", " - ", " - ", " - ", " - ", " - ", " . " }, {"| |", ". |", ". |", ". |", "| |", "| .", "| .", ". |", "| |", "| |", ". ." }, {" . ", " . ", " - ", " - ", " - ", " - ", " - ", " . ", " - ", " - ", " . " }, {"| |", ". |", "| .", ". |", ". |", ". |", "| |", ". |", "| |", ". |", ". ." }, { - ", " . ", " - ", " - ", " . ", " _ ", " _ ", " . ", " - ", " - ", " . " }};*/ {"---.---", "..-..-.", "-.---.-", "-.--.--", ".---.-.", "--.-.--", "--.----", "-.-..-.", "-------", "----.--", "......."}; int ind[28] = {0,1,2,3,0,0,1,1,2,2,3,3,0,1,2,3,0,0,1,1,2,2,3,3,0,1,2,3}; int ind2[28] = {0,0,0,0,1,2,1,2,1,2,1,2,3,3,3,3,4,5,4,5,4,5,4,5,6,6,6,6}; int mozne[4][12]; int sedi(char ziskano[], char cislice[]) { for (int i = 0; i < 7; i++) { if (ziskano[i] == '?') continue; if (ziskano[i] == '.' && cislice[i] != '.') return 0; else if (ziskano[i] != '.' && cislice[i] == '.') return 0; } return 1; } void dekoduj(int i, char in[]) { for (int j = 0; j <= 10; j++) mozne[i][j] = sedi(in,dig[j]); if (i == 0 && mozne[i][10]) mozne[i][0] = 1; } int main() { while (1) { int S; scanf("%d", &S); if (S == 0) return 0; for (int t = 0; t < S; t++) { char in[100]; for (int i = 0; i < 28; i++) { in[i] = getchar(); if (in[i] != '.' && in[i] != '|' && in[i] != '-' && in[i] != '?') i--; } char cisl[4][100]; for (int i = 0; i < 28; i++) cisl[ind[i]][ind2[i]] = in[i]; for (int i = 0; i < 4; i++) cisl[i][7] = '\0'; /*for (int i = 0; i < 4; i++) printf("'%s' ", cisl[i]); printf("\n");*/ for (int i = 0; i < 4; i++) dekoduj(i, cisl[i]); for (int i=0; i < MIN; i++) pocet[t][i] = 0; for (int i=0; i < MIN; i++) { int h = i / 60; int m = i % 60; if (mozne[0][h/10] && mozne[1][h%10] && mozne[2][m / 10] && mozne[3][m%10]) pocet[t][i] = 1; /*printf("t = %d\n", t); for (int q = 0; q < MIN; q++) { int h = q / 60; int m = q % 60; if (pocet[t][q] != 0) printf("%d:%02d, ", h, m); }*/ if (t != 0) { int ok = 0; for (int j = rozsah[t-1][0]; j <= rozsah[t-1][1]; j++) { if (pocet[t-1][(i - j + MIN) % MIN]) ok = 1; } if (!ok) pocet[t][i] = 0; } } if (t != S-1) scanf("%d %d\n", &rozsah[t][0], &rozsah[t][1]); } /*for (int t = 0; t < S; t++) { printf("t = %d: ", t); for (int i = 0; i < MIN; i++) { int h = i / 60; int m = i % 60; if (pocet[t][i] != 0) printf("%d:%02d, ", h, m); } printf("\n"); }*/ for (int t = S-1; t > 0; t--) { for (int i = 0; i < MIN; i++) { if (pocet[t-1][i] == 0) continue; int ok = 0; for (int j = rozsah[t-1][0]; j <= rozsah[t-1][1]; j++) { if (pocet[t][(i + j) % MIN]) ok = 1; } if (!ok) pocet[t-1][i] = 0; } } for (int t = 0; t < S; t++) { int p = 0; int mi = -1; for (int i = 0; i < MIN; i++) { if (pocet[t][i] == 0) continue; p++; if (mi == -1) mi = i; } if (p > 1) printf("ambiguous, %d possibilities\n", p); else { int h = mi / 60; int m = mi % 60; printf("%d:%02d\n", h, m); } } printf("\n"); } return 0; }