# 20240911 def f1(x): # 包括大小写字母.数字.其它符号,以上四种至少三种 a, b, c, other = 0, 0, 0, 0 for i in x: if ord('A') <= ord(i) <= ord('Z'): a = 1 elif ord('a') <= ord(i) <= ord('z'): b = 1 elif ord('0') <= ord(i) <= ord('9'): c = 1 else: other = 1 if a + b + c + other < 3: return False return True def f2(x): # 不能有长度大于2的包含公共元素的子串重复 (注:其他符号不含空格或换行) for i in range(len(x)): if x[i : i + 3] in x[i+3:]: return False return True while True: try: s = input() # print(f1(s), f2(s)) if len(s) > 8 and f1(s) and f2(s): print("OK") else: print("NG") except: break