#include #include #include #include #include #include using namespace std; typedef long long int lint; int main() { string A, B; cin >> A >> B; int a = A.size(); int b = B.size(); int ja = 0; int jb = 0; int AA = 0; int BB = 0; for (int ia = 0; ia < a; ia++) { if (A.at(ia) != '0' && A.at(ia) != '1' && A.at(ia) != '2' && A.at(ia) != '3' && A.at(ia) != '4' && A.at(ia) != '5' && A.at(ia) != '6' && A.at(ia) != '7' && A.at(ia) != '8' && A.at(ia) != '9') { ja++; } } if (!ja) { for (int ja = 0; ja < a; ja++) { AA += (A.at(ja) - '0') * pow(10, (a - ja - 1)); } if (AA && A.at(0) == '0') { ja++; } if (AA > 12345) { ja++; } } for (int ib = 0; ib < b; ib++) { if (B.at(ib) != '0' && B.at(ib) != '1' && B.at(ib) != '2' && B.at(ib) != '3' && B.at(ib) != '4' && B.at(ib) != '5' && B.at(ib) != '6' && B.at(ib) != '7' && B.at(ib) != '8' && B.at(ib) != '9') { jb++; } } if (!jb) { for (int jb = 0; jb < b; jb++) { BB += (B.at(jb) - '0') * pow(10, (b - jb - 1)); } if (BB && B.at(0) == '0') { jb++; } if (BB > 12345) { jb++; } } if (!ja && !jb) { cout << "OK" << endl; } else { cout << "NG" << endl; } }