import java.util.*;
public class Main{
    public static Boolean checkPassword(String str){
        // 验证长度
        if(str.length() <= 8) return false;
        // 验证包括的字符种类
        int low = 0, up = 0, num = 0, other = 0;
        for(int i = 0; i < str.length(); i++){
            char tmp = str.charAt(i);
            if(tmp >= 'a' && tmp <= 'z'){
                low = 1;
            }
            else if(tmp >= 'A' && tmp <= 'Z'){
                up = 1;
            }
            else if(tmp >= '0' && tmp <= '9'){
                num = 1;
            }
            else{
                other = 1;
            }
        }
        if(low+up+num+other < 3) return false;
        // 验证是否有长度大于2的子串重复
        //  这个判断子串的方式是,将一句话截成两段,只要后面一段不包含前面那段就可以了
        for(int i = 0; i < str.length(); i++){
            for(int j = i+3; j < str.length(); j++){
                String tmp = str.substring(i, j);
                if(str.substring(j).contains(tmp)){
                    return false;
                }
            }
        }
        // 以上false都没有出现,返回true
        return true;
    }
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(sc.hasNextLine()){
            String str = sc.nextLine();
            if(checkPassword(str)){
                System.out.println("OK");
            }
            else{
                System.out.println("NG");
            }
        }
    }
}