{"trustable":false,"prependHtml":"\u003cstyle type\u003d\u0027text/css\u0027\u003e\n .input, .output {\n border: 1px solid #888888;\n }\n .output {\n margin-bottom: 1em;\n position: relative;\n top: -1px;\n }\n .output pre, .input pre {\n background-color: #EFEFEF;\n line-height: 1.25em;\n margin: 0;\n padding: 0.25em;\n }\n \u003c/style\u003e\n \u003clink rel\u003d\"stylesheet\" href\u003d\"//codeforces.org/s/96598/css/problem-statement.css\" type\u003d\"text/css\" /\u003e\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 type\u003d\"text/javascript\" async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS_HTML-full\"\u003e\u003c/script\u003e","sections":[{"title":"题目解释","value":{"format":"MD","content":"定义一个字符串 $$$a$$$ 和一个正整数 $$$x$$$ 之间的乘法运算:$$$a \\cdot x$$$ 是将 $$$x$$$ 个 $$$a$$$ 串联起来的结果。例如,\"abc\" $$$\\cdot~2~\u003d$$$ \"abcabc\",\"a\" $$$\\cdot~5~\u003d$$$ \"aaaaa\"。\n\n如果存在一个整数 $$$x$$$ 使得 $$$b \\cdot x \u003d a$$$,那么我们就说字符串 $$$a$$$ 可以被另一个字符串 $$$b$$$ 整除。例如,\"abababab\" 可以被 \"ab\" 整除,但不能被 \"ababab\" 或 \"aa\" 整除。\n\n两个字符串 $$$s$$$ 和 $$$t$$$ 的最小公倍数(定义为 $$$LCM(s, t)$$$)是既可以被 $$$s$$$ 整除,也可以被 $$$t$$$ 整除的最短非空字符串。\n\n给定两个字符串 $$$s$$$ 和 $$$t$$$,找出 $$$LCM(s, t)$$$,或者报告它不存在。可以证明,如果 $$$LCM(s, t)$$$ 存在,那么它是唯一的。"}},{"title":"输入格式","value":{"format":"MD","content":"第一行包含一个整数 $$$q$$$ ($$$1 \\le q \\le 2000$$$) —— 测试用例的数量。\n\n每个测试用例由两行组成,包含字符串 $$$s$$$ 和 $$$t$$$ ($$$1 \\le |s|, |t| \\le 20$$$)。这些字符串中的每个字符都是 $$$a$$$ 或 $$$b$$$。"}},{"title":"输出格式","value":{"format":"MD","content":"对于每个测试用例,如果存在的话,打印 $$$LCM(s, t)$$$;否则,打印 $$$-1$$$。可以证明,如果 $$$LCM(s, t)$$$ 存在,它是唯一的。"}},{"title":"样例 #1","value":{"format":"MD","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003e输入\u003c/th\u003e\n \u003cth\u003e输出\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e3\nbaba\nba\naa\naaa\naba\nab\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003ebaba\naaaaaa\n-1\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"样例解释","value":{"format":"MD","content":"在第一个测试用例中,$$$\"baba\" \u003d \"baba\" ⋅ 1 \u003d \"ba\" ⋅ 2$$$。\n\n在第二个测试用例中,$$$\"aaaaaa\" \u003d \"aa\" ⋅ 3 \u003d \"aaa\" ⋅ 2$$$。"}}]}