#ifndef LOCAL #pragma GCC target("avx2") // judge: v4 or cascadelake(←最後の一投で試すレベルでv4と差がないと思ってる) #pragma GCC optimize("Ofast") #endif #include using namespace std; using ll = long long; constexpr ll mod = 998244353; template struct Mint { using M=Mint; ll v; M& put(ll x) { v=(x>=1; } return res; } M inv() { return pow(mod-2); } }; using mint = Mint; struct UnionFind{ int n; vector par; UnionFind(int n) : n(n), par(n, -1){} int find(int x){return par[x] < 0 ? x : find(par[x]);} bool Unite(int x, int y){ x = find(x), y = find(y); if(x == y)return false; // size[x] < size[y] if(par[x] > par[y])swap(x, y); par[x] += par[y]; par[y] = x; return true; } }; namespace std { template struct hash> { size_t operator()(pair const &val) const { return hash{}(val.first)*1337^hash{}(val.second); }}; } int main(){ int h, w, n; cin >> h >> w >> n; vector xs(n), ys(n); for(int i = 0; i < n; ++i){ cin >> xs[i] >> ys[i]; --xs[i], --ys[i]; } for(int i = 0; i < n; ++i){ ll ans = 1e18; ll dist; for(int j = 0; j < n; ++j){ if(i == j)continue; int d = abs(ys[i] - ys[j]); if(d == 0){ dist = abs(xs[i] - xs[j]); } else if(d == 1){ dist = max(xs[i], xs[j]) + 1; } else if(d == 2){ dist = xs[i] + xs[j] + 2; } else{ dist = xs[i] + xs[j] + d; } ans = min(ans, dist); } cout << ans << endl; } }