#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cmath>
using namespace std;
typedef long long ll;
ll inf = 1e18;

//1-indexed!
class strong_components{
private:
    vector<vector<int>> v,rv,nv,cmp_node;
    vector<int> rs,visited,cmp,cmp_size;
    int num_cmp;
    void dfs(int n){
        visited[n] = 1;
        for(auto x:v[n]) if(!visited[x]) dfs(x);
        rs.push_back(n);
    }
    void rdfs(int n,int cnt){
        visited[n] = 1;
        cmp[n] = cnt;
        for(auto x:rv[n]) if(!visited[x]) rdfs(x,cnt);
    }
public:
    strong_components(int N,vector<vector<int>>& graph){
        v = graph;
        rv = cmp_node = vector<vector<int>>(N+1);
        visited = cmp = cmp_size = vector<int>(N+1,0);
        for(int i=1;i<=N;i++) for(auto x:v[i]) rv[x].push_back(i);
        for(int i=1;i<=N;i++) if(!visited[i]) dfs(i);
        for(int i=1;i<=N;i++) visited[i] = 0;
        int now = 1;
        for(int i=rs.size()-1;i>=0;i--) if(!visited[rs[i]]) rdfs(rs[i],now++);
        nv = vector<vector<int>>(now+1);
        for(int i=1;i<=N;i++){
            cmp_node[cmp[i]].push_back(i);
            for(auto x:v[i]){
                if(cmp[i]!=cmp[x]){
                    nv[cmp[x]].push_back(cmp[i]);
                    cmp_size[cmp[x]]++;
                }
            }
        }
        num_cmp = now-1;
    }
    int find(int n){return cmp[n];}
    vector<int> get_cmp_node(int n){return cmp_node[n];}
    vector<vector<int>> get_cmp_graph(){return nv;}
    int get_num_cmp() {return num_cmp;}
    bool is_same_group(int a,int b){return cmp[a]==cmp[b];}
};

int dx[8] = {1,-1,1,-1,1,1,-1-1},dy[8] = {1,1,-1,-1,1,-1,1,-1},dz[8] = {1,1,1,1,-1,-1,-1,-1};

int N,M;
vector<ll> X(200010),Y(200010),Z(200010);
vector<ll> ans(200010);
vector<vector<int>> graph(200010);
vector<vector<int>> cmp_graph(200010);
vector<vector<int>> cmp_node(200010);
vector<vector<int>> inv_graph(200010);

ll ma[200010][8] = {};
ll mi[200010][8] = {};
ll maid[200010][8] = {};
ll miid[200010][8] = {};


//全体管理
int main(){
    cin >> N >> M;
    for(int i=1;i<=N;i++){
        cin >> X[i] >> Y[i] >> Z[i];
    }
    for(int i=1;i<=M;i++){
        int a,b;
        cin >> a >> b;
        graph[a].push_back(b);
    }
    strong_components scc(N,graph);
    cmp_graph = scc.get_cmp_graph();
    for(int i=1;i<=N;i++) cmp_node[i] = scc.get_cmp_node(i);
    int num_node = scc.get_num_cmp();
    for(int i=0;i<=N;i++) for(int j=0;j<8;j++){
        ma[i][j] = -inf;
        mi[i][j] = inf;
        maid[i][j] = -1;
        miid[i][j] = -1;
    }
    vector<int> cnt(N+1);
    for(int i=1;i<=num_node;i++) cmp_graph[0].push_back(i);
    for(int i=0;i<=num_node;i++) for(auto x:cmp_graph[i]) cnt[x]++;
    queue<int> Q;
    Q.push(0);
    /* cerr << "graph_size: " << num_node << endl;
    for(int i=1;i<=num_node;i++){
        cerr << "cmp " << i << ": ";
        for(auto x:cmp_node[i]) cerr << x << " ";
        cerr << endl;
    }*/
    while(!Q.empty()){
        int now = Q.front(); Q.pop();
//        cerr << now << endl;
        //強連結成分内の点を追加
        for(auto x:cmp_node[now]){
            for(int j=0;j<8;j++){
                ll val = X[x]*dx[j]+Y[x]*dy[j]+Z[x]*dz[j];
                if(ma[now][j]<val){
                    ma[now][j] = val;
                    maid[now][j] = x;
                }
                if(mi[now][j]>val){
                    mi[now][j] = val;
                    miid[now][j] = x;
                }
            }
        }
        //強連結成分内の各点の答えを求める
        for(auto x:cmp_node[now]){
            //cerr << "now: " << now << " x: " << x << endl;
            for(int j=0;j<8;j++){
                if(maid[now][j]!=-1){
                    int id = maid[now][j];
                    ans[x] = max(ans[x],abs(X[x]-X[id])+abs(Y[x]-Y[id])+abs(Z[x]-Z[id]));
                }
                if(miid[now][j]!=-1){
                    int id = miid[now][j];
                    ans[x] = max(ans[x],abs(X[x]-X[id])+abs(Y[x]-Y[id])+abs(Z[x]-Z[id]));
                }
            }
        }
        //行き先に自分の情報を伝える
        for(auto x:cmp_graph[now]){
            for(int j=0;j<8;j++){
                if(ma[x][j]<ma[now][j]){
                    ma[x][j] = ma[now][j];
                    maid[x][j] = maid[now][j];
                }
                if(mi[x][j]>mi[now][j]){
                    mi[x][j] = mi[now][j];
                    miid[x][j] = miid[now][j];
                }               
            }
            cnt[x]--;
            if(!cnt[x]) Q.push(x);
        }
    }
    for(int i=1;i<=N;i++) cout << ans[i] << endl;
}

/* 
192657310
138809442
0
138809442
0
270544279
96766390
0
96664294
0


*/


Measured memory_bytes: 148292