#include using namespace std; ///--------------------------------------------------- const int BUFFER_SIZE = (1 << 16); char buffer[BUFFER_SIZE]; int position = BUFFER_SIZE; inline char getChar() { if ( position == BUFFER_SIZE ) { position = 0; fread(buffer, BUFFER_SIZE, 1, stdin); } return buffer[position++]; } inline int getInt() { register int a = 0; char ch; int sgn = 1; do { ch = getChar(); } while ( !isdigit(ch) && ch != '-' ); if ( ch == '-' ) { sgn = -1; ch = getChar(); } do { a = (a << 3) + (a << 1) + ch - '0'; ch = getChar(); } while ( isdigit(ch) ); return a * sgn; } ///--------------------------------------------------- bool checkFirst(const string &s) { if (s == "B") return true; if (s.size() != 2) return false; for (char c : s) if (!('A' <= c && c <= 'Z')) return false; return true; } bool checkSecond(const string &a, const string &b) { if (a == "B") { if (b.size() != 2 && b.size() != 3) return false; for (char c : b) if (isdigit(c) == false) return false; return true; } else { if (b.size() != 2) return false; for (char c : b) if (isdigit(c) == false) return false; return true; } } bool checkThird(const string &s) { if (s.size() != 3) return false; for (char c : s) if (!('A' <= c && c <= 'Z')) return false; return true; } int main() { ///ifstream cin("data.in"); int N; cin >> N; cin.get(); while (N--) { vector v; string s, word; getline(cin, s); s.push_back(' '); for (char c : s) { if (isspace(c)) { v.push_back(word); word.clear(); } else word.push_back(c); } if (v.size() != 3) { cout << "Incorrect!\n"; } else { bool valid = checkFirst(v[0]); valid &= checkSecond(v[0], v[1]); valid &= checkThird(v[2]); if (valid) cout << "Correct!\n"; else cout << "Incorrect!\n"; } } return 0; }