i,t,p=input,int,print c=lambda x:(x==str(t(x)))*(t(x)<12346) try:p('NOGK'[c(i())*c(i())::2]) except:p('NG')