def check(s):
x=[]
a,b,ct,d=0,0,0,0
if len(s) <= 8:
return 0
else:
for i in s:
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"):
ct=1
else:
d=1
if a+b+ct+d < 3:
return 0
else:
for i in range(len(s)-2):
x.append(s[i:i+3])
if len(set(x)) < len(x):
return 0
else:
return 1
while True:
try:
if check(input()):
print("OK")
else:
print("NG")
except:
break