Pizza Delivery

Given a directed weighted graph with source 1 and target 2, each day flips the direction of one distinct edge; report whether the shortest path distance shrinks, stays equal, or grows (or becomes unreachable).

Hard8GraphShortest pathDynamic programmingNo attempts yetTime limit2sMemory limit512 MB

Problem

Alyssa is a college student living in New Tsukuba City. Every street section in the city is one way. A social experiment starting tomorrow reverses one street section between two adjacent intersections each day. All other sections keep their direction, and the reversal is canceled the next day. On day ii the reversed section is section ii.

Alyssa orders a pizza every day from the same pizzeria. The pizza is delivered along the shortest route from the intersection with the pizzeria to the intersection with Alyssa's house.

Changing the traffic regulation may change the shortest route. Report how the experiment affects the delivery route on each day.

Input

The input consists of a single test case in the following format.

n m
a1 b1 c1
.
.
.
am bm cm

The first line contains two integers, nn, the number of intersections, and mm, the number of street sections in New Tsukuba City (2n1000002 \le n \le 100000, 1m1000001 \le m \le 100000). The intersections are numbered 11 through nn and the street sections are numbered 11 through mm.

The following mm lines contain the information about the street sections, each with three integers aia_i, bib_i, and cic_i (1ain1 \le a_i \le n, 1bin1 \le b_i \le n, aibia_i \ne b_i, 1ci1000001 \le c_i \le 100000). Section ii connects two intersections with the one way direction from aia_i to bib_i and has length cic_i, and it is the section reversed on day ii. More than one section may connect the same pair of intersections.

The pizzeria is on intersection 11 and Alyssa's house is on intersection 22. At least one route from the pizzeria to Alyssa's house exists before the experiment starts.

Output

Print mm lines. Line ii must be

  • HAPPY if the shortest route on day ii becomes shorter,
  • SOSO if the length of the shortest route on day ii does not change, and
  • SAD if the shortest route on day ii becomes longer, or if no route from the pizzeria to Alyssa's house remains.

Alyssa does not care whether the delivery bike can go back to the pizzeria.