{"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\u003eMr. Lawrence is a traveling merchant who travels between cities and resells products. Basically, to earn from it, he needs to buy products at a very low price and sell them at a higher price. Your task is to tell him whether there exists an endless traveling path that can earn money all the time.\u003c/p\u003e\u003cp\u003eTo make things simple, suppose there are $$$n$$$ cities named from $$$0$$$ to $$$n-1$$$ and $$$m$$$ undirected roads each of which connecting two cities. Mr. Lawrence can travel between cities along the roads. Initially he is located at city $$$0$$$ and each of the city $$$i$$$ has a starting price $$$c_i$$$, either $$$\\text{Low}$$$ or $$$\\text{High}$$$. Due to the law of markets, the price status at city $$$i$$$ will change (i.e. $$$\\text{High}$$$ price will become $$$\\text{Low}$$$ price, or vice versa) after he departs for a neighboring city $$$j$$$ from $$$i$$$. (City $$$j$$$ is a neighboring city of city $$$i$$$ when one of the $$$m$$$ roads connects city $$$i$$$ and city $$$j$$$.) For some reasons (e.g. product freshness, traveling fee, tax), he \u003cspan class\u003d\"tex-font-style-bf\"\u003emust\u003c/span\u003e: \u003c/p\u003e\u003col\u003e \u003cli\u003e Start at city $$$0$$$ and buy products at city $$$0$$$. It is guaranteed that $$$c_0$$$ is $$$\\text{Low}$$$. \u003c/li\u003e\u003cli\u003e When he arrives some city, he either sells products or buys products. It is not allowed for him to do nothing before he leaves the city. \u003c/li\u003e\u003cli\u003e After buying products at some city $$$i$$$, he must travel to some neighboring city $$$j$$$ whose price $$$c_j$$$ is $$$\\text{High}$$$ and sell the products at city $$$j$$$. \u003c/li\u003e\u003cli\u003e After selling products at some city $$$i$$$, he must travel to some neighboring city $$$j$$$ whose price $$$c_j$$$ is $$$\\text{Low}$$$ and buy the products at city $$$j$$$. \u003c/li\u003e\u003c/ol\u003e As a result, the path will look like an alternation between \"buy at low price\" and \"sell at high price\".\u003cp\u003eAn endless earning path is defined as a path consisting of an endless sequence of cities $$$p_0, p_1,...$$$ where city $$$p_i$$$ and city $$$p_{i+1}$$$ has a road, $$$p_0\u003d0$$$, and the price alternates, in other words $$$c_{p_{2k}}\u003d\\text{Low}$$$ (indicates a buy-in) and $$$c_{p_{2k+1}}\u003d\\text{High}$$$ (indicates a sell-out) for $$$k\\geq0$$$. Please note here $$$c_{p_i}$$$ is the price when \u003cspan class\u003d\"tex-font-style-bf\"\u003earriving\u003c/span\u003e city $$$p_i$$$ and this value may be different when he arrives the second time.\u003c/p\u003e\u003cp\u003eYour task is to determine whether there exists any such path.\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eThere are several test cases. The first line contains a positive integer $$$T$$$ indicating the number of test cases. Each test case begins with two positive integers $$$n$$$ and $$$m$$$ indicating the number of cities and the number of roads. \u003c/p\u003e\u003cp\u003eThe next line is a string $$$c$$$ of length $$$n$$$ containing \u0027H\u0027 or \u0027L\u0027. The $$$i$$$-th ($$$0\\le i\u0026lt;n$$$) charactor of $$$c$$$ is $$$H$$$ if the starting price $$$c_i$$$ at city $$$i$$$ is $$$\\text{High}$$$. The $$$i$$$-th ($$$0\\le i\u0026lt;n$$$) charactor of $$$c$$$ is $$$L$$$ if the starting price $$$c_i$$$ at city $$$i$$$ is $$$\\text{Low}$$$. \u003c/p\u003e\u003cp\u003eThe $$$i$$$-th line ($$$1\\le i\\le m$$$) of the following $$$m$$$ lines contains two different cities $$$u_i$$$ and $$$v_i$$$, indicating a road between $$$u_i$$$ and $$$v_i$$$.\u003c/p\u003e\u003cp\u003eThe sum of the values of $$$n$$$ over all test cases is no more than $$$200,000$$$. The sum of the values of $$$m$$$ over all test cases is no more than $$$200,000$$$. For each test case, $$$c_i\\in\\{\\text{H},\\text{L}\\}$$$ holds for each $$$i\\in \\{0, \\ldots, n-1\\}$$$. $$$c_0$$$ is always $$$L$$$. $$$0\\leq u_i,v_i\u0026lt;n$$$ and $$$u_i\\neq v_i$$$ hold for each $$$i\\in \\{1,\\ldots, m\\}$$$. No two roads connect the same pair of cities.\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003eFor each test case, output a line of \"yes\" or \"no\", indicating whether there exists an endless earning path.\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\u003e2\n4 4\nLHLH\n0 1\n1 2\n1 3\n2 3\n3 3\nLHH\n0 1\n0 2\n1 2\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eyes\nno\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 sample test case, the endless earning path is $$$0\\rightarrow 1\\rightarrow 2\\rightarrow 3\\rightarrow 1\\rightarrow 2\\rightarrow 3\\rightarrow \\dots$$$. In the illustration, cities with $$$\\text{Low}$$$ price are filled with stripe.\u003c/p\u003e\u003ccenter\u003e \u003cimg class\u003d\"tex-graphics\" height\u003d\"151px\" src\u003d\"CDN_BASE_URL/b9a19d534b37067eba0b4f887547d1f2?v\u003d1726303394\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\"\u003e \u003c/center\u003e\u003cp\u003eIn the second sample test case, Mr. Lawrence can only make one move from city $$$0$$$ and after that all cities will have $$$\\text{High}$$$ price. Thus, no further moves can be made.\u003c/p\u003e\u003ccenter\u003e \u003cimg class\u003d\"tex-graphics\" height\u003d\"189px\" src\u003d\"CDN_BASE_URL/8953ef8163b3a2ad2bd8bc2ac9ccf858?v\u003d1726303394\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\"\u003e \u003c/center\u003e"}}]}