ptn = /(^0$)|(^[1-9][0-9]*$)/ puts (ptn.match(gets) and ptn.match(gets)) ? 'OK' : 'NG'