import sys

class CheckPasswd():
    def __init__(self, passwd):
        self.passwd = passwd
        self.type_counter = 0
        self.child_str = False
    
    def check_type(self):
        type_set = set()
        for i in self.passwd:
            if i.isdigit():
                type_set.add(1)
            elif i.isalpha():
                if i.lower() == i:
                    type_set.add(2)
                else:
                    type_set.add(3)
            else:
                type_set.add(4)
        
        self.type_counter = len(type_set)
    
    def check_child(self):
        for i in self.passwd:
            counter_i = self.passwd.count(i)
            if counter_i >= 2:
                tmp_str = self.passwd
                for j in range(counter_i):
                    point_j = tmp_str.find(i)
                    child_str = tmp_str[point_j: point_j + 3]
                    if tmp_str.count(child_str) >= 2:
                        self.child_str = True
                    else:
                        tmp_str = tmp_str[point_j + 1:]
                        
    def run_check(self):
        if len(self.passwd) <= 8:
            return 'NG'
        
        self.check_type()
        if self.type_counter < 3:
            return 'NG'
        
        self.check_child()
        if self.child_str:
            return 'NG'
        
        return 'OK'

def main():
    while True:
        passwd = sys.stdin.readline().strip()
        if passwd == '':
            break
        
        check_instance = CheckPasswd(passwd)
        print(check_instance.run_check())

main()
            

其中需要注意的是 长度要超过8,也就是要大于8, 子串长度要超过2,也就是子串长度至少是3位,还有输入要用sys.stdin.readline(),如果用input(),可能会出错