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.hasNextLine()) { // 注意 while 处理多个 case
String line = in.nextLine();
int count = 0;
if(line.length()<=8){
System.out.println("NG");
continue;
}
if(line.matches(".*[0-9]+.*")){
count++;
}
if(line.matches(".*[a-z]+.*")){
count++;
}
if(line.matches(".*[A-Z]+.*")){
count++;
}
if(line.matches(".*[^\\w\\s]+.*")){
count++;
}
if(count>=3 && !isContainsSubstr(line,0,3)){
System.out.println("OK");
} else {
System.out.println("NG");
}
}
}
public static boolean isContainsSubstr(String str,int l, int r){
if(r>=str.length()){
return false;
}
if(str.substring(r).contains(str.substring(l,r))){
return true;
} else{
return isContainsSubstr(str,l+1,r+1);
}
}
}