시간 제한메모리 제한제출정답맞은 사람정답 비율
4 초 512 MB111100.000%

문제

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 $n$ countries (enumerate them from $1$ to $n$ for convenience), and there are also $m$ bidirectional flights between them. Each country $i$ has three properties: a spectacularness value $s_i$, a COVID level $c_i$ and a security threshold $t_i\ge c_i$. Their meaning is the following: if one wants to fly to the $j$-th country, and they have ever been to the $i$-th country, then $c_i\le t_j$ must hold.

Assume that a person from the $i$-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 $j$ with the maximal possible $s_j$. Find this spectacularness value for each starting $i$.

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 $n$ and $m$ separated by space ($1\le n, m\le 2\cdot 10^5$). Then $n$ lines follow, $i$-th of them contains three space-separated integers $c_i$, $t_i$, and $s_i$ ($1\le c_i, t_i, s_i\le 10^9$, $c_i \leq t_i$).

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

출력

Print $n$ integers, $i$-th of them being the maximal spectacularness one could see starting from the $i$-th country.

예제 입력 1

4 3
2 3 1
1 1 4
1 2 2
1 1 3
1 2
1 3
1 4

예제 출력 1

2 4 2 3