def check(passwd):
    if len(passwd) <= 8:
        return False
    temp = []
    for i in range(0, len(passwd)):  # 字符串中任意三个连续字符进行切片
        temp.append(passwd[i: i + 3])
    for j in temp:
        if len(j) == 3 and passwd.count(j) > 1:
            return False
    character_type = {}  # 逐个字符判断,属于大小写字母、数字、特殊字符任意一种,加入字典
    for k in passwd:
        if k.isupper():
            character_type['upper'] = k
        elif k.islower():
            character_type['lower'] = k
        elif k.isdigit():
            character_type['digit'] = k
        else:
            character_type['other'] = k
    if len(list(character_type.keys())) < 3:  # 判断字典键的个数,小于3个键不符合要求
        return False
    return True


while True:
    try:
        s = input()
        print('OK' if check(s) else 'NG')
    except:
        break