# easy题 求赞
import sys

data=sys.stdin.readlines()

def get_len(str1):
    if len(str1)>8:
        return True
    else:
        return False

def get_type(str1):
    flag=[0,0,0,0]
    l=list(str1)
    for item in l:
        if item.isdigit():
            flag[2]=1
            continue
        if item.isupper():
            flag[0]=1
            continue
        if item.islower():
            flag[1]=1
            continue
        elif item!=" " or item!="\n":
            flag[3]=1
    # print(sum(flag))
    return sum(flag)>2
def longzc(str1):
    length = len(str1)
    result=[]
    for i in range(length):
        for j in range(i+1,length+1):
            zc=str1[i:j]
            if zc not in result:
                result.append(str1[i:j])
            elif zc in result and len(zc)>2:
                # print("zc:",zc)
                return False
    return True



for i in range(len(data)):
    data[i]=data[i].strip("\n")

# print(data)


for item in data:
    if get_len(item) and get_type(item) and longzc(item):
        print("OK")
    else:
        print("NG")