function Main(input) {
  lines = input.split("\n");
  lines.pop();
  l = lines.shift();
  N = l.split(" ")[0] * 1;
  Q = l.split(" ")[1] * 1;
  t = {};
  len = lines.length - Q;
  for (i = 0; i < len; i++) {
    l = lines[i].split(" ");
    if (!t[l[1]]) {
      t[l[1]] = [];
    }
    t[l[1]].push(l[0]);
  }
//   console.log(t);
  //   console.log(lines)
  s = lines.slice(len)
  //   console.log(s);
  l = s[0].split(' ')
  a = l[0] * 1;
  b = l[1] * 1;
  sum = b;
  ans = [0];
  for (i = 1; i < s.length; i++) {
    l = s[i].split(' ')
    // console.log(s[i]);
    if (a != l[0] * 1) {
      k = a - 1;
      if (ans[k] == undefined) {
        ans[k] = 0;
      }
      ans[k] += sum;
      a = l[0] * 1;
      sum = l[1] * 1;
    } else {
      sum += l[1] * 1;
    }
  }

  k = a - 1;
  if (ans[k] == undefined) {
    ans[k] = 0;
  }
  ans[k] += sum;

//   console.log("1", ans);

  keys = Object.keys(t);
  function cal(a, g) {
      if (t[a]) {
          for (j = 0; j < t[a].length; j++) {
              g += cal(t[a][j], g)
          }
          return g + (ans[a - 1] ? ans[a - 1] : 0)
      } else {
          return g + (ans[a - 1] ? ans[a - 1] : 0)
      }
  }
  
  for (i =keys.length - 1; i >= 0; i--) {
      a = keys[i]
      ans[a-1] = cal(a, 0)
  }

  console.log(ans.join(" "));
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
