# 设置密码
-
# 密码要求:
-
# 1.长度超过8位
-
# 2.包括大小写字母.数字.其它符号, 以上四种至少三种
-
# 3.不能有相同长度超2的子串重复
-
# 结果:符合则返回OK,不符合则返回NG
import re while True: try: s = input() a = re.findall(r'(.{3,}).*\1', s) # 出现超过2次的字串 b1 = re.findall(r'\d', s) # 数字 b2 = re.findall(r'[A-Z]', s) # 大写字母 b3 = re.findall(r'[a-z]', s) # 小写字母 b4 = re.findall(r'[^0-9A-Za-z]', s) # 非大小写字母和数字,^在中括号”[]”中被使用的话就是表示字符类的否定 # print("[b1, b2, b3, b4]",[b1, b2, b3, b4]) print('OK' if ([b1, b2, b3, b4].count([]) <= 1 and a == [] and len(s) > 8) else 'NG') except: break