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()){
            String pwd = in.nextLine();
            printResult(pwd);
        }
    } 
    
    public static void printResult(String pwd){
        if (pwd.length() <= 8){
            System.out.println("NG");
            return;
        }

        char hasUpWord = 0, hasLowWord = 0, hasNum = 0, hasChar = 0;
        Map<Character,List<Integer>> memeryMap = new HashMap<Character,List<Integer>>();
        char[] chars = pwd.toCharArray();
        for (int i = 0; i < chars.length; i++){
            char c = chars[i];
            if(c >= 'A' && c <= 'Z'){
                hasUpWord = 1;
            }else
            if(c >= 'a' && c <= 'z'){
                hasLowWord = 1;
            }else
            if(c >= '0' && c <= '9'){
                hasNum = 1;
            }else {
                hasChar = 1;
            }
            // 记忆集:记录每个字符的位置
            List<Integer> indexs = memeryMap.get(c);
            if (indexs == null){
                indexs = findStartIndex(chars, i+1, c);
                if (indexs == null){
                    continue;
                }
                memeryMap.put(c, indexs);
            }
            // 查找重复的字符串
            boolean repeat = findRepeatChars(chars, i, indexs);
            if (repeat){
                System.out.println("NG");
                return;
            }
        }
        if (hasUpWord+hasLowWord+hasNum+hasChar >= 3){
            System.out.println("OK");
        }else {
            System.out.println("NG");
        }
    }
    
    private static boolean findRepeatChars(char[] chars, int start, List<Integer> repeatStart){
        int n=0,m = 0;
        for (Integer j : repeatStart){
            for (int i = start; i < chars.length; i++){
                if (j <= i){
                    break;
                }
                if (j+n < chars.length && chars[i] == chars[j+n]){
                    n++;
                    m++;
                }else if(m > 2){
                    return true;
                }else{
                    m = 0;
                    n = 0;
                    break;
                }
            }
        }
        return false;
    }
    
    private static List<Integer> findStartIndex(char[] chars, int start, char target){
        List<Integer> result = null;
        for (int i = start; i < chars.length; i++){
            if (chars[i] == target){
                if (result == null){
                  result = new ArrayList<Integer>();
                }
                result.add(i);
            }
        }
        return result;
    }
}