#include<iostream>

using namespace std;

bool f(string s){

   int n=0;
   while(n<=12345){

      if(to_string(n)==s) return true;
      n++;
   }

   return false;
}

int main(){

   string A, B;
   cin>> A>> B;

   cout<< (f(A)&&f(B)? "OK": "NG")<< endl;

   return 0;
}