#include using namespace std; #define FOR(i,l,r) for(int i = (l);i < (r);i++) #define ALL(x) (x).begin(),(x).end() template bool chmax(T& a,const T& b){return a < b ? (a = b,true) : false;} template bool chmin(T& a,const T& b){return b < a ? (a = b,true) : false;} typedef long long ll; int N,M; string A,B; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); cin >> A >> B; N = A.size(); M = B.size(); bool ok = true; FOR(i,0,N){ if(A [i] < '0' || '9' < A [i]){ ok = false; } } FOR(i,0,M){ if(B [i] < '0' || '9' < B [i]){ ok = false; } } if(A.front() == '0' && N != 1){ ok = false; } if(B.front() == '0' && M != 1){ ok = false; } if(ok && (stoi(A) < 0 || stoi(A) > 12345)){ ok = false; } if(ok && (stoi(B) < 0 || stoi(B) > 12345)){ ok = false; } cout << (ok ? "OK" : "NG") << endl; return 0; }