import java.util.Scanner;
import java.util.TreeSet;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
while (scanner.hasNextLine()) {
String nextLine = scanner.nextLine();
if (!checkRuleOne(nextLine)) {
System.out.println("NG");
} else if (!checkRuleTwo(nextLine)) {
System.out.println("NG");
} else if (!checkRuleThree(nextLine, 0, 3)) {
System.out.println("NG");
} else {
System.out.println("OK");
}
}
}
public static boolean checkRuleOne(String nextLine) {
if (nextLine.length() <= 8) {
return false;
}
return true;
}
public static boolean checkRuleTwo(String nextLine) {
TreeSet<String> treeSet = new TreeSet<>();
char[] toCharArray = nextLine.toCharArray();
for (char aChar : toCharArray) {
if (Character.isDigit(aChar)) {
treeSet.add("number");
} else if (Character.isUpperCase(aChar)) {
treeSet.add("upper");
} else if (Character.isLowerCase(aChar)) {
treeSet.add("lower");
} else {
treeSet.add("other");
}
}
return treeSet.size() >= 3;
}
public static boolean checkRuleThree(String nextLine, int beginIndex,
int length) {
int size = nextLine.length() / 2;
size = nextLine.length() % 2 == 0 ? size : size + 1;
if (length >= size) {
return true;
}
for (int i = beginIndex; i < nextLine.length() - length; i++) {
String endSub = nextLine.substring(i + length);
String beginSub = nextLine.substring(i, length + i);
if (endSub.contains(beginSub)) {
return false;
}
}
return checkRuleThree(nextLine, 0, length + 1);
}
}