# 判断长度是否合格
def length_judge(str):
if len(str) > 8:return True
else:
return False
#判断类型是否合格
def type_judge(str):
nu, up, low, oth = 0, 0, 0, 0
for i in str:
if i.isdigit():
nu = 1
elif i.isupper():
up = 1
elif i.islower():
low = 1
else:
oth = 1
if nu + up + low + oth > 2:
return True
else:
return False
#判断是否重复,一次写的,不够精简
def repeat_judge(str):
l = len(str)
for k in range(l-3-1):
j = 3
while k + j < l:
s1 = s[k:k + j]
s2 = s[k + 1:]
if s1 in s2:
return False
else:
j += 1
return True
while True:
try:
s = input().strip()
if length_judge(s) and type_judge(s) and repeat_judge(s):
print('OK')
else:
print('NG')
except:
break