Just One More Tunnel (Easy)


The MAPS design team is preparing the Olympic fencing venue map. Room 11 is the warm-up room, room nn is the final piste, and the team needs the fastest simple route between them before the bout begins.

The venue has nn rooms and mm ordinary corridors. Each corridor connects two different rooms, can be used in both directions, and takes a positive number of seconds to traverse. There is at most one ordinary corridor between any pair of rooms.

Some rooms are marked as shortcut rooms. Between any two different shortcut rooms, MAPS has drawn a hidden referee tunnel that can be used in either direction in exactly tt seconds. Tunnel times are nonnegative: t=0t=0 is allowed and means that moving through a tunnel takes no time.

The fencer must move from room 11 to room nn without visiting any room more than once. Find the minimum possible total time. If no such route exists, output Impossible.

Input

The first line contains three integers nn, mm, and tt (2≤n≤1032 \leq n \leq 10^3, 1≤m≤1031 \leq m \leq 10^3, 0≤t≤1060 \leq t \leq 10^6).

The second line contains a binary string of length nn. Its ii-th character is 1 if room ii is a shortcut room, and 0 otherwise.

Each of the next mm lines contains three integers uiu_i, viv_i, and wiw_i (1≤ui,vi≤n1 \leq u_i, v_i \leq n, ui≠viu_i \neq v_i, 1≤wi≤1061 \leq w_i \leq 10^6), meaning there is an ordinary corridor between rooms uiu_i and viv_i that takes wiw_i seconds.

It is guaranteed that no ordinary corridor connects a room to itself, and there is at most one ordinary corridor between any two rooms.

Output

Print the minimum possible total time, or Impossible if no valid route exists.

Example 1

Input 1
3 2 3
101
1 2 2
2 3 2
Output 1
3

Example 2

Input 2
4 4 0
0110
1 2 2
2 3 2
3 4 2
1 4 9
Output 2
4

Example 3

Input 3
4 2 10
1000
1 2 1
2 3 1
Output 3
Impossible

Comments0


No comments yet

Be the first to comment.

New comment


Log in to join the discussion.