#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<ll> vec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-5;
const ld pi = acos(-1.0);


int x[1 << 19], y[1 << 19], z[1 << 19];

int ans[1 << 19][8];

int calc(int id, int t) {
	int ret = 0;
	if (t % 2) {
		ret += x[id];
	}
	else {
		ret -= x[id];
	}
	t /= 2;
	if (t % 2) {
		ret += y[id];
	}
	else {
		ret -= y[id];
	}
	t /= 2;
	if (t % 2) {
		ret += z[id];
	}
	else {
		ret -= z[id];
	}
	return ret;
}
int calcinv(int id, int t) {
	return calc(id, (7 ^ t));
}

struct graph {
private:
	int n;
	vector<vector<int>> G, rG;
	vector<bool> used;
	vector<int> vs;

	int mk;
	vector<vector<int>> fG;
	vector<vector<int>> ori;
	vector<int> trans;
public:
	graph(int sz) {
		n = sz;
		G.resize(n);
		rG.resize(n);
		used.resize(n);

		fG.resize(n);
		trans.resize(n, -1);
		ori.resize(n);
	}
	void add_edge(int a, int b) {
		G[a].push_back(b);
		rG[b].push_back(a);
	}
	void dfs(int v) {
		used[v] = true;
		rep(i, G[v].size()) {
			if (!used[G[v][i]])dfs(G[v][i]);
		}
		vs.push_back(v);
	}
	void rdfs(int v, int k) {
		used[v] = true;
		queue<int> q; q.push(v);
		vector<int> c;
		while (!q.empty()) {
			int id = q.front(); q.pop();
			ori[k].push_back(id);
			rep(j, rG[id].size()) {
				int to = rG[id][j];
				if (used[to]) {
					if (trans[to] >= 0)c.push_back(trans[to]);
					continue;
				}
				used[to] = true; q.push(to);
			}
		}
		sort(c.begin(), c.end());
		int len = unique(c.begin(), c.end()) - c.begin();
		rep(i, len) {
			fG[c[i]].push_back(k);
		}
		rep(i, ori[k].size()) {
			trans[ori[k][i]] = k;
		}
	}
	void scc() {
		fill(used.begin(), used.end(), false);
		rep(i, n) {
			if (!used[i])dfs(i);
		}
		fill(used.begin(), used.end(), false);
		int k = 0;
		per(i, (int)vs.size()) {
			if (!used[vs[i]]) {
				rdfs(vs[i], k); k++;
			}
		}
		mk = k;
	}
	void query() {
		per(i, mk) {
			rep(j, ori[i].size()) {
				int id = ori[i][j];
				rep(k, 8) {
					ans[i][k] = max(ans[i][k], calc(id, k));
				}
			}
			rep(j, fG[i].size()) {
				int to = fG[i][j];
				rep(k, 8) {
					ans[i][k] = max(ans[i][k], ans[to][k]);
				}
			}
		}
	}
	void solve() {
		rep(i, n) {
			int id = trans[i];
			int ma = 0;
			rep(j, 8) {
				ma = max(ma, ans[id][j] + calcinv(i,j));
			}
			cout << ma << endl;
		}
	}
};

void solve() {
	int n, m; cin >> n >> m;
	rep(i, n) {
		cin >> x[i] >> y[i] >> z[i];
	}
	graph g(n);
	rep(i, m) {
		int a, b; cin >> a >> b; a--; b--;
		g.add_edge(a, b);
	}
	g.scc();
	rep(i, n)rep(j, 8)ans[i][j] = -mod;
	g.query(); g.solve();
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	//stop
	return 0;
}



Measured memory_bytes: 58688