import java.util.*;
import java.util.regex.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
while(sc.hasNext()){
String str = sc.nextLine();
//判断长度是否超过8位
if(str.length()<=8){
System.out.println("NG");
continue;
}
//判断.包括大小写字母.数字.其它符号,以上四种至少三种
if(!checkPassWord(str)){
System.out.println("NG");
continue;
}
//判断是否有重复元素
if(!checkChongFu(str)){
System.out.println("NG");
continue;
}
System.out.println("OK");
}
}
//.包括大小写字母.数字.其它符号,以上四种至少三种
private static boolean checkPassWord(String str){
int count = 0;
Pattern lowerCase = Pattern.compile("[a-z]");
if(lowerCase.matcher(str).find()){
count++;
}
Pattern upperCase = Pattern.compile("[A-Z]");
if(upperCase.matcher(str).find()){
count++;
}
Pattern number = Pattern.compile("[0-9]");
if(number.matcher(str).find()){
count++;
}
Pattern other = Pattern.compile("[^a-zA-Z0-9]");
if(other.matcher(str).find()){
count++;
}
if(count<3){
return false;
}
return true;
}
private static boolean checkChongFu(String str){
for(int i=0,j=i+3;j<=str.length();i++,j++){
if(str.substring(j).contains(str.substring(i,j))){
return false;
}
}
return true;
}
}