There is a simple undirected graph with N vertices and M edges.
The vertices are numbered 1 through N, and the edges are numbered 1 through M.
Edge i connects Vertex U_i and V_i.
Also, Vertex i has two predetermined integers A_i and B_i.
You will play the following game on this graph.
First, choose one vertex and stand on it, with W yen (the currency of Japan) in your pocket.
Here, A_s \leq W must hold, where s is the vertex you choose.
Then, perform the following two kinds of operations any number of times in any order:
 - Choose one vertex v that is directly connected by an edge to the vertex you are standing on, and move to vertex v. Here, you need to have at least A_v yen in your pocket when you perform this move.
 - Donate B_v yen to the vertex v you are standing on. Here, the amount of money in your pocket must not become less than 0 yen.
You win the game when you donate once to every vertex.
Find the smallest initial amount of money W that enables you to win the game.

-----Constraints-----
 - 1 \leq N \leq 10^5
 - N-1 \leq M \leq 10^5
 - 1 \leq A_i,B_i \leq 10^9
 - 1 \leq U_i < V_i \leq N
 - The given graph is connected and simple (there is at most one edge between any pair of vertices).

-----Input-----
Input is given from Standard Input in the following format:
N M
A_1 B_1
A_2 B_2
:
A_N B_N
U_1 V_1
U_2 V_2
:
U_M V_M

-----Output-----
Print the smallest initial amount of money W that enables you to win the game.

-----Sample Input-----
4 5
3 1
1 2
4 1
6 2
1 2
2 3
2 4
1 4
3 4

-----Sample Output-----
6

If you have 6 yen initially, you can win the game as follows:
 - Stand on Vertex 4. This is possible since you have not less than 6 yen.
 - Donate 2 yen to Vertex 4. Now you have 4 yen.
 - Move to Vertex 3. This is possible since you have not less than 4 yen.
 - Donate 1 yen to Vertex 3. Now you have 3 yen.
 - Move to Vertex 2. This is possible since you have not less than 1 yen.
 - Move to Vertex 1. This is possible since you have not less than 3 yen.
 - Donate 1 yen to Vertex 1. Now you have 2 yen.
 - Move to Vertex 2. This is possible since you have not less than 1 yen.
 - Donate 2 yen to Vertex 2. Now you have 0 yen.
If you have less than 6 yen initially, you cannot win the game. Thus, the answer is 6.

```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 = 'class dsu:\n    def __init__(self, n=0):\n        self._n = n\n        self.parent_or_size = [-1] * n\n    \n    def merge(self, a: int, b: int) -> int:\n        x = self.leader(a)\n        y = self.leader(b)\n        if x == y:\n            return x\n        if self.parent_or_size[x] > self.parent_or_size[y]:\n            x, y = y, x\n        self.parent_or_size[x] += self.parent_or_size[y]\n        self.parent_or_size[y] = x\n        return x\n    \n    def same(self, a: int, b: int) -> bool:\n        return self.leader(a) == self.leader(b)\n    \n    def leader(self, a: int) -> int:\n        x = a\n        while self.parent_or_size[x] >= 0:\n            x = self.parent_or_size[x]\n        while a != x:\n            self.parent_or_size[a], a = x, self.parent_or_size[a]\n        return x\n    \n    def size(self, a: int) -> int:\n        return -self.parent_or_size[self.leader(a)]\n    \n    def groups(self):\n        g = [[] for _ in range(self._n)]\n        for i in range(self._n):\n            g[self.leader(i)].append(i)\n        return list(c for c in g if c)\n\nn, m = list(map(int, input().split()))\nvdata = [] # (required, gain)\nfor _ in range(n):\n    a, b = list(map(int, input().split()))\n    vdata.append((max(a - b, 0), b))\nto = [[] for _ in range(n)]\nfor _ in range(m):\n    u, v = list(map(int, input().split()))\n    u -= 1; v -= 1\n    to[u].append(v)\n    to[v].append(u)\ns = dsu(n)\ndp = vdata.copy() # (extra, tot_gain)\nvisited = [False] * n\nfor u in sorted(list(range(n)), key=lambda i: vdata[i][0]):\n    req, gain = vdata[u]\n    frm = {u}\n    for v in to[u]:\n        if visited[v]:\n            frm.add(s.leader(v))\n    mnextra = 10 ** 18\n    for v in frm:\n        e, g = dp[v]\n        e += max(req - (e + g), 0)\n        if e < mnextra:\n            mnextra, mni = e, v\n    extra, tot_gain = mnextra, sum(dp[v][1] for v in frm)\n    for v in frm:\n        s.merge(u, v)\n    dp[s.leader(u)] = extra, tot_gain\n    visited[u] = True\nans = sum(dp[s.leader(0)])\nprint(ans)\n'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 18087