""" 最初に持つ数は 1 1 x でいい 交換も一番小さいのと大きいのでいい にぶたん """ from heapq import* n, m = map(int, input().split()) edges = [[] for _ in range(n)] for _ in range(m): u, v = map(int, input().split()) u -= 1 v -= 1 edges[u].append(v) edges[v].append(u) tot = [0] * n A = [0] * n B = [0] * n C = [0] * n for i in range(n): A[i], B[i], C[i] = map(int, input().split()) tot[i] = A[i] + B[i] + C[i] def ok(x): if x + 2 <= A[0] + B[0] + C[0]: return False t = x + max(A[0], B[0], C[0]) + 1 ok = False for npos in edges[0]: if t > A[npos] + B[npos] + C[npos]: ok = True break if not ok: return False hq = [(tot[0], 0)] used = [False] * n used[0] = True a, b, c = x, 1, 1 while hq: t, pos = heappop(hq) if t >= a + b + c: return False for npos in edges[pos]: if not used[npos]: used[npos] = True heappush(hq, (tot[npos], npos)) lst = [a, b, c, A[pos], B[pos], C[pos]] lst.sort() a, b, c = lst[3:] return True l = 1 r = 3 * 10 ** 8 while r - l > 1: mid = (l + r) // 2 if ok(mid): r = mid else: l = mid print(1, 1, r)