No Rest for the Wicked

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

문제

The 41st Petrozavodsk Programming Camp comes to its end. We hope that you enjoyed the last week. We will probably meet some of you at the ICPC 2020 World Finals, which is planned to be held in about a month, and there are different strategies to spend this time. One option is to train hard and solve more problems. Another possible option is, on the opposite, to clear your mind and take a good rest after all this work.

You may have probably noticed that this camp was held online. COVID-19 has changed the way we live now. It has also constrained travel possibilities a lot.

Let's say that there are nn countries (enumerate them from 11 to nn for convenience), and there are also mm bidirectional flights between them. Each country ii has three properties: a spectacularness value s_is\_i, a COVID level c_ic\_i and a security threshold t_ic_it\_i\ge c\_i. Their meaning is the following: if one wants to fly to the jj-th country, and they have ever been to the ii-th country, then c_it_jc\_i\le t\_j must hold.

Assume that a person from the ii-th country wants to visit other countries, and their goal is to go the most spectacular they can --- that is, to eventually visit a country jj with the maximal possible s_js\_j. Find this spectacularness value for each starting ii.

Note that there always is an option to stay home, so the answer always exists. For the sake of simplicity we do not require the possibility to return home after visiting the most spectacular possible country (let's say that you can always go home somehow even if there are no flights to it).

입력

The first line contains two integers nn and mm separated by space (1n,m21051\le n, m\le 2\cdot 10^5). Then nn lines follow, ii-th of them contains three space-separated integers c_ic\_i, t_it\_i, and s_is\_i (1c_i,t_i,s_i1091\le c\_i, t\_i, s\_i\le 10^9, c_it_ic\_i \leq t\_i).

The following mm lines describe edges, each of them containing two integers uu and vv (1u,vn1\le u, v\le n) and denoting a flight between uu and vv. The described graph is guaranteed to have no self-loops and no multiple edges.

출력

Print nn integers, ii-th of them being the maximal spectacularness one could see starting from the ii-th country.