#include <string.h>

int main()
{
    char input[101] = {0};
    int upperCase = 0;
    int lowCase = 0;
    int number = 0;
    int other = 0;
    
    while(gets(input) != NULL)
    {
        upperCase = 0;
        lowCase = 0;
        number = 0;
        other = 0;
        
        if(strlen(input) <= 8)
        {
            printf("NG\n");
            continue;
        }
        /* 判断字符类型 */
        for(int i = 0; i < strlen(input); i++)
        {
           if(input[i] >= 48 && input[i] <= 57)        //数字
           {
               number = 1;
           }else if(input[i] >= 65 && input[i] <= 90)    //大写字母
           {
               upperCase = 1;
           }else if(input[i] >= 97 && input[i] <= 122)    //小写字母
           {
               lowCase = 1;
           }else                                        //其他字符
           {
               other = 1;
           }
            
        }
        if((number + upperCase + lowCase + other) >= 3)
        {
            int len = strlen(input);
            char *str = input;
            int flag = 0;
            
            /* 判断是否有 长度大于2的不含公共元素的子串重复 */
            for(int m=0;m<len-6;m++)
            {
                for(int k=m+3;k<len-3;k++)
                {
                    if(str[k]==str[m]&&str[k+1]==str[m+1]&&str[k+2]==str[m+2])
                    {
                        flag = 1;
                    }
                }
            }
            
            if(!flag)
            {
                 printf("OK\n");
            }
            else
            {
                 printf("NG\n");
            }

        }
        else
        {
            printf("NG\n");
        }
        
    }
    return 0;
}