const list = []
let itm;
while(itm=readline()){
    list.push(itm)
}

for(let itm of list){
    if(!(/.{9,}/.test(itm))){
        console.log('NG');
        continue;
    }
    let sum = 0;
    if(/[a-z]/.test(itm))sum++
    if(/[A-Z]/.test(itm))sum++
    if(/[\d]/.test(itm))sum++
    if(/[^\da-zA-Z]/.test(itm))sum++
    
    if(sum<3){
        console.log('NG');
        continue;
    }
    if(/(.{3,}).*\1/g.test(itm)){
        console.log('NG');
    }else {
        console.log('OK');
    }
    
}