Alone in the Cactus

아직 제출이 없습니다시간 제한2초메모리 제한256 MB

문제

Cactus is a connected undirected graph in which every edge belongs to at most one simple cycle.

You are given a cactus having nn vertices and mm edges. Each vertex of this cactus is either red, green or blue. All the vertices are numbered with sequential positive integers from 11 to nn. The examples of such graphs are shown in the figure:

Initially, you are standing at the vertex ss. Then you start to move to some adjacent vertex, which hasn't been visited before, until no such vertex exists. The choice of each eligible vertex is equiprobable. When there is no such vertex, you are stopped at some vertex tt. If tt is colored red or green --- the process is stopped. If tt is colored blue --- the process should be restarted from the vertex ss again.

You are to write the program that for given cactus computes the probability pq\frac{p}{q} that the process will be stopped when you are standing at a red vertex and outputs integer pq1mod1000000007p \cdot q^{-1} \mod 1000000007 (109+710^{9}+7). Here q1q^{-1} is a modular multiplicative inverse of an integer qq modulo 10000000071000000007.

입력

The first line of input contains three space-separated integers nn, mm and ss (2n1052 \leq n \leq 10^{5}, mn1m \geq n - 1, 1sn1 \leq s \leq n). The second line of input contains nn characters, ii-th of them denotes the color of vertex ii: 'R' denotes red, 'G' --- green and 'B' --- blue. Each of the following mm lines contains two integers u_iu\_{i}, v_iv\_{i} --- the numbers of vertices connected by the edge (1u_i,v_in1 \leq u\_{i}, v\_{i} \leq n).

It is guaranteed that the given graph is a cactus and it contains no multiple edges.

출력

The only line of output must contain one integer pq1mod109+7p \cdot q^{-1} \bmod 10^9+7. If the process is infinite, output "NaN" instead (quotes for clarity).

힌트

Both samples correspond to the image in the statement. The first sample corresponds to the left cactus and the second sample --- corresponds to the right one.