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

int validatePassword(char *input){
    int len = strlen(input);
    if (len < 8){
        printf("NG\n");
        return 0;
    }

    int upper = 0;
    int lower = 0;
    int digit = 0;
    int othersymbol = 0;
    for (int i = 0; i < len; i++){
        if (isupper(input[i])) upper = 1;
        else if (islower(input[i])) lower = 1;
        else if (isdigit(input[i])) digit = 1;
        else othersymbol = 1;
    }
    if (upper + lower + digit + othersymbol < 3) {
        printf("NG\n");
        return 0;
    }

    for (int i = 0; i < len - 4; i++) {
        for (int j = i + 1; j < len - 3; j++) {
            if ((input[i] == input[j]) && (input[i+1] == input[j+1]) && (input[i+2] == input[j+2])) {
                printf("NG\n");
                return 0;
            }
        }
    }
    return 1;
}

int main(){
    char input[100];
    while (scanf("%s", input) != EOF) {
        if(validatePassword(input)) {
            printf("OK\n");
        }
    }
    return 0;
}