#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define FOR(i,n) for(int i=0; i < (n); i++) #define FORD(i,n) for(int i=(n)-1; i >= 0; i--) #define FORTO(i,a,b) for (int i = (a); i <= (b); ++i) #define DEBUG(x) cout << '>' << #x << ' ' << x << endl; #define SIZE(x) int(x.size()) typedef pair PII; typedef long long ll; char S[1500]; char D[10][7][6] = { { "+---+", "| |", "| |", "+ +", "| |", "| |", "+---+" }, { " +", " |", " |", " +", " |", " |", " +" }, { "+---+", " |", " |", "+---+", "| ", "| ", "+---+" }, { "+---+", " |", " |", "+---+", " |", " |", "+---+" }, { "+ +", "| |", "| |", "+---+", " |", " |", " +" }, { "+---+", "| ", "| ", "+---+", " |", " |", "+---+" }, { "+---+", "| ", "| ", "+---+", "| |", "| |", "+---+" }, { "+---+", " |", " |", " +", " |", " |", " +" }, { "+---+", "| |", "| |", "+---+", "| |", "| |", "+---+" }, { "+---+", "| |", "| |", "+---+", " |", " |", "+---+" } }; char R[7][30] = { " ", " ", " o ", " ", " o ", " ", " " }; char I[7][30]; void print(int pos, int dig) { FOR(y,7) FOR(x,5) R[y][pos+x] = D[dig][y][x]; } char buff[5]; int main() { while (strcmp(gets(I[0]),"end")) { FORTO(i,1,6) gets(I[i]); gets(buff); gets(buff); int count = 0, A, B, C, D; FOR(h,24) FOR(m,60) { int a=h/10, b=h%10; int c=m/10, d=m%10; print(0,a); print(7,b); print(17,c); print(24,d); bool ok = true; FOR(y,7) FOR(x,29) { if (I[y][x] != R[y][x] && I[y][x] != '.') { ok = false; goto next; } } if (ok) { if (!count) A = a, B = b, C = c, D = d; count++; if (count > 1) goto next2; } next:; } next2:; if (count > 1) { printf("ambiguous\n"); } else { printf("%d%d:%d%d\n", A, B, C, D); } } printf("end\n"); return 0; }