Reconstructive Surgery


Submit solution

Points: 1
Time limit: 1.5s
Memory limit: 256M

Author:
Problem type
Allowed languages
C, C++, Java, Python, Rust

Due to an unfortunate incident with a pack of koalas around the Amber's Gully Walking Trail, all of Jamie's organs were destroyed. Dr. Ritisha just finished making Jamie some new ones, and now she needs to construct some veins to connect them.

Dr. Ritisha has made Jamie n new organs, numbered 1 to n. Now, there are m possible veins she can construct, where each vein connects two distinct organs and has an integer length. No vein connects an organ to itself, and no two veins connect the same pair of organs.

Dr. Ritisha needs to pick a set of veins so that blood can flow between every pair of organs, directly or through other organs. More formally, she wants to choose veins so that the organs become part of one connected component, i.e. the resulting graph is connected.

Among all sets of veins that achieve this, Dr. Ritisha wants one whose total vein length is as small as possible. Call such a set a "plan".

There may be many possible plans. For each of the m veins, determine whether it appears in all plans, in some plans but not all, or in no plan at all.

Input

The first line contains two integers n and m (2 \leq n \leq 10^5, n - 1 \leq m \leq \min\left(\frac{n(n-1)}{2},\, 2 \times 10^5\right)), the number of organs and the number of veins Dr. Ritisha can choose from.

The next m lines each contain three integers a_i, b_i and w_i (1 \le a_i, b_i \le n, a_i \ne b_i, 1 \le w_i \le 10^9), indicating that a vein of length w_i can be built between organs a_i and b_i. No two veins connect the same pair of organs.

It is guaranteed that the n organs can all be connected using the available veins.

Output

For each vein, in the order they are given in the input, output all if the vein appears in all plans, some if it appears in some plans (but not all), and none if it appears in no plans. Each output should be on a separate line.

Example

Input 1
7 10
7 2 8
2 3 2
2 1 1
7 1 5
1 3 2
7 6 3
3 4 4
1 5 3
6 5 4
5 4 4
Output 1
none
some
all
none
some
all
some
all
all
some

Ritisha has 10 veins available to connect the 7 organs.

The smallest total vein length required to connect all the organs is 17. There are 4 valid plans that achieve this, using the veins in various ways.

The veins (2, 1), (7, 6), (1, 5), and (6, 5) appear in every plan, so their outputs are all. Each plan chooses one of (2, 3) and (1, 3) to connect organ 3, and one of (3, 4) and (5, 4) to connect organ 4, so these veins have output some. The remaining two veins are never used in a plan, so their outputs are none.

Input 2
6 8
1 2 1
2 3 1
1 3 1
1 4 10
4 5 1
5 6 1
4 6 1
2 5 100
Output 2
some
some
some
all
some
some
some
none
Input 3
6 8
1 2 1
1 3 2
1 4 2
1 5 2
2 3 1
2 4 1
4 5 1
5 6 2
Output 3
all
none
none
none
all
all
all
all

Comments

There are no comments at the moment.