#[allow(unused_imports)] use std::cmp::*; #[allow(unused_imports)] use std::collections::*; fn read() -> T { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); s.trim().parse().ok().unwrap() } fn read_vec() -> Vec { read::() .split_whitespace() .map(|e| e.parse().ok().unwrap()) .collect() } fn grundy(l: usize, d: usize, mem: &mut Vec) -> i32 { if mem[l] != -1 { return mem[l]; } if l <= 2 { mem[l] = 0; return 0; } let mut s = HashSet::new(); for l1 in 1..l - 2 { for l2 in l1 + 1..l - 2 { if l1 + l2 >= l - 1 { continue; } let l3 = l - l1 - l2; if l3 == l1 || l3 == l2 { continue; } let max_l = max(l2, l3); let min_l = min(l1, l3); if max_l - min_l > d { continue; } s.insert(grundy(l1, d, mem) ^ grundy(l2, d, mem) ^ grundy(l3, d, mem)); } } let mut res = 0; while s.contains(&res) { res += 1; } mem[l] = res; res } fn main() { let v: Vec = read_vec(); let (l, d) = (v[0], v[1]); let mut mem = vec![-1; l + 1]; if grundy(l, d, &mut mem) == 0 { println!("matsu"); } else { println!("kado"); } }