#include<stdio.h>
#include<string.h>
#include<ctype.h>

int test1(char* str){
    return strlen(str)>9;
}

int test2(char* str){
    int i=0,up=0,low=0,dig=0,other=0;
    while(str[i]){
        
        if(isupper(str[i]))
            up=1;
        else if(islower(str[i]))
            low=1;
        else if(isdigit(str[i]))
            dig=1;
        else if(str[i]!=' '&&str[i]!='\n')
            other=1;
        
        i++;
    }
    return up+low+dig+other>2;
}
int isequal(char*str,int i,int j){
    if(str[i]==str[j]&&str[i+1]==str[j+1]&&str[i+2]==str[j+2]){
        return 1;
    }
    return 0;
}
int test3(char* str){
    int i,j,len=strlen(str);
    for(i=0;i<len-5;i++){
        for(j=i+3;j<len-2;j++){
            if(isequal(str,i,j))return 0;
        }
    }
    return 1;
}

int main(){
    char str[101];
    while(fgets(str,101,stdin)){
        printf("%s",test1(str)&&test2(str)&&test3(str)?"OK\n":"NG\n");
    }
}