/// USACO 2019 US Open Contest, Silver - Fence Planning
/// https://u...content-available-to-author-only...o.org/index.php?page=viewproblem2&cpid=944
/// Author: Qwerty
#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
const int MAXN = 1e5 + 100;
int n, m;
pair<int, int> c[MAXN];
vector<int> a[MAXN];
int vis[MAXN];
vector<int> comp[MAXN];
int cnt = 1;
void dfs(int u){
vis[u] = 1;
comp[cnt].push_back(u);
for (int v: a[u]){
if (!vis[v]){
dfs(v);
}
}
}
int main(){
//freopen("fenceplan.in", "r", stdin);
//freopen("fenceplan.out", "w", stdout);
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m;
for (int i = 1; i <= n; i++){
cin >> c[i].fi >> c[i].se;
}
for (int i = 1; i <= m; i++){
int x, y;
cin >> x >> y;
a[x].push_back(y);
a[y].push_back(x);
}
for (int i = 1; i <= n; i++){
if (!vis[i]){
dfs(i);
cnt++;
}
}
cnt--;
int ans = 1e9;
for (int i = 1; i <= cnt; i++){
int minx = 1e9;
int maxx = 0;
int miny = 1e9;
int maxy = 0;
for (int x: comp[i]){
minx = min(minx, c[x].first);
maxx = max(maxx, c[x].first);
miny = min(miny, c[x].second);
maxy = max(maxy, c[x].second);
}
ans = min(ans, 2 * ((maxx - minx) + (maxy - miny)));
}
cout << ans << '\n';
}
Ly8vIFVTQUNPIDIwMTkgVVMgT3BlbiBDb250ZXN0LCBTaWx2ZXIgLSBGZW5jZSBQbGFubmluZwovLy8gaHR0cHM6Ly91Li4uY29udGVudC1hdmFpbGFibGUtdG8tYXV0aG9yLW9ubHkuLi5vLm9yZy9pbmRleC5waHA/cGFnZT12aWV3cHJvYmxlbTImY3BpZD05NDQKLy8vIEF1dGhvcjogUXdlcnR5CiNpbmNsdWRlPGJpdHMvc3RkYysrLmg+CiNkZWZpbmUgZmkgZmlyc3QKI2RlZmluZSBzZSBzZWNvbmQKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKY29uc3QgaW50IE1BWE4gPSAxZTUgKyAxMDA7CmludCBuLCBtOwpwYWlyPGludCwgaW50PiBjW01BWE5dOwp2ZWN0b3I8aW50PiBhW01BWE5dOwppbnQgdmlzW01BWE5dOwp2ZWN0b3I8aW50PiBjb21wW01BWE5dOwppbnQgY250ID0gMTsKdm9pZCBkZnMoaW50IHUpewogICAgdmlzW3VdID0gMTsKICAgIGNvbXBbY250XS5wdXNoX2JhY2sodSk7CiAgICBmb3IgKGludCB2OiBhW3VdKXsKICAgICAgICAgaWYgKCF2aXNbdl0pewogICAgICAgICAgICAgZGZzKHYpOwogICAgICAgICB9CiAgICB9Cn0KaW50IG1haW4oKXsKICAgIC8vZnJlb3BlbigiZmVuY2VwbGFuLmluIiwgInIiLCBzdGRpbik7CiAgICAvL2ZyZW9wZW4oImZlbmNlcGxhbi5vdXQiLCAidyIsIHN0ZG91dCk7CiAgICBpb3NfYmFzZTo6c3luY193aXRoX3N0ZGlvKDApOwogICAgY2luLnRpZSgwKTsKICAgIGNpbiA+PiBuID4+IG07CiAgICBmb3IgKGludCBpID0gMTsgaSA8PSBuOyBpKyspewogICAgICAgICBjaW4gPj4gY1tpXS5maSA+PiBjW2ldLnNlOwogICAgfQogICAgZm9yIChpbnQgaSA9IDE7IGkgPD0gbTsgaSsrKXsKICAgICAgICAgaW50IHgsIHk7CiAgICAgICAgIGNpbiA+PiB4ID4+IHk7CiAgICAgICAgIGFbeF0ucHVzaF9iYWNrKHkpOwogICAgICAgICBhW3ldLnB1c2hfYmFjayh4KTsKICAgIH0KICAgIGZvciAoaW50IGkgPSAxOyBpIDw9IG47IGkrKyl7CiAgICAgICAgIGlmICghdmlzW2ldKXsKICAgICAgICAgICAgIGRmcyhpKTsKICAgICAgICAgICAgIGNudCsrOwogICAgICAgICB9CiAgICB9CiAgICBjbnQtLTsKICAgIGludCBhbnMgPSAxZTk7CiAgICBmb3IgKGludCBpID0gMTsgaSA8PSBjbnQ7IGkrKyl7CiAgICAgICAgIGludCBtaW54ID0gMWU5OwogICAgICAgICBpbnQgbWF4eCA9IDA7CiAgICAgICAgIGludCBtaW55ID0gMWU5OwogICAgICAgICBpbnQgbWF4eSA9IDA7CiAgICAgICAgIGZvciAoaW50IHg6IGNvbXBbaV0pewogICAgICAgICAgICAgIG1pbnggPSBtaW4obWlueCwgY1t4XS5maXJzdCk7CiAgICAgICAgICAgICAgbWF4eCA9IG1heChtYXh4LCBjW3hdLmZpcnN0KTsKICAgICAgICAgICAgICBtaW55ID0gbWluKG1pbnksIGNbeF0uc2Vjb25kKTsKICAgICAgICAgICAgICBtYXh5ID0gbWF4KG1heHksIGNbeF0uc2Vjb25kKTsKICAgICAgICAgfQogICAgICAgICBhbnMgPSBtaW4oYW5zLCAyICogKChtYXh4IC0gbWlueCkgKyAobWF4eSAtIG1pbnkpKSk7CiAgICB9CiAgICBjb3V0IDw8IGFucyA8PCAnXG4nOwp9Cgo=