{"trustable":true,"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":"HTML","content":"\u003cp\u003eLet\u0027s define a multiplication operation between a string $$$a$$$ and a positive integer $$$x$$$: $$$a \\cdot x$$$ is the string that is a result of writing $$$x$$$ copies of $$$a$$$ one after another. For example, \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eabc\u003c/span\u003e\" $$$\\cdot~2~\u003d$$$ \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eabcabc\u003c/span\u003e\", \"\u003cspan class\u003d\"tex-font-style-tt\"\u003ea\u003c/span\u003e\" $$$\\cdot~5~\u003d$$$ \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eaaaaa\u003c/span\u003e\".\u003c/p\u003e\u003cp\u003eA string $$$a$$$ is divisible by another string $$$b$$$ if there exists an integer $$$x$$$ such that $$$b \\cdot x \u003d a$$$. For example, \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eabababab\u003c/span\u003e\" is divisible by \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eab\u003c/span\u003e\", but is not divisible by \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eababab\u003c/span\u003e\" or \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eaa\u003c/span\u003e\".\u003c/p\u003e\u003cp\u003eLCM of two strings $$$s$$$ and $$$t$$$ (defined as $$$LCM(s, t)$$$) is the shortest non-empty string that is divisible by both $$$s$$$ and $$$t$$$.\u003c/p\u003e\u003cp\u003eYou are given two strings $$$s$$$ and $$$t$$$. Find $$$LCM(s, t)$$$ or report that it does not exist. It can be shown that if $$$LCM(s, t)$$$ exists, it is unique.\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eThe first line contains one integer $$$q$$$ ($$$1 \\le q \\le 2000$$$) — the number of test cases.\u003c/p\u003e\u003cp\u003eEach test case consists of two lines, containing strings $$$s$$$ and $$$t$$$ ($$$1 \\le |s|, |t| \\le 20$$$). Each character in each of these strings is either \u0027\u003cspan class\u003d\"tex-font-style-tt\"\u003ea\u003c/span\u003e\u0027 or \u0027\u003cspan class\u003d\"tex-font-style-tt\"\u003eb\u003c/span\u003e\u0027.\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003eFor each test case, print $$$LCM(s, t)$$$ if it exists; otherwise, print \u003cspan class\u003d\"tex-font-style-tt\"\u003e-1\u003c/span\u003e. It can be shown that if $$$LCM(s, t)$$$ exists, it is unique.\u003c/p\u003e"}},{"title":"Examples","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\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":"Note","value":{"format":"HTML","content":"\u003cp\u003eIn the first test case, \"\u003cspan class\u003d\"tex-font-style-tt\"\u003ebaba\u003c/span\u003e\" \u003d \"\u003cspan class\u003d\"tex-font-style-tt\"\u003ebaba\u003c/span\u003e\" $$$\\cdot~1~\u003d$$$ \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eba\u003c/span\u003e\" $$$\\cdot~2$$$.\u003c/p\u003e\u003cp\u003eIn the second test case, \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eaaaaaa\u003c/span\u003e\" \u003d \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eaa\u003c/span\u003e\" $$$\\cdot~3~\u003d$$$ \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eaaa\u003c/span\u003e\" $$$\\cdot~2$$$.\u003c/p\u003e"}}]}