{"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\n\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027$$$$$$\u0027, right: \u0027$$$$$$\u0027, display: true},\n {left: \u0027$$$\u0027, right: \u0027$$$\u0027, display: false},\n {left: \u0027$$\u0027, right: \u0027$$\u0027, display: true},\n {left: \u0027$\u0027, right: \u0027$\u0027, display: false}\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003eYou are given a string $$$s$$$ consisting of lowercase letters of the English alphabet. You must perform the following algorithm on $$$s$$$:\u003c/p\u003e\u003cul\u003e \u003cli\u003e Let $$$x$$$ be the length of the longest prefix of $$$s$$$ which occurs somewhere else in $$$s$$$ as a contiguous substring (the other occurrence may also intersect the prefix). If $$$x \u003d 0$$$, break. Otherwise, remove the first $$$x$$$ characters of $$$s$$$, and repeat. \u003c/li\u003e\u003c/ul\u003e\u003cp\u003eA prefix is a string consisting of several first letters of a given string, without any reorders. An empty prefix is also a valid prefix. For example, the string \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eabcd\u003c/span\u003e\" has 5 prefixes: empty string, \"\u003cspan class\u003d\"tex-font-style-tt\"\u003ea\u003c/span\u003e\", \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eab\u003c/span\u003e\", \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eabc\u003c/span\u003e\" and \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eabcd\u003c/span\u003e\".\u003c/p\u003e\u003cp\u003eFor instance, if we perform the algorithm on $$$s \u003d$$$ \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eabcabdc\u003c/span\u003e\", \u003c/p\u003e\u003cul\u003e \u003cli\u003e Initially, \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eab\u003c/span\u003e\" is the longest prefix that also appears somewhere else as a substring in $$$s$$$, so $$$s \u003d$$$ \"\u003cspan class\u003d\"tex-font-style-tt\"\u003ecabdc\u003c/span\u003e\" after $$$1$$$ operation. \u003c/li\u003e\u003cli\u003e Then, \"\u003cspan class\u003d\"tex-font-style-tt\"\u003ec\u003c/span\u003e\" is the longest prefix that also appears somewhere else as a substring in $$$s$$$, so $$$s \u003d$$$ \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eabdc\u003c/span\u003e\" after $$$2$$$ operations. \u003c/li\u003e\u003cli\u003e Now $$$x\u003d0$$$ (because there are no non-empty prefixes of \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eabdc\u003c/span\u003e\" that also appear somewhere else as a substring in $$$s$$$), so the algorithm terminates. \u003c/li\u003e\u003c/ul\u003e\u003cp\u003eFind the final state of the string after performing the algorithm.\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eThe first line contains a single integer $$$t$$$ ($$$1 \\le t \\le 10^4$$$) — the number of test cases.\u003c/p\u003e\u003cp\u003eThis is followed by $$$t$$$ lines, each containing a description of one test case. Each line contains a string $$$s$$$. The given strings consist only of lowercase letters of the English alphabet and have lengths between $$$1$$$ and $$$2 \\cdot 10^5$$$ inclusive.\u003c/p\u003e\u003cp\u003eIt is guaranteed that the sum of the lengths of $$$s$$$ over all test cases does not exceed $$$2 \\cdot 10^5$$$.\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003eFor each test case, print a single line containing the string $$$s$$$ after executing the algorithm. It can be shown that such string is non-empty.\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\u003e6\nabcabdc\na\nbbbbbbbbbb\ncodeforces\ncffcfccffccfcffcfccfcffccffcfccf\nzyzyzwxxyyxxyyzzyzzxxwzxwywxwzxxyzzw\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eabdc\na\nb\ndeforces\ncf\nxyzzw\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\u003eThe first test case is explained in the statement.\u003c/p\u003e\u003cp\u003eIn the second test case, no operations can be performed on $$$s$$$.\u003c/p\u003e\u003cp\u003eIn the third test case, \u003c/p\u003e\u003cul\u003e \u003cli\u003e Initially, $$$s \u003d$$$ \"\u003cspan class\u003d\"tex-font-style-tt\"\u003ebbbbbbbbbb\u003c/span\u003e\". \u003c/li\u003e\u003cli\u003e After $$$1$$$ operation, $$$s \u003d$$$ \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eb\u003c/span\u003e\". \u003c/li\u003e\u003c/ul\u003e\u003cp\u003eIn the fourth test case, \u003c/p\u003e\u003cul\u003e \u003cli\u003e Initially, $$$s \u003d$$$ \"\u003cspan class\u003d\"tex-font-style-tt\"\u003ecodeforces\u003c/span\u003e\". \u003c/li\u003e\u003cli\u003e After $$$1$$$ operation, $$$s \u003d$$$ \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eodeforces\u003c/span\u003e\". \u003c/li\u003e\u003cli\u003e After $$$2$$$ operations, $$$s \u003d$$$ \"\u003cspan class\u003d\"tex-font-style-tt\"\u003edeforces\u003c/span\u003e\". \u003c/li\u003e\u003c/ul\u003e"}}]}