import sys


def check(line):
    # 长度超过8位
    if len(line) <= 8:
        return False
    # 包括大小写字母.数字.其它符号,以上四种至少三种
    upper, lower, number, other = 0, 0, 0, 0
    for ch in line:
        if ord("a") <= ord(ch) <= ord("z"):
            lower = 1
        elif ord("A") <= ord(ch) <= ord("Z"):
            upper = 1
        elif ord("0") <= ord(ch) <= ord("9"):
            number = 1
        elif ch != " ":
            other = 1
    if upper + lower + number + other < 3:
        return False
    # 不能有长度大于2的包含公共元素字串重复,其实看长度为3的就够了
    s = set()
    for i in range(len(line) - 3):
        if line[i : i + 3] in s:
            return False
        s.add(line[i : i + 3])
    return True


for line in sys.stdin:
    if check(line.strip()):
        print("OK")
    else:
        print("NG")