結果

問題 No.3086 愛国心(2)
ユーザー googol_S0googol_S0
提出日時 2021-04-01 22:56:01
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 119 ms / 5,000 ms
コード長 35,911 bytes
コンパイル時間 303 ms
コンパイル使用メモリ 91,740 KB
実行使用メモリ 76,724 KB
最終ジャッジ日時 2024-12-21 07:02:02
合計ジャッジ時間 1,069 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 61 ms
69,500 KB
testcase_01 AC 119 ms
76,724 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

X=[[765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765],[765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,762,762,762,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765],[765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,762,760,765,765,765,765,762,762,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765],[765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,762,759,765,765,765,713,672,756,765,765,762,759,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765],[765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,762,759,765,765,765,690,533,293,155,422,616,735,765,765,765,759,764,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765],[765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,764,762,762,765,765,756,648,470,228,26,143,199,43,51,343,556,703,765,765,765,762,762,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765],[765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,762,762,765,765,765,733,601,399,146,36,167,235,223,211,235,216,85,37,258,489,663,762,765,765,765,762,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765],[765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,762,760,765,765,765,703,551,323,52,71,193,231,221,202,202,205,199,209,231,221,156,40,166,418,616,737,765,765,765,759,762,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765],[765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,762,762,765,765,759,664,492,242,29,128,215,225,216,202,202,205,205,205,205,204,200,208,221,225,195,52,42,338,560,704,765,765,765,759,762,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765],[765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,762,762,765,765,765,741,617,426,166,29,169,231,222,209,205,202,205,205,205,205,205,205,205,205,205,202,205,213,228,220,102,29,261,493,663,762,765,765,762,762,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765],[765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,762,762,765,765,765,713,565,349,76,42,191,237,219,202,202,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,202,205,228,231,152,33,175,417,613,738,765,765,765,762,762,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765],[765,764,765,765,765,764,765,765,765,765,765,765,764,765,765,765,765,765,762,765,765,765,765,765,759,759,765,765,765,679,505,272,41,100,205,233,216,199,202,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,201,202,223,231,185,59,69,336,557,706,765,765,765,762,762,765,765,765,765,765,762,765,762,765,765,765,765,764,765,764,765,765,764,764,765,765,765,765,765,765,765,765,765],[765,764,765,765,765,764,765,765,765,765,765,765,762,765,765,765,765,765,762,765,765,765,759,762,765,765,744,636,447,181,33,158,220,225,213,202,202,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,202,202,217,226,212,119,30,251,495,665,759,765,765,762,762,765,765,765,762,765,762,765,765,765,765,762,765,764,765,765,764,764,765,765,765,765,765,765,765,765,765],[765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,762,762,765,765,765,721,583,377,82,37,191,231,217,208,202,202,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,202,205,210,223,228,166,29,165,423,613,736,765,765,765,762,762,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765],[765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,762,762,765,765,765,688,525,301,41,65,210,236,213,202,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,202,202,219,238,193,42,69,339,554,706,765,765,765,762,762,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765],[765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,759,765,765,765,753,651,464,220,38,131,217,232,210,199,204,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,202,199,216,234,208,105,40,255,490,666,759,765,765,765,759,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765],[765,765,765,765,765,765,765,765,765,765,765,765,765,759,765,765,765,730,604,399,111,40,179,223,225,209,200,202,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,202,201,212,225,220,166,36,151,422,617,736,765,765,765,759,764,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765],[765,765,765,765,765,765,765,765,765,765,762,762,765,765,765,699,548,326,40,53,207,228,216,207,202,204,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,202,202,208,217,230,199,43,45,343,557,703,765,765,765,762,762,765,765,765,765,765,765,765,765,765,765,765,765,765,765],[765,765,765,765,765,765,765,762,762,765,765,765,762,661,483,251,33,105,223,232,209,202,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,202,210,234,219,87,34,261,489,663,762,765,765,765,762,762,765,765,765,765,765,765,765,765,765,765,765],[765,765,765,765,765,765,765,765,765,765,740,618,419,164,40,156,225,230,205,199,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,199,207,231,223,152,40,169,417,616,737,765,765,765,765,765,765,765,765,765,765,765,765,765,765],[765,765,765,765,765,765,765,765,716,576,346,46,58,194,226,223,205,200,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,200,207,223,225,193,58,45,339,568,711,765,765,765,765,765,765,765,765,765,765,765,765],[765,765,765,765,765,765,756,563,155,0,115,239,236,216,202,202,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,202,202,216,236,239,126,0,98,539,750,765,765,765,765,765,765,765,765,765,765],[765,765,765,765,765,765,760,697,577,398,143,43,179,223,225,209,199,204,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,202,200,209,225,223,182,45,130,383,566,688,759,765,765,765,765,765,765,765,765,765,765],[765,765,765,765,765,765,765,765,765,744,639,455,211,37,133,218,232,210,199,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,204,199,210,232,218,134,38,202,447,632,740,765,765,765,765,765,765,765,765,765,765,765,765,765],[765,765,765,765,765,765,709,730,765,765,765,764,682,518,296,41,65,211,235,213,202,204,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,204,202,213,236,210,65,40,293,515,678,762,765,765,765,721,716,765,765,765,765,765,765,765,765,765,765],[765,765,765,765,765,765,528,313,586,713,765,765,765,765,715,580,376,79,37,190,230,219,208,202,202,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,202,202,209,220,230,187,36,87,376,580,713,765,765,765,765,703,566,284,577,765,762,765,765,765,765,765,765,765,765],[765,765,765,765,762,765,536,0,58,293,512,675,762,765,765,765,741,633,450,191,33,154,217,226,213,201,202,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,202,202,215,226,217,149,32,202,455,636,742,765,765,765,756,662,493,268,44,0,586,765,762,765,765,765,765,765,765,765,765],[765,765,765,765,765,765,539,76,236,138,37,200,441,630,739,765,765,765,759,676,513,280,42,82,202,234,217,199,202,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,202,200,220,234,197,74,44,293,522,681,762,765,765,765,732,614,420,175,38,150,239,82,586,765,762,765,765,765,765,765,765,765,765],[765,765,765,765,764,765,536,35,225,228,224,184,47,74,361,574,709,765,765,765,765,712,571,361,88,39,187,237,220,202,202,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,202,204,223,235,175,37,122,379,583,716,765,765,765,765,700,557,339,52,61,190,225,226,221,39,586,765,762,765,765,765,765,765,765,765,765],[765,765,765,765,765,765,536,38,222,205,205,216,226,213,81,30,278,508,669,759,765,765,765,738,624,440,188,27,156,228,223,210,205,202,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,202,205,212,225,225,138,25,216,458,636,744,765,765,765,753,658,491,255,27,110,217,225,214,205,205,220,41,586,765,762,765,765,765,765,765,765,765,765],[765,765,765,765,765,765,536,38,222,207,204,204,205,207,228,231,147,30,190,432,619,736,765,765,765,759,670,507,269,33,112,210,226,217,202,202,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,200,205,220,226,202,78,37,301,530,682,762,765,765,765,730,607,414,168,31,160,234,225,207,204,204,205,207,220,41,586,765,762,765,765,765,765,765,765,765,765],[765,764,765,765,765,765,536,38,222,207,205,205,205,205,202,202,225,234,179,44,82,349,562,703,765,765,765,765,707,567,349,76,50,182,231,225,202,201,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,199,205,228,226,168,43,123,382,589,718,765,765,765,765,697,549,332,66,48,187,234,223,202,202,205,205,205,205,207,220,41,583,765,762,765,765,765,765,765,765,765,765],[765,764,765,765,765,765,536,38,222,207,205,205,205,205,205,205,202,202,220,228,206,114,37,261,498,661,752,765,765,765,732,618,426,182,34,149,231,228,205,202,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,202,208,232,225,118,34,226,459,641,745,765,765,765,750,656,484,242,36,125,210,228,217,202,202,205,205,205,205,205,205,207,220,41,583,765,762,765,765,765,765,765,765,765,765],[765,765,765,765,765,765,536,38,222,207,205,205,205,205,205,205,205,205,202,202,212,223,224,163,29,164,426,613,730,765,765,765,757,663,496,265,29,101,220,228,213,205,202,205,205,205,205,205,205,205,205,205,205,202,202,207,215,231,209,58,38,310,530,684,765,765,765,765,726,604,411,143,31,172,225,222,212,202,202,205,205,205,205,205,205,205,205,207,220,41,586,765,762,765,765,765,765,765,765,765,765],[765,765,765,765,765,765,536,38,222,207,205,205,205,205,205,205,205,205,205,205,203,204,205,217,235,196,41,61,340,551,698,765,765,765,765,703,560,340,44,53,196,225,221,207,200,204,205,205,205,205,205,202,201,210,223,223,179,38,107,392,592,719,765,765,765,765,692,542,326,46,44,202,235,216,205,204,204,205,205,205,205,205,205,205,205,205,205,207,220,41,586,765,762,765,765,765,765,765,765,765,765],[765,765,765,765,765,765,536,38,222,207,205,205,205,205,205,205,205,205,205,205,205,205,205,202,199,213,235,211,93,38,255,485,656,753,765,765,765,731,612,417,164,40,158,223,230,208,199,205,205,202,199,213,232,213,126,38,224,467,645,746,765,765,765,750,651,474,241,37,105,215,235,212,200,204,205,205,205,205,205,205,205,205,205,205,205,205,205,207,220,41,586,765,762,765,765,765,765,765,765,765,765],[765,765,765,765,765,765,536,38,222,207,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,202,199,210,228,220,163,40,152,411,607,727,765,765,765,753,658,485,252,36,96,220,234,210,201,217,237,199,51,45,313,533,688,765,765,765,765,724,601,401,134,42,169,222,228,209,199,202,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,207,220,41,586,765,762,765,765,765,765,765,765,765,765],[765,764,765,765,765,765,536,38,222,207,205,205,205,205,205,205,205,205,205,204,202,205,205,205,205,205,205,202,202,208,220,226,200,48,41,329,545,691,765,765,765,765,696,546,333,44,45,204,234,175,32,137,399,593,722,765,765,765,765,688,539,319,38,58,202,226,218,208,202,203,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,207,220,41,583,765,762,765,765,765,765,765,765,765,765],[765,765,765,765,765,765,536,38,222,207,205,205,205,205,205,205,205,202,208,223,213,201,202,205,205,205,205,205,205,204,202,205,210,231,223,109,30,243,476,648,750,765,765,765,727,605,410,141,20,228,473,647,747,765,765,765,748,645,468,236,29,120,225,230,210,205,202,204,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,207,220,41,586,765,762,765,765,765,765,765,765,765,765],[765,765,765,765,762,765,536,38,222,207,205,205,205,205,205,205,202,210,182,102,202,232,213,199,204,205,205,205,205,205,205,205,205,202,205,228,231,158,38,152,400,595,722,765,765,765,755,645,560,689,765,765,765,765,721,593,391,143,38,162,231,228,205,202,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,207,220,41,586,765,762,765,765,765,765,765,765,765,765],[765,765,765,765,765,765,536,38,222,207,205,205,205,205,205,202,212,170,292,367,91,42,205,236,212,201,205,205,205,205,205,205,205,205,205,200,202,223,228,194,74,44,313,536,688,765,765,765,765,765,765,765,686,533,307,44,77,195,228,223,202,201,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,207,220,41,586,765,762,765,765,765,765,765,765,765,765],[765,765,765,765,765,765,536,38,222,207,205,205,205,205,205,200,232,44,410,733,625,397,108,39,202,232,213,205,202,205,205,205,205,205,205,205,205,202,205,216,225,217,134,27,226,464,651,759,765,759,650,461,219,26,138,218,225,215,204,202,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,207,220,41,586,765,762,765,765,765,765,765,765,765,765],[765,765,765,765,765,765,536,38,222,207,205,205,205,205,205,200,234,47,409,765,765,751,639,436,140,37,189,226,220,205,202,205,205,205,205,205,205,205,205,202,205,207,221,232,195,0,295,731,765,733,296,0,198,232,220,207,205,202,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,207,220,41,586,765,762,765,765,765,765,765,765,765,765],[765,765,765,765,765,765,536,38,222,207,205,205,205,205,205,200,234,42,426,759,765,765,765,762,661,464,192,39,166,226,225,202,201,205,205,205,205,205,205,205,205,205,202,199,234,176,322,727,765,729,327,173,235,199,202,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,207,220,41,586,765,762,765,765,765,765,765,765,765,765],[765,765,765,765,765,765,536,38,223,207,205,205,205,205,205,200,234,42,429,756,765,759,762,765,765,765,678,492,237,35,143,231,226,202,202,205,205,205,205,205,205,205,205,204,220,119,329,730,765,731,332,114,220,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,207,220,41,586,765,762,765,765,765,765,765,765,765,765],[765,765,765,765,765,765,536,38,222,207,205,205,205,205,205,199,237,35,447,765,765,757,764,762,762,765,765,765,694,521,275,30,129,231,218,202,205,205,205,205,205,205,205,202,221,127,323,729,765,730,327,124,223,202,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,207,220,41,586,765,762,765,765,765,765,765,765,765,765],[765,765,765,765,765,765,536,38,222,207,205,205,205,205,205,202,221,143,330,657,765,765,765,762,762,764,762,765,765,765,709,551,305,29,145,213,202,205,205,205,205,205,205,202,221,126,325,729,765,730,328,122,223,202,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,207,220,41,586,765,762,765,765,765,765,765,765,765,765],[765,765,765,765,765,765,536,38,222,207,205,205,205,205,205,205,202,214,167,178,440,645,759,765,765,762,762,765,759,765,765,765,725,577,320,177,212,205,205,205,205,205,205,202,221,126,325,729,765,730,328,122,223,202,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,207,220,41,586,765,762,765,765,765,765,765,765,765,765],[765,765,765,765,762,765,536,38,222,207,205,205,205,205,205,205,205,202,210,187,48,121,410,625,747,765,765,762,762,765,762,765,765,765,575,42,217,208,205,205,205,205,205,202,221,126,325,729,765,730,328,122,223,202,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,207,220,41,586,765,762,765,765,765,765,765,765,765,765],[765,765,765,765,765,765,536,38,222,207,205,205,205,205,205,205,205,205,205,217,226,205,54,50,378,604,736,765,765,762,762,765,756,765,577,42,217,208,205,205,205,205,205,202,221,126,325,729,765,730,328,122,223,202,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,207,220,41,586,765,762,765,765,765,765,765,765,765,765],[765,765,765,765,765,765,536,38,222,207,205,205,205,205,205,205,205,205,205,202,205,210,228,217,69,41,346,575,724,765,765,765,756,765,565,42,218,208,205,205,205,205,205,202,221,126,325,729,765,730,328,122,223,202,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,207,220,41,586,765,762,765,765,765,765,765,765,765,765],[765,765,765,765,765,765,536,38,222,207,205,205,205,205,205,205,205,205,205,205,205,205,202,206,232,220,81,40,309,548,712,765,765,765,560,42,220,208,205,205,205,205,205,202,221,126,325,729,765,730,328,122,223,202,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,207,220,41,586,765,762,765,765,765,765,765,765,765,765],[765,764,765,765,765,765,536,38,223,207,205,205,205,205,205,205,205,205,205,205,205,205,205,205,199,207,231,217,131,38,270,524,692,765,571,34,220,208,205,205,205,205,205,202,221,126,325,729,765,727,328,122,223,202,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,207,220,41,583,765,762,765,765,765,765,765,765,765,765],[765,765,765,765,765,765,536,38,222,207,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,200,209,223,223,158,30,210,530,464,118,210,207,205,205,205,205,205,202,221,126,325,729,765,730,328,122,223,202,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,207,220,41,586,765,762,765,765,765,765,765,765,765,765],[765,765,765,765,765,765,536,38,223,207,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,204,202,207,218,232,169,34,161,212,202,205,205,205,205,205,205,202,221,126,325,729,765,730,328,122,223,202,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,207,220,41,586,765,762,765,765,765,765,765,765,765,765],[765,765,765,765,765,765,536,38,223,207,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,204,202,219,232,208,202,205,205,205,205,205,205,205,202,221,126,325,729,765,730,328,122,223,202,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,207,220,41,586,765,762,765,765,765,765,765,765,765,765],[765,764,765,765,765,765,536,38,223,207,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,202,202,207,205,205,205,205,205,205,205,205,202,221,126,325,729,765,727,328,122,223,202,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,207,220,41,583,765,762,765,765,765,765,765,765,765,765],[765,764,765,765,765,765,536,38,222,207,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,202,221,126,325,729,765,727,328,122,223,202,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,207,220,41,583,765,762,765,765,765,765,765,765,765,765],[765,765,765,765,765,765,536,38,223,207,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,202,221,126,325,729,765,730,328,122,223,202,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,207,220,41,586,765,762,765,765,765,765,765,765,765,765],[765,765,765,765,765,765,536,38,222,207,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,202,221,126,325,729,765,730,328,122,223,202,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,207,220,41,586,765,762,765,765,765,765,765,765,765,765],[765,765,765,765,765,765,536,38,222,207,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,202,221,126,325,729,765,730,328,122,223,202,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,207,220,41,586,765,762,765,765,765,765,765,765,765,765],[765,765,765,765,765,765,536,38,222,207,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,202,221,126,325,729,765,730,328,122,223,202,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,207,220,41,586,765,762,765,765,765,765,765,765,765,765],[765,765,765,765,765,765,536,36,223,207,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,202,221,126,325,729,765,730,328,122,223,202,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,207,220,40,586,765,762,765,765,765,765,765,765,765,765],[765,765,765,765,764,765,541,44,217,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,202,221,126,325,729,765,730,328,122,223,202,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,217,58,589,765,762,765,765,765,765,765,765,765,765],[765,765,765,765,765,765,524,29,251,214,199,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,202,221,126,325,729,765,730,328,122,223,202,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,199,217,249,28,574,765,762,765,765,765,765,765,765,765,765],[765,765,765,765,762,765,568,0,51,208,235,210,202,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,202,221,126,325,729,765,730,328,122,223,202,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,202,213,236,199,41,34,613,765,762,765,765,765,765,765,765,765,765],[765,765,765,765,765,765,750,631,420,108,39,202,228,214,205,202,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,202,221,126,325,729,765,730,328,122,223,202,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,202,205,216,230,193,34,155,444,649,756,765,765,765,765,765,765,765,765,765,765],[765,764,765,765,765,762,765,765,759,648,441,145,41,188,226,220,202,202,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,202,221,126,325,729,765,727,328,122,223,202,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,201,205,222,225,181,37,178,464,660,765,765,765,762,765,765,765,765,765,765,765,765,765],[765,765,765,765,765,765,762,760,765,765,765,660,458,185,40,170,231,222,200,202,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,202,221,126,325,729,765,730,328,122,223,202,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,202,202,224,230,158,38,213,481,675,765,765,765,759,762,765,765,765,765,765,765,765,765,765,765],[765,764,765,765,765,762,765,765,762,762,765,765,765,672,479,218,31,165,236,220,202,204,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,202,221,126,325,729,765,727,328,122,223,202,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,204,202,223,234,152,31,243,499,685,765,765,765,759,762,765,764,762,765,765,765,765,765,765,765,765,765],[765,765,765,765,765,765,765,765,765,765,765,762,765,765,765,684,504,238,26,161,230,220,207,202,204,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,202,221,126,325,729,765,730,328,122,223,202,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,202,202,208,220,228,148,26,264,521,695,765,765,765,762,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765],[765,764,765,765,765,762,765,765,765,765,765,765,762,759,765,765,765,697,521,260,31,151,220,225,208,200,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,202,221,126,325,729,765,727,328,122,223,202,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,200,210,225,220,140,32,283,539,707,765,765,765,759,765,762,765,762,765,765,762,764,765,765,765,765,765,765,765,765,765],[765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,759,765,765,765,709,542,286,40,121,220,231,205,200,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,202,221,126,325,729,765,730,328,122,223,202,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,199,207,231,216,108,41,306,557,718,765,765,765,759,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765],[765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,764,762,765,765,765,718,556,315,39,88,225,231,205,202,205,205,205,205,205,205,205,205,205,205,205,205,205,202,221,126,325,729,765,730,328,122,223,202,205,205,205,205,205,205,205,205,205,205,205,205,205,202,205,231,220,77,42,333,571,726,765,765,765,762,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765],[765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,762,762,765,765,726,577,340,38,78,220,226,210,204,202,205,205,205,205,205,205,205,205,205,205,202,221,126,325,729,765,730,328,122,223,202,205,205,205,205,205,205,205,205,205,205,202,204,210,227,217,67,42,358,589,733,765,765,762,762,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765],[765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,762,762,765,765,735,595,361,43,76,209,227,215,202,202,205,205,205,205,205,205,205,205,202,221,126,325,729,765,730,328,122,223,202,205,205,205,205,205,205,205,205,202,202,216,227,205,69,49,379,607,741,765,765,762,762,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765],[765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,759,762,765,765,744,612,382,82,61,197,233,214,199,204,205,205,205,205,205,205,202,221,126,325,729,765,730,328,122,223,202,205,205,205,205,205,205,202,199,216,232,194,52,104,398,622,749,765,765,762,762,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765],[765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,762,762,765,765,753,624,408,124,41,198,237,213,202,205,205,205,205,205,202,221,126,325,729,765,730,328,122,223,202,205,205,205,205,205,202,213,237,193,39,140,420,633,756,765,765,762,762,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765],[765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,762,762,765,765,758,639,435,145,35,196,231,214,205,202,205,205,202,221,126,325,729,765,730,328,122,223,202,205,205,202,205,214,231,193,33,161,444,647,762,765,765,762,762,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765],[765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,762,759,765,765,762,656,456,164,36,185,225,220,205,202,202,221,126,325,729,765,730,328,122,223,202,202,205,220,226,182,36,176,465,663,765,765,765,759,762,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765],[765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,762,759,765,765,765,670,474,201,39,165,228,224,200,219,128,325,729,765,730,328,124,220,200,225,228,163,38,211,482,676,765,765,765,759,762,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765],[765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,762,762,765,765,765,681,492,234,33,153,232,238,121,323,729,765,730,327,118,241,232,149,34,242,499,685,765,765,765,762,762,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765],[765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,763,762,765,765,765,692,515,260,26,172,170,333,729,765,730,337,167,173,25,266,520,696,765,765,765,762,762,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765],[765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,759,765,765,765,703,537,290,0,293,730,765,732,297,0,296,542,706,765,765,765,759,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765],[765,764,765,765,765,764,765,765,765,765,765,765,764,765,765,765,765,765,764,765,765,765,765,765,765,764,764,765,765,765,762,765,765,765,762,762,765,765,765,765,756,765,765,765,719,536,391,725,765,723,400,539,722,765,765,762,756,765,765,765,765,765,765,762,765,765,765,765,765,765,765,765,765,765,765,765,765,765,764,765,764,765,765,765,765,764,765,764,765,765,764,764,765,765,765,765,765,765,765,765,765],[765,764,765,765,765,764,765,765,765,765,765,765,764,765,765,765,765,765,764,765,765,765,765,765,765,764,762,765,765,765,764,765,765,765,762,762,765,765,762,765,765,765,762,762,765,765,728,753,765,750,733,765,765,765,762,762,765,765,765,765,765,765,765,762,765,765,765,765,765,765,765,765,765,765,765,765,765,765,764,765,764,765,765,765,765,764,765,764,765,765,764,764,765,765,765,765,765,765,765,765,765],[765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,762,765,765,765,765,765,765,765,762,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765],[765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,762,765,765,765,762,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765],[765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765,765]]
for t in range(int(input())):
  a,b=map(int,input().split())
  print(X[a][b])
0