use std::io::Read; fn judge(s: &mut String) -> bool { let vs: String = s.matches(char::is_numeric).collect(); *s == vs && (s.len() == 1 || s.chars().nth(0).unwrap()!= '0') && s.parse::().unwrap() <= 12345 } fn main() { let mut s = String::new(); let _ = std::io::stdin().read_to_string(&mut s); let result:bool = s.lines() .fold(true, |acc, ss| acc && judge(&mut ss.to_string())); println!("{}", if result { "OK" } else { "NG" }); }