#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <set>
#include <queue>

template <typename F>
class fix_point: F {
public:
  explicit constexpr fix_point(F&& f) noexcept: F(std::forward<F>(f)) {}

  template <typename... Args>
  constexpr decltype(auto) operator ()(Args&&... args) const {
    return F::operator ()(*this, std::forward<Args>(args)...);
  }
};

template <typename F>
static inline constexpr decltype(auto) make_fix_point(F&& f) noexcept {
  return fix_point<F>{std::forward<F>(f)};
}

template <typename Weight>
struct edge {
  using value_type = Weight;
  size_t src, dst;
  value_type cost;

  edge(size_t src, size_t dst, value_type cost = 1):
    src(src), dst(dst), cost(cost)
  {}

  bool operator <(edge<value_type> const& rhs) const {
    if (cost != rhs.cost) return cost < rhs.cost;
    if (src != rhs.src) return src < rhs.src;
    return dst < rhs.dst;
  }
};

template <typename Weight>
struct graph: public std::vector<std::vector<edge<Weight>>> {
  using value_type = Weight;
  graph(size_t n): std::vector<std::vector<edge<value_type>>>(n) {}

  void connect_to(size_t src, size_t dst, value_type cost = 1) {
    (*this)[src].emplace_back(src, dst, cost);
  }

  void connect_with(size_t src, size_t dst, value_type cost = 1) {
    connect_to(src, dst, cost);
    connect_to(dst, src, cost);
  }
};

template <class Weight>
std::vector<size_t> strongly_connected_components(const graph<Weight>& g) {
  size_t n = g.size();
  graph<int> rev(n);
  for (const auto& v: g)
    for (const auto& e: v)
      rev.connect_to(e.dst, e.src);

  std::vector<bool> used(n);
  std::vector<size_t> vs;
  auto dfs = make_fix_point([&](auto f, size_t v) -> void {
      used[v] = true;
      for (size_t i = 0; i < g[v].size(); ++i)
        if (!used[g[v][i].dst]) f(g[v][i].dst);
      vs.push_back(v);
  });
  for (size_t i = 0; i < n; ++i)
    if (!used[i]) dfs(i);

  used.assign(n, false);
  std::vector<size_t> cmp(n);
  size_t num = 0;
  auto rdfs = make_fix_point([&](auto f, size_t v) -> void {
      used[v] = true;
      cmp[v] = num;
      for (size_t i = 0; i < rev[v].size(); ++i)
        if (!used[rev[v][i].dst]) f(rev[v][i].dst);
  });

  for (size_t i = vs.size(); i--;)
    if (!used[vs[i]]) {
      rdfs(vs[i]);
      ++num;
    }

  return cmp;
}

class neko {
  std::array<intmax_t, 8> a = {};

public:
  neko() {
    for (intmax_t i = 0; i < 8; ++i) a[i] = -1e14;
  }
  neko(intmax_t x, intmax_t y, intmax_t z) {
    for (int i = 0; i < 8; ++i) {
      a[i] += ((i & 1)? +x: -x);
      a[i] += ((i & 2)? +y: -y);
      a[i] += ((i & 4)? +z: -z);
    }
  }
  neko(neko const& other) = default;

  neko max(neko const& other) const {
    neko res;
    for (size_t i = 0; i < 8; ++i)
      res.a[i] = std::max(a[i], other.a[i]);
    return res;
  }

  intmax_t tsurai(neko const& other) const {
    intmax_t res = 0;
    for (size_t i = 0; i < 8; ++i)
      res = std::max(res, a[i] - other.a[i]);
    return res;
  }

  void inspect() const {
    for (size_t i = 0; i < 8; ++i) fprintf(stderr, "%jd%c", a[i], i<7? ' ': '\n');
  }
};

int main() {
  size_t n, m;
  scanf("%zu %zu", &n, &m);

  std::vector<intmax_t> x(n), y(n), z(n);
  for (size_t i = 0; i < n; ++i)
    scanf("%jd %jd %jd", &x[i], &y[i], &z[i]);

  graph<int> g(n);
  std::vector<std::pair<size_t, size_t>> es;
  for (size_t i = 0; i < m; ++i) {
    size_t u, v;
    scanf("%zu %zu", &u, &v);
    --u, --v;
    g.connect_to(u, v);
    es.emplace_back(u, v);
  }

  auto scc = strongly_connected_components(g);
  size_t n1 = *std::max_element(scc.begin(), scc.end()) + 1;

  std::vector<neko> dp(n1);
  for (size_t i = 0; i < n; ++i) {
    dp[scc[i]] = dp[scc[i]].max(neko(x[i], y[i], z[i]));
  }
  // for (size_t i = 0; i < n1; ++i)
  //   dp[i].inspect();

  graph<size_t> h(n1);
  std::vector<size_t> indeg(n1);
  {
    std::set<std::pair<size_t, size_t>> es0;
    for (size_t i = 0; i < m; ++i) {
      size_t u0 = scc[es[i].first];
      size_t v0 = scc[es[i].second];
      if (u0 == v0) continue;
      if (es0.count(std::make_pair(v0, u0))) continue;
      h.connect_to(v0, u0);
      es0.insert(std::make_pair(v0, u0));
      ++indeg[u0];
    }
  }

  std::queue<size_t> q;
  for (size_t i = 0; i < n1; ++i)
    if (indeg[i] == 0) q.push(i);

  while (!q.empty()) {
    size_t v = q.front();
    // fprintf(stderr, "v: %zu\n", v);
    q.pop();
    for (auto const& e: h[v]) {
      dp[e.dst] = dp[e.dst].max(dp[e.src]);
      if (--indeg[e.dst] != 0) continue;
      q.push(e.dst);
    }
  }

  // for (size_t i = 0; i < n1; ++i)
  //   dp[i].inspect();
  for (size_t i = 0; i < n; ++i)
    printf("%jd\n", dp[scc[i]].tsurai(neko(x[i], y[i], z[i])));
}



Measured memory_bytes: 66616