import sys import re for x in sys.stdin: x = x.strip() if len(x) < 8: print('NG') continue y = 0 if re.search(r'[a-z]+', x) is not None: y += 1 if re.search(r'[A-Z]+', x) is not None: y += 1 if re.search(r'[0-9]+', x) is not None: y += 1 if re.search(r'[^(0-9a-zA-Z)]+', x) is not None: y += 1 if y < 3: # print(y) print('NG') continue # 滑动窗口判断有么有公共元素 def catch_ii(x): # 大于2,那就是最小是3 for win in range(3, len(x)-1): mp = {} for i in range(len(x)-win): item = x[i:i+win] if item in mp: # print(item) return True mp[item] = 1 return False if catch_ii(x): print('NG') else: print('OK')