while True:
try:
s = input()
if len(s) > 8:
zmd = 0
zmx = 0
sz = 0
ts = 0
for i in s:
if i.isupper():
zmd = 1
elif i.islower():
zmx = 1
elif i.isdigit():
sz = 1
else:
ts = 1
if (zmd + zmx + sz + ts) >= 3:
# 判断子串是否有重复,否OK 是 NG
n = len(s)
cnt_all = []
for i in range(0, n - 2):
for j in range(i + 3, n):
cnt_all.append(s.count(s[i:j]))
max_n = max(cnt_all)
if max_n >= 2:
print('NG')
else:
print('OK')
else:
print('NG')
else:
print('NG')
except:
break