def check_pwd(pwd):
    if len(pwd)<8:
        return 'NG'
    flag_upper=0
    flag_lower=0
    flag_number=0
    flag_other=0
    for i in pwd:
        if ord(i)>=65 and ord(i)<=90:
            flag_upper=1
            continue
        if ord(i)>=97 and ord(i)<=122:
            flag_lower=1
            continue
        if ord(i)>=48 and ord(i)<=57:
            flag_number=1
            continue 
        if not all((i.isalpha() , i.isdigit())):
            flag_other=1
            continue
    if flag_lower+flag_upper+flag_number+flag_other<3:
        return 'NG'
    for i in range(len(pwd)-3):
        if pwd.count(pwd[i:i+3])>1:
            return 'NG'
    return 'OK'
import sys
for line in sys.stdin:
    pwd=line.strip()
    res=check_pwd(pwd)
    print(res)