use std::io::Read; fn judge(s: &mut String) -> bool { let mut cs = s.chars(); cs.all(|c| c.is_digit(10)) && (s.len() == 1 || cs.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" }); }