import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNextLine()) {
            String str = sc.nextLine();
            if (str.length() <= 8) {
                System.out.println("NG");
                continue;
            }
            char A = 'A', a = 'a', num = '0', other = 'O';
            Set<Character> set = new HashSet<>();
            for (int i = 0; i < str.length(); i++) {
                if (str.charAt(i) >= 'A' && str.charAt(i) <= 'Z') {
                    set.add('A');
                } else if (str.charAt(i) >= 'a' && str.charAt(i) <= 'z') {
                    set.add('a');
                } else if (str.charAt(i) >= '0' && str.charAt(i) <= '9') {
                    set.add('0');
                } else {
                    set.add('O');
                }
            }
            if (set.size() < 3) {
                System.out.println("NG");
                continue;
            }
            List<String> list = new ArrayList<>();
            Set<String> set1 = new HashSet<>();
            for (int i = 0; i < str.length() - 2; i++) {
                for (int j = i + 2; j < str.length(); j++) {
                    if (j == str.length() - 1){
                        list.add(str.substring(i));
                        set1.add(str.substring(i));
                    }else{
                        list.add(str.substring(i,j+1));
                        set1.add(str.substring(i,j+1));
                    }
                }
            }
            if(list.size() == set1.size()){
                System.out.println("OK");
            }else{
                System.out.println("NG");
            }
        }
    }
}