import java.util.; import java.io.; public class Main{ public static void main(String[] args)throws IOException{ BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String str = null;

    while((str = in.readLine()) != null){
        int flag = 0;
        int len = str.length();
        if(len <= 8){
          flag = 1;
        }
        int flag1 = 0;
        int flag2 = 0;
        int flag3 = 0;
        int flag4 = 0;
        while(len -- > 0){
            if(str.charAt(len) >= '0' && str.charAt(len) <= '9'){
                flag1 = 1;
            }else if(str.charAt(len) >= 'A' && str.charAt(len) <= 'Z'){
                flag2 = 1;
            }else if(str.charAt(len) >= 'a' && str.charAt(len) <= 'z'){
                flag3 = 1;
            }else if(str.charAt(len) == ' ' || str.charAt(len) == '\n'){
                flag = 1;
            }else {
                flag4 = 1;
            }
        }
        int sum = flag1 +flag2+flag3+flag4;
        if(sum < 3) {
           flag =1;
        }
        Set<String> set = new HashSet<>();

        for(int i = 0;i < str.length() - 3; i++){

// System.out.println(str.substring(i,i+3)); if(!set.contains(str.substring(i,i+3))){ set.add(str.substring(i,i+3)); // System.out.println(str.substring(i,i+3)); }else { flag = 1; } } if(flag == 1){ System.out.println("NG"); continue; } System.out.println("OK");

    }
}

}