Vertex Merge Game

아직 제출이 없습니다시간 제한3초메모리 제한1024 MB

문제

Yunee is going to challenge Woongbae with a game that Yunee invented. Yunee's game is called the Vertex Merge Game and it is played on an edge-weighted connected graph. The game consists of several rounds, and each round proceeds as follows.

  1. At the start of each round, Yunee colors each vertex either red or blue. There should be at least one red vertex and one blue vertex after coloring.
  2. Yunee receives points equal to (the number of red vertices)×(the number of blue vertices)\text{(the number of red vertices)} \times \text{(the number of blue vertices)}.
  3. Woongbae selects an edge that connects a red vertex and a blue vertex.
  4. Woongbae receives points equal to the weight of the selected edge.
  5. Merge the two vertices at the ends of the selected edge. All edges are preserved after merging.

Repeat the rounds until there is only one vertex left in the graph. Then the game ends, and the person with higher total points wins the game.

Given a graph, find out who wins the game when both Yunee and Woongbae play the game optimally. Note that their goal is to win the game, not to maximize their points.

입력

The first line contains two integers NN and MM (2N100,000,1M300,000)(2\leq N \leq 100,000, 1\leq M \leq 300,000). NN is the number of vertices and MM is the number of edges.

The next MM lines describe the edges of the graph. The ii-th line contains three integers u_i,v_i,w_iu\_i, v\_i, w\_i (1u_i,v_iN,0w_i109)(1\leq u\_i, v\_i \leq N, 0 \leq w\_i \leq 10^9). It represents an edge connecting u_iu\_i and v_iv\_i with a weight w_iw\_i.

It is guaranteed that the given graph is connected.

출력

If Yunee wins, output win. If Woongbae wins, output lose. If there is a tie, output tie.