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

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


int checksymbol(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 checkrepeat(char *str)
{
    int i,j,len=strlen(str);
    for (i = 0; i < len - 6; i++)
    {
        for (j = i + 3; j < len - 2; j++)
        {
            if (str[j] == str[i] && str[j+1] == str[i+1] && str[j+2] == str[i+2])
                return 0;
        }
    }
    return 1;
}

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