{"trustable":true,"prependHtml":"\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027\\\\(\u0027, right: \u0027\\\\)\u0027, display: false},\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003eAfter the final BOSS is defeated, the hero found that the whole castle is collapsing (very familiar scene, isn\u0027t it). Escape from the castle is easy, just need to cross a few rooms. But as the Hero is full of adventurous spirit, he decides to \u003cb\u003evisit every room\u003c/b\u003e before he escape the castle.\u003c/p\u003e\n \u003cp\u003eThe castle is a rectangle with \u003ci\u003eN\u003c/i\u003e * \u003ci\u003eM\u003c/i\u003e rooms in it. Two rooms are connected if they share a common edge. The hero starts in the top left room. And the bottom left room is the only way out. After the hero visits a room and leaves it, it will collapse immediately(Another familiar scene). So he can visit each room \u003cb\u003eonly once\u003c/b\u003e.\u003c/p\u003e\n \u003cp\u003eThe diagram shows one tour over a castle with 4 * 10 rooms:\u003c/p\u003e\n \u003ccenter\u003e\u003cimg src\u003d\"CDN_BASE_URL/71e93e54303f8e4c45ce9b93751975cc?v\u003d1715432612\"\u003e\u003c/center\u003e\n\n\n\n\u003cp\u003e\u003cb\u003eInput\u003c/b\u003e\u003c/p\u003e\n \u003cp\u003eThere are multiply cases (\u0026lt;20), process to the end of file.\u003c/p\u003e\n \u003cp\u003eEach case contains a line with two Integer \u003ci\u003eN\u003c/i\u003e and \u003ci\u003eM\u003c/i\u003e (2 \u0026lt;\u003d \u003ci\u003eN\u003c/i\u003e \u0026lt;\u003d 7, 1 \u0026lt;\u003d \u003ci\u003eM\u003c/i\u003e \u0026lt;\u003d10^9).\u003c/p\u003e \n \n\u003cp\u003e\u003cb\u003eOuput\u003c/b\u003e\u003c/p\u003e\n \u003cp\u003eFor each case, if it\u0027s impossible to visit every room exactly once and get to the bottom left room, output \"Impossible\". Otherwise, output the number of tours as it describe above. Beacause the answer can be huge, you just need to output the answer MOD 7777777.\u003c/p\u003e\n \n\u003cp\u003e\u003cb\u003eSample Input\u003c/b\u003e\u003c/p\u003e\n\u003cpre\u003e3 2\n3 3\n4 10\n\u003c/pre\u003e\n\u003cp\u003e\u003cb\u003eSample Output\u003c/b\u003e\u003c/p\u003e\n\u003cpre\u003eImpossible\n2\n2329\n\u003c/pre\u003e\n\n"}}]}