結果

問題 No.3086 愛国心(2)
ユーザー googol_S0googol_S0
提出日時 2021-04-01 22:19:21
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 36,041 bytes
コンパイル時間 586 ms
コンパイル使用メモリ 91,476 KB
実行使用メモリ 77,140 KB
最終ジャッジ日時 2024-06-01 04:00:38
合計ジャッジ時間 1,316 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

X=[[762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762],[762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,759,759,759,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762],[762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,759,757,762,762,762,762,759,759,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762],[762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,759,756,762,762,762,719,681,749,762,762,759,756,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762],[762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,759,756,762,762,762,701,565,353,219,437,618,729,759,762,762,756,761,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762],[762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,761,759,759,762,762,756,666,510,293,92,152,191,88,106,365,562,700,759,762,762,759,759,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762],[762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,759,759,762,762,762,736,625,448,216,88,164,211,215,208,215,201,115,89,290,501,663,753,762,762,762,759,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762],[762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,759,757,762,762,762,712,582,382,128,101,180,210,216,205,202,205,202,209,218,205,167,87,208,436,619,731,759,762,762,756,759,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762],[762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,759,759,762,762,756,679,531,308,96,138,194,211,213,205,202,205,205,205,205,204,202,208,214,209,192,90,97,364,568,701,759,762,762,756,759,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762],[762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,759,759,762,762,762,744,640,472,236,84,163,209,213,209,205,202,205,205,205,205,205,205,205,205,205,202,205,210,212,204,125,80,292,508,663,756,762,762,759,759,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762],[762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,759,759,762,762,762,720,597,405,151,78,175,217,215,205,202,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,202,205,216,214,161,77,214,438,619,735,759,762,762,759,759,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762],[762,764,762,762,762,764,762,762,762,762,762,762,764,762,762,762,762,762,762,762,762,762,762,762,756,759,765,762,762,694,546,336,111,114,185,215,213,202,202,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,202,203,217,215,183,90,116,363,567,705,759,762,762,759,759,762,762,762,762,762,762,762,762,762,762,762,762,764,762,764,762,762,764,764,762,762,762,762,762,762,762,762,762],[762,764,762,762,762,764,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,756,759,762,765,747,657,492,253,88,153,201,214,213,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,202,203,214,213,200,135,77,285,510,668,753,762,762,759,759,762,762,762,762,762,762,762,762,762,762,762,762,764,762,762,764,764,762,762,762,762,762,762,762,762,762],[762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,759,759,762,762,762,727,612,429,160,73,171,214,214,209,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,215,214,170,68,204,444,619,733,762,762,762,759,759,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762],[762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,759,759,762,762,762,702,562,361,113,82,184,220,213,205,205,205,205,205,205,205,205,205,205,205,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,224,188,71,111,366,566,706,759,762,762,759,759,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762],[762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,756,762,762,762,753,670,508,288,97,130,196,219,211,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,202,202,213,221,196,119,80,287,507,669,756,762,762,762,756,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762],[762,762,762,762,762,762,762,762,762,762,762,762,762,756,762,762,762,733,630,450,191,77,161,207,218,211,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,202,202,212,217,207,167,70,192,443,626,733,760,762,762,756,761,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762],[762,762,762,762,762,762,762,762,762,762,759,759,762,762,759,708,581,386,124,73,179,214,214,210,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,214,218,190,67,93,372,569,703,759,762,762,759,759,762,762,762,762,762,762,762,762,762,762,762,762,762,762],[762,762,762,762,762,762,762,759,759,762,762,759,756,679,525,316,103,107,194,219,211,203,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,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,222,204,101,76,295,507,666,756,759,762,762,759,759,762,762,762,762,762,762,762,762,762,762,762],[762,762,762,762,762,762,762,762,762,759,740,641,469,238,89,143,205,221,208,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,200,207,222,210,153,74,208,441,622,734,759,762,762,762,762,762,762,762,762,762,762,762,762,762],[762,762,762,762,762,762,762,759,719,605,408,137,78,170,211,218,208,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,200,208,219,214,185,78,94,371,577,708,759,762,762,762,762,762,762,762,762,762,762,762],[762,762,762,762,762,762,756,612,272,65,107,206,226,216,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,205,205,205,205,205,205,205,205,205,205,205,205,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,226,221,129,40,166,565,750,762,762,762,762,762,762,762,762,762,762],[762,762,762,762,762,762,757,703,586,419,199,77,156,212,222,211,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,205,205,205,205,205,205,205,205,202,200,209,222,218,177,65,154,382,554,685,756,762,762,762,762,762,762,762,762,762,762],[762,762,762,762,762,762,762,759,753,732,639,474,262,86,123,200,225,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,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,200,210,227,210,135,64,223,443,617,722,753,757,761,762,762,762,762,762,762,762,762,762,762],[762,762,762,762,762,762,718,716,750,759,756,749,678,531,337,104,74,183,224,214,205,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,228,201,78,71,305,505,661,747,756,759,753,711,716,762,762,762,762,762,762,762,762,762,762],[762,762,762,762,762,762,584,369,521,675,744,759,759,753,706,585,406,148,63,166,218,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,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,202,202,209,217,222,182,57,118,378,566,697,753,759,759,751,682,538,318,595,762,759,762,762,762,762,762,762,762,762],[762,762,762,762,759,762,584,129,68,256,463,631,733,756,759,756,729,632,471,245,79,140,202,219,213,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,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,202,202,214,220,209,151,61,222,450,618,727,755,759,757,738,640,473,266,64,60,598,762,759,762,762,762,762,762,762,762,762],[762,762,762,762,762,762,586,175,195,163,77,183,393,581,705,750,759,758,747,674,528,323,100,89,182,223,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,205,205,205,205,205,205,205,205,205,205,205,205,205,205,202,202,217,226,191,88,75,305,512,666,747,756,759,753,711,590,405,183,66,162,219,119,598,762,759,762,762,762,762,762,762,762,762],[762,762,762,762,761,762,584,146,183,223,219,192,89,89,313,523,669,744,759,759,753,706,579,394,149,65,167,223,220,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,205,205,205,205,205,205,202,204,220,226,174,62,147,382,569,701,753,759,759,750,678,534,329,76,83,192,219,223,207,85,598,762,759,762,762,762,762,762,762,762,762],[762,762,762,762,762,762,584,147,181,209,205,213,218,211,116,60,243,458,625,730,756,759,756,729,627,461,238,71,145,213,219,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,219,216,144,56,233,453,622,729,756,759,756,735,635,471,254,55,126,212,219,212,205,206,205,85,598,762,759,762,762,762,762,762,762,762,762],[762,762,762,762,762,762,584,147,181,210,204,204,205,207,219,223,167,70,175,386,571,700,750,759,759,747,670,522,311,87,114,195,217,215,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,200,205,217,218,198,95,69,308,519,667,748,759,759,753,709,583,399,178,58,167,225,220,207,204,204,205,207,205,85,598,762,759,762,762,762,762,762,762,762,762],[762,764,762,762,762,765,586,147,181,210,205,205,205,205,202,202,218,226,189,82,93,308,513,663,742,759,762,756,704,576,383,133,71,168,219,222,205,201,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,199,205,223,218,170,68,147,382,575,703,753,759,757,749,674,526,326,88,70,188,226,220,202,202,205,205,205,205,207,205,85,598,765,759,762,762,762,762,762,762,762,762],[762,764,762,762,762,765,586,147,181,210,205,205,205,205,205,205,202,202,215,221,206,137,69,233,449,620,725,753,759,756,727,622,448,228,73,143,215,223,207,202,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,202,208,223,217,130,64,238,453,625,730,756,759,756,732,633,465,246,62,135,206,220,214,202,202,205,205,205,205,205,205,207,205,85,598,765,759,762,762,762,762,762,762,762,762],[762,762,762,762,762,762,584,147,181,210,205,205,205,205,205,205,205,205,202,202,209,218,219,175,66,155,380,565,695,747,759,759,748,663,512,303,79,106,201,220,213,205,202,205,205,205,205,205,205,205,205,205,205,202,202,207,212,220,204,80,69,314,519,669,751,759,759,751,705,579,398,158,56,175,219,218,212,202,202,205,205,205,205,205,205,205,205,207,205,85,598,762,759,762,762,762,762,762,762,762,762],[762,762,762,762,762,762,584,147,181,210,205,205,205,205,205,205,205,205,205,205,203,204,205,213,227,202,78,74,301,505,657,741,756,759,756,700,569,373,100,72,182,215,218,208,202,204,205,205,205,205,205,202,201,210,218,215,182,66,132,387,578,704,756,759,756,748,669,522,323,71,65,198,227,213,205,204,204,205,205,205,205,205,205,205,205,205,205,207,205,85,598,762,759,762,762,762,762,762,762,762,762],[762,762,762,762,762,762,584,147,181,210,205,205,205,205,205,205,205,205,205,205,205,205,205,202,199,210,227,211,118,62,231,440,612,723,753,759,759,725,616,440,209,74,154,209,223,208,199,205,205,202,199,210,223,205,138,67,235,459,629,734,758,759,755,732,628,458,247,63,115,209,228,212,200,204,205,205,205,205,205,205,205,205,205,205,205,205,205,207,205,85,598,762,759,762,762,762,762,762,762,762,762],[762,762,762,762,762,762,584,147,181,210,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,202,199,207,222,217,173,70,149,368,558,692,747,759,759,747,660,503,290,80,105,203,224,210,202,214,226,198,77,74,315,522,674,753,759,759,751,703,576,390,152,63,169,217,223,209,199,202,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,207,205,85,598,762,759,762,762,762,762,762,762,762,762],[762,764,762,762,762,765,586,147,181,210,205,205,205,205,205,205,205,205,205,204,202,205,205,205,205,205,205,202,202,208,216,220,203,80,58,293,499,650,742,756,762,758,696,561,366,96,66,190,222,180,64,156,394,579,707,759,762,756,747,665,517,319,67,74,197,221,216,208,202,203,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,207,205,85,598,765,759,762,762,762,762,762,762,762,762],[762,762,762,762,762,762,584,147,181,210,205,205,205,205,205,205,205,202,205,214,213,204,202,205,205,205,205,205,205,204,202,205,210,225,220,130,56,222,432,603,718,750,756,759,724,611,434,185,57,236,465,633,735,759,759,753,727,621,452,245,56,126,217,225,210,205,202,204,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,207,205,85,598,762,759,762,762,762,762,762,762,762,762],[762,762,762,762,759,762,584,147,181,210,205,205,205,205,205,205,202,207,192,130,182,217,214,202,204,205,205,205,205,205,205,205,205,202,205,222,228,169,64,147,361,547,686,745,756,759,749,651,568,677,753,759,758,750,699,568,383,161,58,161,225,225,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,205,85,598,762,759,762,762,762,762,762,762,762,762],[762,762,762,762,762,762,584,147,181,210,205,205,205,205,205,202,211,172,273,368,166,72,175,220,214,204,205,205,205,205,205,205,205,205,205,200,202,219,225,197,95,60,284,490,647,738,756,759,759,762,756,746,663,511,310,71,87,190,223,220,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,205,85,598,762,759,762,762,762,762,762,762,762,762],[762,762,762,762,762,762,584,147,181,210,205,205,205,205,205,200,225,79,340,671,645,449,184,74,176,217,213,207,202,205,205,205,205,205,205,205,205,202,205,213,222,217,146,50,210,419,613,744,762,753,635,445,232,50,139,213,222,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,205,85,598,762,759,762,762,762,762,762,762,762,762],[762,762,762,762,762,762,584,147,181,210,205,205,205,205,205,200,226,80,341,697,762,750,658,482,216,79,169,211,216,208,202,205,205,205,205,205,205,205,205,202,205,207,218,228,200,28,275,695,759,730,325,30,189,227,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,205,85,598,762,759,762,762,762,762,762,762,762,762],[762,762,762,762,762,762,584,147,181,210,205,205,205,205,205,200,226,77,352,695,762,762,762,759,679,508,261,89,156,207,219,206,201,205,205,205,205,205,205,205,205,205,202,199,231,176,310,694,759,729,351,179,230,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,207,205,85,598,762,759,762,762,762,762,762,762,762,762],[762,762,762,762,762,762,584,147,182,210,205,205,205,205,205,200,227,77,356,694,759,756,759,762,762,762,693,531,299,92,140,209,219,206,202,205,205,205,205,205,205,205,205,204,217,128,311,696,759,729,356,128,213,205,205,205,205,205,205,205,205,205,205,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,205,85,598,762,759,762,762,762,762,762,762,762,762],[762,762,762,762,762,762,584,147,181,210,205,205,205,205,205,199,229,78,364,697,759,756,760,759,759,762,762,762,706,557,335,95,131,208,213,204,205,205,205,205,205,205,205,202,218,134,308,694,759,729,351,136,216,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,205,85,598,762,759,762,762,762,762,762,762,762,762],[762,762,762,762,762,762,584,147,181,210,205,205,205,205,205,202,216,160,287,565,718,752,759,759,759,761,759,762,762,762,717,583,363,100,147,204,203,205,205,205,205,205,205,202,218,133,309,696,759,729,352,134,216,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,205,85,598,762,759,762,762,762,762,762,762,762,762],[762,762,762,762,762,762,584,147,181,210,205,205,205,205,205,205,202,211,178,178,368,569,708,747,759,759,759,762,756,762,762,762,731,604,368,186,207,205,205,205,205,205,205,202,218,133,309,696,759,729,352,134,216,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,205,85,598,762,759,762,762,762,762,762,762,762,762],[762,762,762,762,759,762,584,147,181,210,205,205,205,205,205,205,205,202,207,193,83,116,337,545,693,744,759,759,759,762,759,762,762,762,595,103,197,208,205,205,205,205,205,202,218,133,309,696,759,729,352,134,216,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,205,85,598,762,759,762,762,762,762,762,762,762,762],[762,762,762,762,762,762,584,147,181,210,205,205,205,205,205,205,205,205,205,214,223,208,90,64,305,521,677,739,756,759,759,762,753,759,595,103,197,208,205,205,205,205,205,202,218,133,309,696,759,729,352,134,216,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,205,85,598,762,759,762,762,762,762,762,762,762,762],[762,762,762,762,762,762,584,147,181,210,205,205,205,205,205,205,205,205,205,202,205,208,223,217,104,61,282,495,661,735,756,762,756,762,586,102,198,208,205,205,205,205,205,202,218,133,309,696,759,729,352,134,216,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,205,85,598,762,759,762,762,762,762,762,762,762,762],[762,762,762,762,762,762,584,147,181,210,205,205,205,205,205,205,205,205,205,205,205,205,202,206,225,220,113,62,258,468,645,730,753,762,583,100,200,208,205,205,205,205,205,202,218,133,309,696,759,729,352,134,216,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,205,85,598,762,759,762,762,762,762,762,762,762,762],[762,764,762,762,762,765,586,147,182,210,205,205,205,205,205,205,205,205,205,205,205,205,205,205,199,205,225,217,151,67,232,444,619,727,581,102,199,208,205,205,205,205,205,202,218,133,309,696,759,729,352,134,216,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,205,85,598,765,759,762,762,762,762,762,762,762,762],[762,762,762,762,762,762,584,147,181,210,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,200,207,219,220,172,65,185,443,436,162,200,207,205,205,205,205,205,202,218,133,309,696,759,729,352,134,216,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,205,85,598,762,759,762,762,762,762,762,762,762,762],[762,762,762,762,762,762,584,147,182,210,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,204,202,207,215,226,181,70,152,205,202,205,205,205,205,205,205,202,218,133,309,696,759,729,352,134,216,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,205,85,598,762,759,762,762,762,762,762,762,762,762],[762,762,762,762,762,762,584,147,182,210,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,204,202,216,226,209,202,205,205,205,205,205,205,205,202,218,133,309,696,759,729,352,134,216,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,205,85,598,762,759,762,762,762,762,762,762,762,762],[762,764,762,762,762,765,586,147,182,210,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,218,133,309,696,759,729,352,134,216,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,205,85,598,765,759,762,762,762,762,762,762,762,762],[762,764,762,762,762,765,586,147,181,210,205,205,205,205,205,205,205,205,205,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,218,133,309,696,759,729,352,134,216,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,205,85,598,765,759,762,762,762,762,762,762,762,762],[762,762,762,762,762,762,584,147,182,210,205,205,205,205,205,205,205,205,205,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,218,133,309,696,759,729,352,134,216,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,205,85,598,762,759,762,762,762,762,762,762,762,762],[762,762,762,762,762,762,584,147,181,210,205,205,205,205,205,205,205,205,205,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,218,133,309,696,759,729,352,134,216,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,205,85,598,762,759,762,762,762,762,762,762,762,762],[762,762,762,762,762,762,584,147,181,210,205,205,205,205,205,205,205,205,205,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,218,133,309,696,759,729,352,134,216,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,205,85,598,762,759,762,762,762,762,762,762,762,762],[762,762,762,762,762,762,584,147,181,210,205,205,205,205,205,205,205,205,205,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,218,133,309,696,759,729,352,134,216,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,205,85,598,762,759,762,762,762,762,762,762,762,762],[762,762,762,762,762,762,586,147,181,210,205,205,205,205,205,205,205,205,205,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,218,133,309,696,759,729,352,134,216,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,205,87,598,762,759,762,762,762,762,762,762,762,762],[762,762,762,762,761,762,586,152,182,210,205,205,205,205,205,205,205,205,205,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,218,133,309,696,759,729,352,134,216,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,208,207,97,598,762,759,762,762,762,762,762,762,762,762],[762,762,762,762,762,762,580,137,178,215,206,205,205,205,205,205,205,205,205,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,218,133,309,696,759,729,352,134,216,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,204,214,204,74,592,762,759,762,762,762,762,762,762,762,762],[762,762,762,762,759,762,630,206,104,174,202,208,205,205,205,205,205,205,205,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,218,133,309,696,759,729,352,134,216,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,210,204,186,104,168,643,762,759,762,762,762,762,762,762,762,762],[762,762,762,762,762,762,753,672,509,251,120,175,197,208,208,205,205,205,205,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,218,133,309,696,759,729,352,134,216,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,208,210,199,184,109,252,504,670,756,762,762,762,762,762,762,762,762,762,762],[762,764,762,762,762,762,762,762,759,684,526,281,131,172,194,208,208,205,205,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,218,133,309,696,759,729,352,134,216,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,204,208,210,194,180,116,274,520,683,762,762,765,762,762,762,762,762,762,762,762,762,762],[762,762,762,762,762,762,759,757,760,762,762,692,539,312,140,165,194,209,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,202,218,133,309,696,759,729,352,134,216,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,207,211,195,168,123,304,534,692,762,762,762,756,759,762,762,762,762,762,762,762,762,762,762],[762,764,762,762,762,762,762,762,759,759,762,762,765,701,555,340,145,165,196,209,207,206,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,202,218,133,309,696,759,729,352,134,216,202,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,207,205,210,197,167,125,329,549,700,762,765,762,759,759,762,764,762,762,762,762,762,762,762,762,762,762],[762,762,762,762,762,762,762,762,762,762,762,759,762,762,762,708,573,359,148,165,193,206,210,205,204,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,202,218,133,309,696,759,729,352,134,216,202,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,202,205,209,205,193,169,127,350,567,707,762,762,762,759,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762],[762,764,762,762,762,762,762,762,762,762,762,762,762,759,762,762,762,717,589,378,158,166,186,203,210,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,202,218,133,309,696,759,729,352,134,216,202,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,210,204,187,167,135,367,583,716,765,762,762,756,762,762,762,762,762,762,762,764,762,762,762,762,762,762,762,762,762],[762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,759,761,762,762,724,603,400,170,152,183,202,208,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,202,218,133,309,696,759,729,352,134,216,202,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,204,210,202,183,147,146,387,595,724,762,762,762,756,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762],[762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,761,759,762,762,762,730,614,424,179,135,182,201,208,205,205,205,205,205,205,205,205,205,205,205,205,205,205,202,218,133,309,696,759,729,352,134,216,202,205,205,205,205,205,205,205,205,205,205,205,205,205,205,208,200,185,132,153,411,606,729,762,762,762,759,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762],[762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,759,759,762,762,735,629,444,185,133,178,196,208,207,205,205,205,205,205,205,205,205,205,205,205,202,218,133,309,696,759,729,352,134,216,202,205,205,205,205,205,205,205,205,205,205,205,207,210,197,183,128,158,430,619,733,762,762,759,759,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762],[762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,759,759,759,762,741,642,463,194,138,178,193,208,207,205,205,205,205,205,205,205,205,205,202,218,133,309,696,759,729,352,134,216,202,205,205,205,205,205,205,205,205,205,207,210,193,183,135,169,448,634,741,762,762,759,759,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762],[762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,759,759,762,762,747,654,480,226,137,174,192,209,206,204,205,205,205,205,205,205,202,218,133,309,696,759,729,352,134,216,202,205,205,205,205,205,205,204,206,210,193,182,129,213,463,646,746,762,762,759,759,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762],[762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,759,759,762,762,753,663,499,260,134,179,195,207,207,206,205,205,205,205,202,218,133,309,696,759,729,352,134,216,202,205,205,205,205,206,207,208,196,185,126,243,482,654,753,762,762,759,759,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762],[762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,759,759,762,762,758,674,520,281,136,181,190,206,208,205,205,205,202,218,133,309,696,759,729,352,134,216,202,205,205,205,208,206,192,188,127,263,501,665,756,759,762,759,759,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762],[762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,759,756,762,759,759,686,537,298,143,181,186,206,209,205,202,218,134,309,696,759,729,352,134,216,202,205,208,208,187,187,135,279,518,676,759,759,762,756,759,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762],[762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,759,756,762,762,762,696,551,328,153,175,185,207,207,222,133,308,696,759,729,352,135,218,208,208,187,178,141,307,531,686,759,762,762,756,759,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762],[762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,759,759,762,762,762,703,564,356,156,172,186,220,139,311,696,759,729,353,141,220,188,175,143,332,545,694,759,762,762,759,759,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762],[762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,760,759,762,762,762,710,581,377,159,194,138,309,696,759,729,352,141,196,144,352,561,702,759,759,762,759,759,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762],[762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,759,762,762,762,718,598,403,142,299,695,759,729,345,134,376,578,709,759,759,762,756,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762],[762,764,762,762,762,764,762,762,762,762,762,762,764,762,762,762,762,762,764,762,762,762,762,762,762,764,764,762,762,762,762,762,762,762,762,762,762,762,765,762,759,762,762,765,729,597,477,710,759,732,490,581,719,759,762,762,759,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,764,762,764,762,762,762,762,764,762,764,762,762,764,764,762,762,762,762,762,762,762,762,762],[762,764,762,762,762,764,762,762,762,762,762,762,764,762,762,762,762,762,764,762,762,762,762,762,762,764,762,762,762,762,764,762,762,762,762,762,762,762,762,762,765,762,759,762,762,762,737,752,762,753,739,759,762,762,759,762,765,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,764,762,764,762,762,762,762,764,762,764,762,762,764,764,762,762,762,762,762,762,762,762,762],[762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,759,762,762,762,762,762,762,762,759,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762],[762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,759,762,762,762,759,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762],[762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762,762]]
for t in range(int(input())):
  a,b=map(int,input().split())
  print(X[a][b])
0