#include #define PI 3.14159265359 using namespace std; int main() { string A, B; cin >> A >> B; bool b = true; if (A.size() < 1 || A.size() > 5) b = false; if (B.size() < 1 || B.size() > 5) b = false; if (b) { int f = 0; for (int i = 0; i < A.size(); i++) { if (A.at(i) < '0' || A.at(i) > '9') { b = false; break; } else { if (A.at(i) != '0') { f = 1; } else { if (!f && A.size() != 1) { b = false; break; } } } } } if (b) { for (int i = 0; i < B.size(); i++) { int f = 0; if (B.at(i) < '0' || B.at(i) > '9') { b = false; break; } else { if (B.at(i) != '0') { f = 1; } else { if (!f && B.size() != 1) { b = false; break; } } } } } if (b) { int n, m; n = stoi(A); m = stoi(B); if (n > 12345 || m > 12345) b = false; } cout << (b ? "OK" : "NG") << endl; }