{"raw_statement":[{"iden":"problem statement","content":"You are given an undirected graph consisting of $N$ vertices and $M$ edges. The vertices are numbered $1$ to $N$, and the edges are numbered $1$ to $M$. In addition, each vertex has a label, `A` or `B`. The label of Vertex $i$ is $s_i$. Edge $i$ bidirectionally connects vertex $a_i$ and $b_i$.\nThe phantom thief Nusook likes to choose some vertex as the startpoint and traverse an edge zero or more times. Today, he will make a string after traveling as above, by placing the labels of the visited vertices in the order visited, beginning from the startpoint.\nFor example, in a graph where Vertex $1$ has the label `A` and Vertex $2$ has the label `B`, if Nusook travels along the path $1 \\rightarrow 2 \\rightarrow 1 \\rightarrow 2 \\rightarrow 2$, the resulting string is `ABABB`.\nDetermine if Nusook can make all strings consisting of `A` and `B`."},{"iden":"constraints","content":"*   $2 \\leq N \\leq 2 \\times 10^{5}$\n*   $1 \\leq M \\leq 2 \\times 10^{5}$\n*   $|s| = N$\n*   $s_i$ is `A` or `B`.\n*   $1 \\leq a_i, b_i \\leq N$\n*   The given graph may NOT be simple or connected."},{"iden":"input","content":"Input is given from Standard Input in the following format:\n\n$N$ $M$\n$s$\n$a_1$ $b_1$\n$:$\n$a_{M}$ $b_{M}$"},{"iden":"sample input 1","content":"2 3\nAB\n1 1\n1 2\n2 2"},{"iden":"sample output 1","content":"Yes\n\n*   Since Nusook can visit Vertex $1$ and Vertex $2$ in any way he likes, he can make all strings consisting of `A` and `B`.\n\n![image](https://img.atcoder.jp/agc027/77e96cf8e213d606ddd8f3c3f8315d32.png)"},{"iden":"sample input 2","content":"4 3\nABAB\n1 2\n2 3\n3 1"},{"iden":"sample output 2","content":"No\n\n*   For example, Nusook cannot make `BB`.\n*   The given graph may not be connected.\n\n![image](https://img.atcoder.jp/agc027/1ab1411cb9d6ee023d14ca4e77c4b584.png)"},{"iden":"sample input 3","content":"13 23\nABAAAABBBBAAB\n7 1\n10 6\n1 11\n2 10\n2 8\n2 11\n11 12\n8 3\n7 12\n11 2\n13 13\n11 9\n4 1\n9 7\n9 6\n8 13\n8 6\n4 10\n8 7\n4 3\n2 1\n8 12\n6 9"},{"iden":"sample output 3","content":"Yes"},{"iden":"sample input 4","content":"13 17\nBBABBBAABABBA\n7 1\n7 9\n11 12\n3 9\n11 9\n2 1\n11 5\n12 11\n10 8\n1 11\n1 8\n7 7\n9 10\n8 8\n8 12\n6 2\n13 11"},{"iden":"sample output 4","content":"No"}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}