結果

問題 No.361 門松ゲーム2
ユーザー anta
提出日時 2016-04-20 18:34:07
言語 C++11
(gcc 4.8.5)
結果
AC  
実行時間 4 ms
コード長 27,438 Byte
コンパイル時間 127 ms
使用メモリ 1,304 KB
最終ジャッジ日時 2019-11-19 23:47:47

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
0_1.txt AC 3 ms
1,296 KB
0_2.txt AC 3 ms
1,300 KB
0_3.txt AC 3 ms
1,296 KB
1_1.txt AC 4 ms
1,296 KB
1_2.txt AC 2 ms
1,296 KB
1_3.txt AC 3 ms
1,300 KB
1_4.txt AC 3 ms
1,296 KB
1_5.txt AC 3 ms
1,292 KB
2_1.txt AC 2 ms
1,300 KB
2_2.txt AC 3 ms
1,300 KB
2_3.txt AC 3 ms
1,296 KB
2_4.txt AC 3 ms
1,304 KB
2_5.txt AC 3 ms
1,304 KB
2_6.txt AC 3 ms
1,304 KB
3_1.txt AC 3 ms
1,300 KB
3_2.txt AC 3 ms
1,304 KB
3_3.txt AC 2 ms
1,300 KB
3_4.txt AC 3 ms
1,300 KB
3_5.txt AC 3 ms
1,300 KB
3_6.txt AC 2 ms
1,304 KB
3_7.txt AC 3 ms
1,300 KB
3_8.txt AC 2 ms
1,304 KB
4_1.txt AC 3 ms
1,300 KB
4_2.txt AC 3 ms
1,300 KB
4_3.txt AC 3 ms
1,296 KB
4_4.txt AC 4 ms
1,300 KB
4_5.txt AC 3 ms
1,296 KB
4_6.txt AC 3 ms
1,304 KB
テストケース一括ダウンロード

ソースコード

diff #
#include <cstdio>
using namespace std;

