import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            String line = sc.nextLine();
            int length = line.length();
            if (length < 8) {
                System.out.println("NG");
                continue;
            }
            // 1表示存在对应类型的符号,0表示不存在
            int bigLetter = 0;
            int smallLetter = 0;
            int digit = 0;
            int symbol = 0;
            // 去掉非数字字母的字符串
            String replaceStr = line.replaceAll("[^0-9a-zA-Z]", "");
            if (length - replaceStr.length() > 0) {
                symbol = 1;
            }
            for (char c : replaceStr.toCharArray()) {
                if (bigLetter + smallLetter + digit == 3) {
                    break;
                }
                if (Character.isDigit(c)) {
                    digit = 1;
                    continue;
                }
                if (Character.isUpperCase(c)) {
                    bigLetter = 1;
                    continue;
                }
                if (Character.isLowerCase(c)) {
                    smallLetter = 1;
                }
            }
            if (bigLetter + smallLetter + digit + symbol < 3) {
                System.out.println("NG");
                continue;
            }
            if (hasRepeatStr(line, length)) {
                System.out.println("OK");
            } else {
                System.out.println("NG");
            }
        }
        sc.close();
    }

    private static boolean hasRepeatStr(String line, int length) {
        for (int i = 0; i < length - 3; i++) {
            String left = line.substring(i, i + 3);
            String right = line.substring(i + 3);
            if (right.contains(left)) {
                return false;

            }
        }
        return true;
    }
}