402580: GYM100812 G Short Path

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

G. Short Pathtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

In my opinion, people are divided into two categories: some live in the future while others — in the past. Should it be explained what category did I belong? The mystery I hunted for a half of my life, finally was taking shape. Good Magician didn't know where Dragon hid. But he knew that bandit dens in some cities of the kingdom were controlled by people from the Dragon's gang. For each city he gave me a reliable information, whether Dragon controlled that city or not.

I was staring on the map of Fairy Kingdom trying to understand where to go now. There were n cities in the Kingdom, connected by m roads, with the length of the j-th road equal to wj. I guessed that Dragon hid in one of two cities controlled by his gang with the shortest path between them. First of all, the traffic of Blue Tea was the highest between them, and secondly, in case of emergency it was possible to move quickly from one of the cities to the other. All that remained was just to find such pair of cities.

Input

The first line contains two integers separated by a space: n and m (2 ≤ n ≤ 105, 1 ≤ m ≤ 105) — the number of cities in Fairy Kingdom and the number of roads between them, correspondingly.

The second line contains n integers separated by spaces. On the i-th position the number 1 is written, if the i-th city is under control of Dragon's gang; otherwise the number 0 is written there.

The next m lines contain three integers each, separated by spaces: ai, bi, wi (1 ≤ ai < bi ≤ n, 1 ≤ wi ≤ 109) — the numbers of cities connected by a road and the length of this road. The cities are numbered from 1. Each pair of cities is presented at most once.

Output

In the first line output a single integer — the length of the shortest path between cities where Dragon presumably hides.

In the second line output two integers separated by a space — the numbers of these cities.

If there are several possible answers, output any of them. If no two cities controlled by Dragon's people have a path between them, output «No luck at all» without quotes.

ExamplesInput
4 4
1 0 0 1
1 2 1
1 3 2
2 4 3
3 4 1
Output
3
4 1
Input
7 9
1 0 1 1 0 0 1
1 2 5
1 4 100
2 3 5
2 5 4
2 6 4
3 7 100
4 5 2
6 7 2
5 6 3
Output
7
4 7
Input
2 1
0 0
1 2 1
Output
No luck at all

加入题单

算法标签: