##### Woburn Challenge 2018-19 Round 4 - Senior Division

Billy, the king of video games, is (among other things) a top
professional *StarCraft II* player. In light of his recent success as
the only human to defeat the fearsome AlphaStar AI, he has received
exclusive access to play the upcoming installment in the series, *World
of StarCraft*. In a natural progression for the series, this is a
massively multiplayer online role-playing game.

*World of StarCraft* features planets,
numbered from 1 to . Each planet is under the control of one of three
races (Protoss, Terran, or Zerg), with the character
representing planet 's race (either `P`

for Protoss, `T`

for
Terran, or `Z`

for Zerg).

There are space routes running amongst the planets, with the -th space route allowing one to travel in either direction between planets and . There may be multiple space routes connecting a single pair of planets.

Despite its secretive and unreleased development status, *World of
StarCraft* somehow already has an enormous player-base. Billy himself
has friends in the game. His -th friend
is currently on planet , and would like to reach a different
planet to complete an objective .

When a player is on a planet , they may travel along a space route to another planet , assuming that a space route exists which connects planets and . However, due to open hostilities amongst the three races, it's only safe to do so if both planets are under the control of the same race (in other words, if ).

Billy would love to help all of his friends complete their objectives, but not without putting their in-game lives at risk! Help him determine how many friends i he has such that it's possible to safely travel through a sequence of planets beginning at planet and ending at planet .

#### Subtasks

In test cases worth of the points, , , and .

#### Input Specification

The first line of input consists of three space-separated integers, ,
, and .

The next line consists of characters, .

lines follow, the -th of which consists of two space-separated
integers, and , for .

lines follow, the -th of which consists of two space-separated
integers, and , for .

#### Output Specification

Output a single integer, the number of friends who can safely complete their objectives.

#### Sample Input

```
6 7 3
PZZPPP
1 2
6 4
3 4
2 5
5 6
1 4
4 2
6 4
2 3
1 5
```

#### Sample Output

`2`

#### Sample Explanation

Billy's first friend can safely travel directly from planet to planet to complete their objective.

Billy's second friend may never safely reach planet .

Billy's third friend can safely travel through the sequence of planets .

## Comments