import java.util.*;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNext()) { // 注意 while 处理多个 case
            String cipher = in.nextLine();
            if (cipher.length() <= 8) {
                System.out.print("NG");
            } else {
                int typeC = 0;
                int typeL = 0;
                int typeN = 0;
                int typeO = 0;
                for (int i = 0; i < cipher.length(); i++) {
                    char c = cipher.charAt(i);
                    if (c >= 'A' & c <= 'Z') {
                        typeC=1;
                    } else if (c >= 'a' & c <= 'z') {
                        typeL=1;
                    } else if (c>='0'&c<='9') {
                        typeN=1;
                    }else if(typeO==0){
                        typeO=1;
                    }
                }
                int at=typeC+typeL+typeN+typeO;
                if (at<3) {
                    System.out.print("NG");
                } else {
                    int type=0;
                    for(int x=3;x<cipher.length()-1;x++){
                    for (int i = 0; i < cipher.length() - x; i++) {
                        String a = cipher.substring(i, i + x);
                        String a1=cipher.substring(0,i);
                        String a2=cipher.substring(i+x,cipher.length());
                            if (a1.contains(a)||a2.contains(a)) {
                                type++;
                            }
                        
                    }
                    }
                    if(type==0){
                        System.out.print("OK");
                    }else{
                        System.out.print("NG");
                    }
                }
            }
        }
    }
}