{"trustable":true,"prependHtml":"\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\" type\u003d\"text/javascript\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv class\u003d\"panel_content\"\u003eFor a binary number x with n digits (A\u003csub\u003en\u003c/sub\u003eA\u003csub\u003en-1\u003c/sub\u003eA\u003csub\u003en-2\u003c/sub\u003e ... A\u003csub\u003e2\u003c/sub\u003eA\u003csub\u003e1\u003c/sub\u003e), we encode it as \u003cimg style\u003d\"max-width:100%;\" src\u003d\"CDN_BASE_URL/78e178e585bf9e54bd3812b4f9a6b808?v\u003d1714419237\"\u003e\u003cbr\u003eWhere \"\u003cimg style\u003d\"max-width:100%;\" src\u003d\"CDN_BASE_URL/e36d5e8bb9e30869b5315a49ba9258fe?v\u003d1714419237\"\u003e\" is bitwise XOR operation and \"\u003cimg style\u003d\"max-width:100%;\" src\u003d\"CDN_BASE_URL/832b7a776be0012fa3161e947b1a2173?v\u003d1714419237\"\u003e\" indicates the largest integer which is not greater than x.\u003cbr\u003eDue to some reasons, Mzry1992 encode his password P into G(P), and additionally, he encode P + 1 into G(P + 1) too, and write G(P) and G(P + 1) into his diary.\u003cbr\u003eThis story happened many years ago and now you hold the diary with these numbers in your hands. Unfortunately, some digits are unreadable now. Could you determine the values of these digits using the readable digits?\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The first line has a number T (T \u0026lt;\u003d 100) , indicating the number of test cases.\u003cbr\u003eFor every test case, it has 2 lines of same number of digits describe G(P) and G(P + 1), In every line, it only contains 1, 0 and ?. Unreadable digits are denoted with symbol ?, The length of every line in the input is up to 10\u003csup\u003e5\u003c/sup\u003e."}},{"title":"Output","value":{"format":"HTML","content":"For every case, you should output \"Case #t: \" at first, without quotes. The \u003ci\u003et\u003c/i\u003e is the case number starting from 1.\u003cbr\u003eThen, if there is impossible to restore G(P) and G(P + 1), you should output \"Impossible\" in the second line.\u003cbr\u003eOtherwise, if G(P) is unique, you should output restored G(P) and G(P +1) in the same format.\u003cbr\u003eOtherwise, you should output \"Ambiguous\" and the number of possible G(P) in the second line.\u003cbr\u003e\u003cb\u003eThe number may be very large so the answer should modulo 10^9 + 7.\u003c/b\u003e\u003cbr\u003e"}},{"title":"Sample","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e3\r\n10??\r\n10??\r\n0010\r\n0110\r\n1?01\r\n0?01\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eCase #1:\r\nAmbiguous 3\r\nCase #2:\r\n0010\r\n0110\r\nCase #3:\r\nImpossible\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Hint","value":{"format":"HTML","content":"\u003cbr\u003eIn the first sample case, the three possible situations are:\u003cbr\u003e1. \u003cbr\u003eG(12) \u003d 1010\u003cbr\u003eG(13) \u003d 1011\u003cbr\u003e2. \u003cbr\u003eG(13) \u003d 1011\u003cbr\u003eG(14) \u003d 1001\u003cbr\u003e3. \u003cbr\u003eG(14) \u003d 1001\u003cbr\u003eG(15) \u003d 1000\u003cbr\u003e"}}]}