#P4366. Penguin Kingdom Travel Time

    ID: 17612 Type: Default 1000ms 256MiB

Penguin Kingdom Travel Time

Penguin Kingdom Travel Time

In Penguin Kingdom, there are NN cities, numbered from 11 to NN. For any two distinct cities ii and jj, a penguin can travel from ii to jj in ( (i \oplus j) \times C ) time (where ( \oplus ) denotes the bitwise XOR operation and CC is a given constant). Additionally, there are MM one-way shortcut channels. The ii-th shortcut channel runs from city FiF_i to city TiT_i and takes ViV_i time. Given two cities AA and BB, determine the minimum time required to travel from city AA to city BB.

inputFormat

The first line contains five integers: NN, MM, CC, AA, and BB. Each of the following MM lines contains three integers FiF_i, TiT_i, and ViV_i, describing a shortcut channel from city FiF_i to TiT_i with time cost ViV_i.

outputFormat

Output a single integer representing the minimum time required to travel from city AA to city BB.

sample

4 1 1 1 4
2 3 1
5

</p>