import sys for line in sys.stdin: password = line length = len(password) if length <= 8: print('NG') continue else: typ = [False, False, False, False] abc = 'abcdefghijklmnopqrstuvwxyz' repeat_ = False for i in range(length-2): if password[i]+password[i+1]+password[i+2] in password[i+3:]: repeat_ = True break if password[i] in abc: typ[0] = True elif password[i] in abc.upper(): typ[1] = True elif password[i] in '0123456789': typ[2] = True else: typ[3] = True if repeat_: print('NG') elif sum(typ)<3 : print('NG') else : print('OK')