package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

func main() {
    reader := bufio.NewScanner(os.Stdin)
    for reader.Scan() {
        s := reader.Text()
        if valid(s) {
            fmt.Println("OK")
        } else {
            fmt.Println("NG")
        }
    }
}

func valid(s string) bool {
    // rule 1
    if len(s) <= 8 {
        return false
    }
    // rule 2
    counts := [4]int{0}
    for _, v := range s {
        if v >= 'a' && v <= 'z' {
            counts[0]++
        } else if v>= 'A' && v<= 'Z' {
            counts[1]++
        } else if v >= '0' && v<= '9' {
            counts[2]++
        } else {
            counts[3]++
        }
    }
    diffType := 0
    for _,v := range counts {
        if v != 0 {
            diffType++
        }
    }
    if diffType < 3 {
        return false
    }
    
    // rule 3
    for i :=0; i < len(s)-2; i++ {
        str_count := strings.Count(s, s[i:i+3])
        if str_count > 1 {
            return false
        } 
    }
    return true
}