CSES - HIIT Open 2019 - HIIT Speedrun
  • Time limit: 1.00 s
  • Memory limit: 512 MB

You are playing a game that consists of nn rooms and mm tunnels between them. Each room has a letter that you can collect.

Your task is to move from room 11 to room nn and collect one letter H, two letters I and one letter T during your journey. You can collect the letters in any order. What is the minimum length of such a path?

Input

The first input line has two integers nn and mm: the number of rooms and tunnels. The rooms are numbered 1,2,,n1,2,\dots,n.

The second line has nn characters c1c2cnc_1 c_2 \dots c_n: the letter (A–Z) in each room.

Finally, there are mm lines that describe the tunnels. Each line has two integers aa and bb: there is a tunnel between rooms aa and bb.

Output

Print one integer: the minimum length of a valid path from room 11 to room nn. If there is no such path, print "IMPOSSIBLE".

Constraints

  • 1n1001 \le n \le 100
  • 0m50000 \le m \le 5000

Example 1

Input:

5 6
ITHXI
1 2
1 3
1 4
3 4
3 5
4 5

Output:

4

Explanation: An optimal path is 121351 \rightarrow 2 \rightarrow 1 \rightarrow 3 \rightarrow 5.

Example 2

Input:

3 2
HIT
1 2
2 3

Output:

IMPOSSIBLE

Explanation: Only one letter I is available, so you can't win the game.