#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MAXN = 100010;
int n, m, xi[MAXN], yi[MAXN], cnt;
signed main() {
freopen("monkeygame.in", "r", stdin);
freopen("monkeygame.out", "w", stdout);
cin >> n >> m;
for(int i = 1; i <= n; i ++) {
cin >> xi[i] >> yi[i];
}
cnt = n;
for(int i = 1; i <= m; i ++) {
int op, x, y;
cin >> op >> x >> y;
if(op == 1) {
xi[++ cnt] = x;
yi[cnt] = y;
}
else {
int ans = 1e12;
for(int j = 1; j <= cnt; j ++) {
ans = min(ans, abs(xi[j] - x) + abs(yi[j] - y));
}
cout << ans << endl;
}
}
return 0;
}