#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define LLINF 1000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
#define dmp(x) cerr << __LINE__ << " " << #x << " " << x << endl;
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
template<class T,class U>
ostream& operator << (ostream& os,pair<T,U>& p){
	os << p.fi << ',' << p.sec; return os;
}
template<class T,class U>
istream& operator >> (istream& is,pair<T,U>& p){
	is >> p.fi >> p.sec; return is;
}
template<class T>
ostream& operator << (ostream &os,const vector<T> &vec){
	for(int i=0;i<vec.size();i++){
		os << vec[i];
		if(i+1<vec.size())os << ' ';
	}
	return os;
}
template<class T>
istream& operator >> (istream &is,vector<T>& vec){
	for(int i=0;i<vec.size();i++)is >> vec[i];
	return is;
}
vector<int> G[200100],rG[200100];
set<int> cG[200100];
vector<int> vs;
int V,E,Q;
bool used[200100];
int cmp[200100];
vector<int> cmpv[200100];
void add_edge(int from,int to){
    G[from].pb(to);
    rG[to].pb(from);
    return;
}
void dfs(int s){
    used[s]=true;
    for(int i=0;i<G[s].size();i++){
        if(!used[G[s][i]])dfs(G[s][i]);
    }
    vs.pb(s);
}
void rdfs(int s,int k){
    used[s]=true;
    cmp[s]=k;
    cmpv[k].pb(s);
    for(int i=0;i<rG[s].size();i++){
      int u = rG[s][i];
      if(!used[rG[s][i]]){
        rdfs(rG[s][i],k);
      }else{
        if(cmp[u]!=k){
          cG[cmp[u]].insert(k);
        }
      }
    }
}
int scc(){
    memset(used,0,sizeof(used));
    vs.clear();
    for(int v=0;v<V;v++){
        if(!used[v])dfs(v);
    }
    memset(used,0,sizeof(used));
    int k=0;
    for(int i=vs.size()-1;i>=0;i--){
        if(!used[vs[i]])rdfs(vs[i],k++);
    }
    return k;
}
int same(int u,int v){
    if(cmp[u]==cmp[v])return 1;
    else return 0;
}
int x[200100],y[200100],z[200100];
int w[200100][4];
int mx[200100][4],mi[200100][4];
int ans[200100];
int main(){
  cin >> V >> E;
  for(int i=0;i<V;i++){
    cin >> x[i] >> y[i] >> z[i];
    w[i][0] = x[i]+y[i]+z[i];
    w[i][1] = x[i]-y[i]+z[i];
    w[i][2] = x[i]+y[i]-z[i];
    w[i][3] = x[i]-y[i]-z[i];
  }
  for(int i=0;i<V;i++){
    ans[i] = -INF;
  }
  for(int i=0;i<V;i++){
    for(int j=0;j<4;j++){
      mx[i][j] = -INF;
      mi[i][j] = INF;
    }
  }
  for(int i=0;i<E;i++){
      int s,t;
      cin >> s >> t;
      s--;t--;
      add_edge(s,t);
  }
  int k = scc();
  // for(int i=0;i<k;i++){
  //   cout << cmpv[i] << endl;
  // }      
  for(int i=k-1;i>=0;i--){
    // cout << i << ',' << endl;
    for(int j=0;j<cmpv[i].size();j++){
      int u = cmpv[i][j];
      for(int idx=0;idx<4;idx++){
        chmin(mi[i][idx],w[u][idx]);
        chmax(mx[i][idx],w[u][idx]);
      }
    }
    for(auto it = cG[i].begin();it!=cG[i].end();it++){
      int to = *it;
      for(int idx=0;idx<4;idx++){
        chmin(mi[i][idx],mi[to][idx]);
        chmax(mx[i][idx],mx[to][idx]);
      }
    }
    for(int j=0;j<cmpv[i].size();j++){
      int v = cmpv[i][j];
      for(int idx=0;idx<4;idx++){
        chmax(ans[v],max(abs(mx[i][idx]-w[v][idx]),abs(mi[i][idx]-w[v][idx])));
      }
    }
  }
  for(int i=0;i<V;i++){
    cout << ans[i] << endl;
  }
  return 0;
}



Measured memory_bytes: 73636