Breadth First Search 0-1#10056

Breadth First Search 0-1

3 seconds
128 megabytes
Very easy

An undirected graph is given. The weight of its edges can be or only. Find the shortest distance between vertices and .

Input

The first line contains four integers: the number of vertices , the number of edges m~(n, m \le 10^5), and the vertex numbers and d~(1 \le s, d \le n). Each of the following lines contains three integers , , and , representing an undirected edge with an integer weight w~(0 \le w \le 1).

Output

Print the shortest distance between vertices and .

Examples

Example 1

Loading
Loading