from re import fullmatch a = input() b = input() pat = '[0-9]|[1-9]\d|[1-9]\d\d|[1-9]\d{3}|1[01]\d{3}|12[012]\d\d|123[0-3]\d|1234[0-5]' ans = 'NG' if fullmatch(pat, a): if fullmatch(pat, b): ans = 'OK' print(ans)