//#define _GLIBCXX_DEBUG #include #define rep(i, n) for(int i=0; i; using vs = vector; using vi = vector; using vvi = vector; template using PQ = priority_queue; template using PQG = priority_queue, greater >; const int INF = 0xccccccc; const ll LINF = 0xcccccccccccccccLL; template inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);} template inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);} template istream &operator>>(istream &is, pair &p) { return is >> p.first >> p.second;} template ostream &operator<<(ostream &os, const pair &p) { return os << p.first << ' ' << p.second;} //head bitset<499*498/2> bits; int main() { ios::sync_with_stdio(false); cin.tie(0); int l, d; cin >> l >> d; if(l < 6) { cout << "matsu\n"; return 0; } vi grundy(l+1); for(int i = 6; i <= l; i++) { bits = 0; for(int j = 1; j < i/3; j++) { for(int k = j+1; k < i-j-k; k++) { if(j+d < i-j-k) continue; bits.set(grundy[j]^grundy[k]^grundy[i-j-k]); } } int j = 0; while(bits.test(j)) j++; grundy[i] = j; } if(grundy[l]) cout << "kado\n"; else cout << "matsu\n"; } /* 1 0 2 0 3 0 4 0 5 0 6 1 7 1 8 1 9 2 */