import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
while (in.hasNext()) {
String a = in.next();
if(a.length()<9){
System.out.println("NG");
continue;
}
if(!isTypeOk(a)){
System.out.println("NG");
continue;
}
if(isContains(a,0,3)){
System.out.println("NG");
continue;
}
System.out.println("OK");
}
}
private static boolean isTypeOk(String s){
int cnt = 0;
boolean a1 = false;
boolean a2 = false;
boolean a3 = false;
boolean a4 = false;
for(int i = 0; i<s.length(); i++){
if(s.charAt(i)>='0' && s.charAt(i)<='9'){
if(!a1){
cnt++;
a1 = true;
}else{
continue;
}
}else if(s.charAt(i)>='A' && s.charAt(i)<='Z'){
if(!a2){
cnt++;
a2 = true;
}else{
continue;
}
}else if(s.charAt(i)>='a' && s.charAt(i)<='z'){
if(!a3){
cnt++;
a3 = true;
}else{
continue;
}
}else{
if(!a4){
cnt++;
a4 = true;
}
}
}
return cnt>=3?true:false;
}
private static boolean isContains(String s,int left,int right){
if(right>=s.length()){
return false;
}else if(s.substring(right).contains(s.substring(left,right))){
return true;
}else{
return isContains(s,left+1, right+1);
}
}
}