def f1(x1):
if len(x1) > 8:
return True
return False
def f2(x2):
up = 0
lw = 0
num = 0
ot = 0
for i in x2:
if i.isupper():
up += 1
elif i.islower():
lw += 1
elif i.isdigit():
num += 1
else:
ot += 1
if (up != 0 and lw != 0 and num != 0 and ot == 0) or (up != 0 and lw != 0 and ot != 0 and num == 0) or (up != 0 and num != 0 and ot != 0 and lw == 0) or (lw != 0 and num != 0 and ot != 0 and up == 0) or (lw != 0 and num != 0 and ot != 0 and up != 0):
return True
return False
def f3(x3):
for i in range(len(x3)):
#for j in range(i+1,len(x3)):
if x3[i:i+3] in x3[i+3:]:
return False
return True
while True:
try:
s = input()
if f1(s) and f2(s) and f3(s):
print('OK')
else:
print('NG')
except:
break