Given is an undirected connected graph with N vertices numbered 1 to N, and M edges numbered 1 to M.
The given graph may contain multi-edges but not self loops.
Each edge has an integer label between 1 and N (inclusive).
Edge i has a label c_i, and it connects Vertex u_i and v_i bidirectionally.
Snuke will write an integer between 1 and N (inclusive) on each vertex (multiple vertices may have the same integer written on them) and then keep only the edges satisfying the condition below, removing the other edges.
Condition: Let x and y be the integers written on the vertices that are the endpoints of the edge. Exactly one of x and y equals the label of the edge.
We call a way of writing integers on the vertices good if (and only if) the graph is still connected after removing the edges not satisfying the condition above. Determine whether a good way of writing integers exists, and present one such way if it exists.

-----Constraints-----
 - 2 \leq N \leq 10^5
 - N-1 \leq M \leq 2 \times 10^5
 - 1 \leq u_i,v_i,c_i \leq N
 - The given graph is connected and has no self-loops.

-----Input-----
Input is given from Standard Input in the following format:
N M
u_1 v_1 c_1
\vdots
u_M v_M c_M

-----Output-----
If there is no good way of writing integers, print No.
Otherwise, print N lines. The i-th line should contain the integer written on Vertex i.
Any good way of writing integers will be accepted.

-----Sample Input-----
3 4
1 2 1
2 3 2
3 1 3
1 3 1

-----Sample Output-----
1
2
1

 - We write 1, 2, and 1 on Vertex 1, 2, and 3, respectively.
 - Edge 1 connects Vertex 1 and 2, and its label is 1.
 - Only the integer written on Vertex 1 equals the label, so this edge will not get removed.
 - Edge 2 connects Vertex 2 and 3, and its label is 2.
 - Only the integer written on Vertex 2 equals the label, so this edge will not be removed.
 - Edge 3 connects Vertex 1 and 3, and its label is 3.
 - Both integers written on the vertices differ from the label, so this edge will be removed.
 - Edge 4 connects Vertex 1 and 3, and its label is 1.
 - Both integers written on the vertices equal the label, so this edge will be removed.
 - After Edge 3 and 4 are removed, the graph will still be connected, so this is a good way of writing integers.

```python

USER_FILENAME = "<user_code>"
import sys, json, builtins
import math, heapq, bisect, itertools, functools, collections, statistics, fractions, decimal, operator, array, random, re, string, os, pathlib
try:
    import resource as _res
except Exception:
    _res = None
from collections import Counter, defaultdict, deque, OrderedDict
from functools import lru_cache, reduce
from itertools import accumulate, permutations, combinations, product
from math import gcd, ceil, floor, sqrt
from decimal import Decimal
try:
    from typing import *
except Exception:
    pass
try:
    sys.setrecursionlimit(1_000_000)
except Exception:
    pass
try:
    import site as _site
    try:
        _sys_sites = _site.getsitepackages() if hasattr(_site, "getsitepackages") else []
        for _p in _sys_sites:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
    try:
        _usp = _site.getusersitepackages()
        if isinstance(_usp, str):
            _usp = [_usp]
        for _p in _usp:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
except Exception:
    pass

ns = {"__name__": "__main__"}
for _k, _v in list(globals().items()):
    if not _k.startswith("_"):
        ns[_k] = _v
_CODE = "# import sys\n# sys.setrecursionlimit(10 ** 6)\n# import bisect\nfrom collections import deque\n\n\n# from decorator import stop_watch\n#\n#\n# @stop_watch\ndef solve(N, M, uvc):\n    tree_map = [[] for _ in range(N + 1)]\n    for u, v, c in uvc:\n        tree_map[u].append([v, c])\n        tree_map[v].append([u, c])\n    # [print(t) for t in tree_map]\n    ans = [0] * (N + 1)\n    visited = [False] * (N + 1)\n    visited[1] = True\n    ans[1] = 1\n    dq = deque([1])\n    while dq:\n        now = dq.popleft()\n        for child, c in tree_map[now]:\n            if visited[child]:\n                continue\n            visited[child] = True\n            if c == ans[now]:\n                ans[child] = c % N + 1\n            else:\n                ans[child] = c\n            dq.append(child)\n    [print(i) for i in ans[1:]]\n\n    # dq = deque([[1, 0, True, 0]])  # now, parent, parent is same label?, label\n    # visited[0] = True\n    # visited[1] = True\n    # while dq:\n    #     now, parent, issame, label = dq.popleft()\n    #     if not issame:\n    #         ans[now] = label\n    #     for child, c in tree_map[now]:\n    #         if visited[child]:\n    #             continue\n    #         visited[child] = True\n    #         if issame and ans[now] == 0 and c != label:\n    #             ans[now] = c\n    #         dq.append([child, now, ans[now] == c, c])\n    #     if ans[now] == 0:\n    #         ans[now] = label % N + 1\n    # [print(i) for i in ans[1:]]\n\n    # # check\n    # check = [1] * (N + 1)\n    # check[0] = 0\n    # new_map = [[] for _ in range(N + 1)]\n    # for u, v, c in uvc:\n    #     if (ans[u] == c) ^ (ans[v] == c):\n    #         new_map[u].append(v)\n    #         new_map[v].append(u)\n    # dq = deque([1])\n    # while dq:\n    #     now = dq.popleft()\n    #     check[now] = 0\n    #     for nxt in new_map[now]:\n    #         if check[nxt] == 0:\n    #             continue\n    #         dq.append(nxt)\n    # if sum(check) > 0:\n    #     print('wrong')\n\n\ndef __starting_point():\n    N, M = map(int, input().split())\n    uvc = [[int(i) for i in input().split()] for _ in range(M)]\n    solve(N, M, uvc)\n\n    # # test\n    # from random import randint\n    # from func import random_str, random_ints\n    #\n    # N = 4\n    # M = 2 * N\n    #\n    #\n    # def trial():\n    #     a, b = 0, 0\n    #     while a == b:\n    #         a, b = randint(1, N), randint(1, N)\n    #     return a, b, randint(1, N)\n    #\n    # cnt = 0\n    # while True:\n    #     uvc = [[i, i % N + 1, randint(1, N)] for i in range(1, N + 1)] + \\\n    #           [trial() for _ in range(randint(0, N))]\n    #     solve(N, M, uvc)\n    #     cnt += 1\n    #     # if cnt % 10 == 0:\n    #     #     print(cnt)\n\n__starting_point()"
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 13971