int main() {
	const char *table[206] = {
		"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
		"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
		"aecbaaaaaaecjecjecjecjecjecjecbaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaecjecjecjecjecjecjecjecjecjecjecjec",
		"ampbobaamdmdmdmdmpppppppbobobobobobobobobobobobobobaaaaaaaaaaaaaaaaaaaamdmdmdmdmdmdmdmdmdmdmdmdmdmdmdmdmdmdmdmdmdmdmdmdmdmdmdm",
		"ampbphaabhombbaembpppphpofadgmnlhhmibeponppppnlhbmibompbaaaaaaaaaamppppppppphhphmjdhomjdheiabceiabcemjdhomjdhmpnnppppppppphaaa",
		"ampjpbbappppiemhpppppphophaaaaaaaiopiopgpphpbhepphaaaaaaaaaaaaaaaamppppaaaampdpppppppppppppppppppppppampampampampamhfjekkpaaaa",
		"ampnpjhbppfmpnmphhhhhmfnbobapfnbhbbhdehphopgjpphpphhhemfmfmfembbppppkppppmdpbpampphpboihjpohohonbnampppppppphpppnnegphafapohpp",
		"ampnpnpnpbmpmbmppbmpephmhmphmpnpppppponpnpbampbampbampbmpbpfodifnnmnpnnbmnkhmpbbpmppppppppppphiphahapbmdmpmlmjkgppppppppphapbp",
		"ampnpppphiphmppaaaaaaampppdpappaphohpppphpppdipppppppppppppppppppppppphaaaaaophmholpphgiphpppphjhonpdpnoifphhmpbabaaaampppphdh",
		"ampnpppphiphmpaaaaaaaapppplpbapohhphjpplppppppppppppppppppppppppppppphaaaaacojpokppppppppphippopppfohhhphkplndmppjoopppppppaaa",
		"ampnpppphiphmdhaaophampppplpfipkhpkhjppppppppppppppppppppppppppppppphaaaaaipdodopphppppplpppnkpplplhjonppppphoppppdphaaaaaaaaa",
		"ampnpppphnphodplppphpppfopnplpheldppppnhpppjpoppppidaabpbhophphdidpapnopjppipbohlpcofopppdopnppppppppppppppppemppppppppppppppp",
		"ampnppppppphpmppmpddaaaamdaaamppppppppppppophphhjhoppppppppppppppppppppppppppppppppppppppppppdaaaaaaaaaaaaaaaaaaaaaaophplppppp",
		"ampnppppppphppphopbhaaaapbihahpnnlpnmpppdopppmpponpappppppppppppppppppppppppppppppppppppppppppphppphopdppjppopppomhmppppdpphnp",
		"ampnpppppppppppbpdahaaaidaibaiaaiopaamoppppppphgpppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppplippphaa",
		"ampnpppppppppppbpdahaaeidaibaiaaaihaaailpppppppgpppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppplipp",
		"ampnppppppppppphphahaagidaaaaaaaaigpljpppppppnppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppahaaafmp",
		"ampnppppppppppphppbhaahidaaaaaaiaiopplppppppppppopjppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppphpppphpp",
		"ampnppppppppppphppbhaghidaaaaaamooppphpnppppppnhofipppppppppppppppppppppppppppppppppppppppppppppppppppphoppppdnfhmppppppppppmf",
		"ampnpppppppppppbppbbapaihaaaaaonppppppppppppppohppphppppppppppppppppppppppppppppppppppppppppppppppphnpiaaaaaaaaddpnphopjnppinl",
		"ampnpppppppppppbppnbaaaaaaaaaaonpppppppppppppppblhpplpppppppppppppppppppppppppppppppppppppppppppppppbpbhaaaaaaaaaaaipibhgppbcp",
		"ampnpppppppppppbppndbaaaaaaaaoopppppppppphppppopphoppppppppppppppppppppppppppppppppppppppppppppppccodaaaaaaaaaaaaaajlpppppppjh",
		"ampnpppppppppppbppnhhahopbaaipppppppppppppppppppppopppppppppppppppppppppppppppppppppppppppppppppdampdpbmpbihobaaaaaaibaaaaaipd",
		"ampnpppppppppppbppnppbompdihppppppppppppppppplppopopppppppppppppppppppppppppppppppppppppppppppdaaaaallpppppbaaaaaipppppppppnlm",
		"ampnpppppppppppfppnpphpphhmpppppppppppppppppppphpppppppppppppppppppppppppplpppppppppppppjppppppppppppppppppnphpppppppphpplpnob",
		"ampnppppppppppppppndpplppnppppppplhppppppphnpcppppppppppppppppppppppppppppppppppppppppopppppppppppppppplpppppppplppppppppphlmg",
		"ampnppppppppppppppnpppppppppdoppppppnpppppppppppnppppppnppppppppopnpdmpppphpppdoppppppppppppppppppppppppppppppppppppppppnpppop",
		"ampnppppppppppppppppppppppppbphmppphpppppphpndpolbojbipahpcjmlmbbpfhemdippppppppppppppppppppppppppppppoppplpppppppoppppppppplp",
		"ampnppppppppppppppppppppppppbphmppphpppppphpndpolbojbipahpcjmlodbofhamdippppppppppppppppppppppppppplppopppppppppppoppppppppppp",
		"ampnpppppppppppppppppppppppppphmpnphpppppphjidoolfcibipahpcjakoabcedaiaaeopplcpppppppppppppopppppppppppppppppppppppppppppppppp",
		"ampnpppppppppppppppppppppppppphmpnpppppppphlkdoolhcibihahoabacoaaaedaaaafppppkppppppppppppppppppphpppppppppppppppppppppppppppp",
		"ampnpppppppppppppppppppppppppphmpnpppppppphlldpolhcibidehoaaaaoaaaedaaaipppppppppppppppppppoppppphppppplpppppplppppppppppppppp",
		"ampnpppppppppppppppppppppppppppmpnpppppppphlidfaceapbophaaaneppepbedahaaaaainppppppppppppppppphopppphlphpppppppppppppppppppppp",
		"ampnpppppppppppppppppppppppppppmpnpppppppphjmdjdceapbodaaaaaampambedahaaaaaaippppppppppppppppphppppppppppppppopppppnpppppppppp",
		"ampnpppppppppppppppppppppppppppmpnpppppppphjmdjdcaambidaaaaaaapambadahaaaaaaopppppppppppppppppppppppoppopppppoplpppppppppppppp",
		"ampnpppppppppppppppppppppppppppmpnpppppppphjmdjdcabmbihaaaaaaipfppppipeabaaaopppppppppppppppppppppphoppopppppppppppppppppppppp",
		"ampnpppppppppppppppppppppppppppmpnpppppppphjmdjdcadmbipaaaiofpphpppppmhadbecmppppppppppppppppppppppdoppopppppppppppppppppppppp",
		"ampnpppppppppppppppppppppppppppmpnpppppppphjacidaadmbmdaaeionppdndmnamaapppppppppppppppppppppppppppppppppppppppppppppppppppppp",
		"ampnpppppppppppppppppppppppppppmpnpppppppphjacidaabpambaagionppjnbmpamdapppppppppppppppppppppjpppppppppppppppppppppppppppppppp",
		"ampnpppppppppppppppppppppppppppopnpppppppphjacopoanpppbaihmppppppppppphkpmpjppppppppppppppppmhpppopppppppppppppppppppppppppppp",
		"ampnpppppppppppppppppppppppppppopppppppppphbaaoppbppppdakpmppppoppppmppopnphpplppoppppppppdpmhdpdppppppppppppppppppppppppppppp",
		"ampnpppppppppppppppppppppppppppoppppppppppbbaaihkdnpppdkhppppppppppphapppppppplppiippppppppmppcppppppppppppppppppppppppppppppp",
		"ampnpppppppppppppppppppppppppppoppppppppppbbahehmpppplhnnppppppnppppplppppppppjppiaopppppppppjaopppppppppppppppppppppppppppppp",
		"ampnpppppppppppppppppppppppppppppppppppppnbbapmpopphphpppppppppppppjaaipplmpppaeobadamjpppohmbaaaaaaihpbpmpppppppppppppppppppp",
		"ampnpppppppppppppppppppppppppppppppppppdpnbidolpppppopppppppppppppphnpppppppppbpobodbmjpppphmbaaaijpphpjpppppppppppppppppppppp",
		"ampnpppppppppppppppppppppppppppppppppppdpnbojpppppppppppppppppppppppbpplppdppplmhdildiiheopdaaaacodppppppppppppppppppppppppppp",
		"ampnpppppppppppppppppppppppppppppppppppdpbaojppppppnppppppppppppppppmpplppdppplpaaappppepppppppppppppppppppppppppppppppppppppp",
		"ampnpppppppppppppppppppppppppppppppppppdpbooppppppppppppppppppppppppppllppdhpjppmacaappipppppppppphppppppppppppppppppppppppppp",
		"ampnpppppppppppppppppppppppppppppppppppdpjpppppppppppppppppppppnpppppppdopddaiphpcpdcopdpppppppppppppppppppppppppppppppppppppp",
		"ampnppppppppppppppppppppppppppppppppppplppppppppppppppppppppoppppppppppdipddaipflgpdhmhbphppihompppppppppppppppppppppppppppppp",
		"ampnppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppaphaaimpiplppnpdpplpailhdoocapaoamaidaibmhhaaaaaaaaaaa",
		"ampnppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppnpplapdapnnopkdapbppppodcdiiaaacameaobdaaaibapbidaaaaaaaaa",
		"ampnpppppppppppppppppppppppppppppppppppppdopppppppppppppppppppppppoppmphmpdipdjpolpnpppppnpppdhhpnmlpppppppppppppppppppppppppp",
		"ampnppppppppppppppppppppppppppppppppppppppppppppppppppppplppppppppppppphopbmpbihkppldppmhkppmfbodigadagaaaaaaaaaihaipippmipdmp",
		"ampnppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppphopbmpamdkppldppmhkppmnaodigadagaaamamdaamdaibihhaidama",
		"ampnppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppmpbmpamhkppllppmpipjifaobagabagagaiaidmaibaaaaaaaaaaaa",
		"ampnppppppppppppppppppppppppppppppppppppppppppppppppppppplppppppppppppppmpbapamdkppdjodipapbaaaaaaaaaaaadaiaidgaibaaaaaaaaaaaa",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppppppjpppppppppppnppmpampaohipnhbidmpamaaaaaaaaaaaaidaiaidhaibaaaaaaaaaaaa",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppppphipppppppppppnppmpaohaobapndaidopamaaaaaaaaaaaamdaiailhaibaaaaaaaaaaia",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppppppjpppppppppppnppmpaohaohapndamdopamaaaaaaaaaaaamdaiailhaibaaaaaaaaaaia",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppppppjpppppppppppnppmpaohaohapndamdopamaaaaaaaaaaaamdaiailhaibaaaaaaaaaaia",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppphppjpppppppppppnphmpaohaohmpnlaedopamaaaaaaaaaaaamdaiailhaibaaaaaaaaaaia",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppphppjpppppppppppnphmpaohiphmpnlaedopamaaaaaaaaaaaamdaiailhaibaaaaaaaaaaaa",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppphppjpppppppppppnphmpaohmphopnlaedopamaaaaaaaaaaaamdilailhaibaaaaaaaaaaaa",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppphppappppppphpppnpgmpaohmphppaiaaaaaaaaaaaaaaaaaaamdmlailhaibaaaaaaaaaaaa",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppphppappppppphpppnpgmpaohmphppaiaaaaaaaaaaaaaaaaaaamdmlaiphaibaaaaaaaaaaaa",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppphppappppppphpppnpgmhaohmphppoiaaaaaaaaaaaaaaaaaaamdmlaiphaibaaaaaaaaaaaa",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppphppappppppphpppnpgmhaohmphpppiaaaaaaaaaaaaaaaaagamdmlmiphaibaaaaaaaaaaaa",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppphppappppppphpppnpgmhappmphpppiaaaaaaaaaaaaaaaaahamdmloiphaibaibaaadogglo",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppphppappppppphpppnpgmhippmphpppiaaaaaaaaaaaaaaaaahamdmloiphaibaibaaidogopp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppphppapppppppppppnpgmpmppmphpppiaaaaaaaaaaaaaaaaahamdmloiphaibaibaapdppppp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppphppapnppppphpnpnpgmpmppmphpppaamaaaaaaaaaaaaaaahamdmdoamhaaaaaaaippppppp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppphppapnppppphpnpnpgmpmppmphpppaipaaaaaaaaaaaaaaahamdmdoamhaaaaaaamppppppp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppphppapnppppphpnpnpgmpmppmphpppaipaaaaaaaaaaaaaaahamdmdoamhidaaibaoppppppp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppphppapnppppphpnpnpgmpmppmphpppaipdaaaaaaaaaaaaaahamdmdoamhmdaaibapppppppp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppphppapnppppphpnpnpompoppophpppaipdaacaaaaaaaaaaahamdmdoaohodaambipppppppp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppphppapnppppphpnpnppmppppophpppaipdaacaaaaaaaaaeahamdmdoaohodaampppppppppp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppphppapnppppphpnpnppoppppophpppampdaacaaaaaaaaagahaodmdoaohodaampppppppppp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppphppapnppppphpnpnpgmpaopopppppampaaaccaaaaaaaaaahaodmdoaopppppppppppppppp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppphppappppppphpnpnpgmhaohophppdampaaacdaaaaaaaaaahaodmdoaohodaaopppppppppp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppphppappppppphpnpnpgmhaohophppbamdaaakdaaaaaaaahmppppppolphopbeeeapppppppp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppphppappppppphpnpnpgmhaopophpphamdaaakdaaaaaaaapmppppppppppppppppppppppppp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppphppappppppphpnpnpgmhaopophpphambaaakdaaaaaaaapnppppppppppppppppppppppppp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppphppappppppphpnpnpgmpaopophpphambaaakdaaaaaaaapnppppppppppppppppppppppppp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppphppappppppphpnpnpgmpaopophpphambaaakdaaaaaaaaojppppppppppppppppppppppppp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppphppappppppphpnpnpgmpaopophpphambiaakdaaaaaaaambppppppppppppppppppppppppp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppphppappppppphpnpnpgmpaopophpphambmaakdaaaaaaaaaahamdmpppppppppppppppppppp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppphppappppppphpnpnpgmpaopophpphamboaakdaaaaaaaaaahamdmpppppppppppppppppppp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppphppappppppphpnpnpgmpaopophpphamboaakdaaaaaaaaaahamdmpppppppppppppppppppp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppphppappppppphpnpnpgmpaopophpphamboaakdaaaaaaaaaahamdmpppppppppppppppppppp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppphppappppppphpnpnpgmpaopophpphambaaaaaaaaaaaaaaaaaaaaoppppppppppppppppppp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppphppappppppphpnpnpgoppppppppphambaaaaafaaaaaaaaaaaaaipppppppppppppppppppp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppphppappnpppphpnpnhhopppppppppbaaaaaaaandaacaaaaaaaaampppppppppppppppppppp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppphppappnpppphpnpnhhmhaohophppbaaaaaaaanhaacaipopppppppppppppppppppppppppp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppphppippppppphpnpnhhmpppppppppbaaaaaaehphaacampppppppppppppppppppppppppppp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppphppjppppppphpnpnhpmpppppphppbaadaajnpppbbcampppppppppppppppppppppppppppp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppphppjppppppphpnpnhppppppppppphaiknbaeopppbpampppppppppppppppppppppppppppp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppphppjppppppphpnppppppppppppppppnpnpploppppppppppppppppppppppppppppppppppp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppphppjppppppphpnppppppppppppppndmpfppppppppppppppppppppppppppppppppppppppp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppphppjppppppphpnppppppppppppppppppnppnpppppppppppppppppppppppppppppppppppp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppphppjppppppphpnpppppppppppppppppppppppppppppppppppppppppppppppppppppppppp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppphppjpppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppphppjpppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppppppjppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppmppppppp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppppppnpppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp",
		"ampnppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppphpp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppnpp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppphpppphpppppppp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppphpppphpppppppp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppphpppphpppppppp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppphpppphpppppppp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppphpppphpppppppp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppphpppphpppppppp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppphpppphpppppppp",
		"ampnppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppdppophpppppppp",
		"ampnppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppdppophpppppppp",
		"ampnppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppdppophpppppppp",
		"ampnppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppdppophpppppppp",
		"ampnppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppdppophpppppppp",
		"ampnppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppdppophpppppppp",
		"ampnppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppdppophpppppppp",
		"ampnppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppdpppphpppppppp",
		"ampnppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppdpppphpppppppp",
		"ampnppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppdpppphpppppppp",
		"ampnppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppdpppphpppppppp",
		"ampnppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppdpppphpppppppp",
		"ampnppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppdpppphpppppppp",
		"ampnppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppdpppphpppppppp",
		"ampnppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppdpppphpppppppp",
		"ampnppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppdpppphpppppppp",
		"ampnppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppdpppphpppppppp",
		"ampnppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppphapppphppppppmp",
		"ampnppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppphapppphppppppmp",
		"ampnppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppphapppphppppppmp",
		"ampnppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppphapppphppppppmp",
		"ampnppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppphapppphppppppmp",
		"ampnppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppphapppphppppppmp",
		"ampnppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppphapppphppppppmp",
		"ampnppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppphapppphppppppmp",
		"ampnppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppphapppphppppppmp",
		"ampnppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppphapppphppppppmp",
		"ampnppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppphapppphppppppmp",
		"ampnppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppphapppphppppppmp",
		"ampnppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppphapppphppppppmp",
		"ampnppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppphapppphppppppmp",
		"ampnppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppphapppphppppppmp",
		"ampnppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppphapppphppppppmp",
		"ampnppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppphapppphppppppmp",
		"ampnppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppphapppphppppppmp",
		"ampnppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppphapppphppppppmp",
		"ampnppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppphapppphppppppmp",
		"ampnppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppphapppphppppppmp",
		"ampnppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppphapppphppppppmp",
		"ampnppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppphapppphppppppmp",
		"ampnppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppapppphppppppmp",
		"ampnppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppbpppphppppppmp",
		"ampnppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppdpppphppppppmp",
		"ampnppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppdpppphppppppmp",
		"ampnppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppdpppphppppppmp",
		"ampnppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppdpppphppppppmp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppphoppppppphppppppmp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppphoppppppphppppppmp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppphoppppppphppppppmp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppphoppppppphppppppmp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppoppppppphppppppmp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppoppppppphppppppmp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppoppppppphppppppmp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppoppppppphppppppmp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppoppppppphppppppmp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppoppppppphppppppmp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppoppppppphppppppmp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppoppppppphppppppmp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppoppppppppppppppmp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppopnppppphppppppmp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppopnppppphppppppmp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppopnppppphppppppmp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppopnppppphppppppmp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppopnppppphppppppmp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppopnppppphppppppmp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppopnppppphppppppmp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppopnppppphppppppmp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppopnppppphppppppmp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppopnppppphppppppmp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppopnppppphppppppmp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppopnppppphppppppmp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppoppppppphpppppppp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppoppppppphpppppppp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppoppppppphpppppppp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppoppppppphpppppppp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppoppppppphpppppppp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppoppppppphpppppppp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppoppppppphpppppppp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppoppppppphpppppppp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppoppppppphpppppppp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppoppppppphpppppppp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppoppppppphpppppppp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppoppppppphpppppppp",
		"ampnppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppphpppppppp",
		"ampnppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppphpppppppp",
		"ampnppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppphpppppppp",
		"ampnppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppopppphpppppppp",
		"ampnppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppopppphpppppppp",
		"ampnppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppopppphpppppppp",
		"ampnpppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp",
	};
	int L, D;
	while(~scanf("%d%d", &L, &D)) {
		bool ans = (table[D > 205 ? 205 : D][L / 4] - 'a') >> (L % 4) & 1;
		puts(ans ? "kado" : "matsu");
	}
	return 0;
}
0