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.shift().split(" ");
    if (!t[l[0]]) {
      t[l[0]] = [];
    }
    t[l[0]].push(l[1]);
  }
//   console.log(t);
  //   console.log(lines)
  s = lines
    .map(function(a) {
      return a.split(" ").map(function(b) {
        return b * 1;
      });
    })
    .sort(function(a, b) {
      return a[0] - b[0];
    });
//   console.log(s);
  a = s[0][0];
  b = s[0][1];
  sum = b;
  ans = [0];
  for (i = 1; i < s.length; i++) {
    // console.log(s[i]);
    if (a != s[i][0]) {
      k = a - 1;
      if (ans[k] == undefined) {
        ans[k] = 0;
      }
      ans[k] += sum;
      a = s[i][0];
      sum = s[i][1];
    } else {
      sum += s[i][1];
    }
  }

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

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

  keys = Object.keys(t);
  while (a = keys.shift())  {
      if (t[a] && t[a].length > 0) {
        t[a].map(function(b) {
          if (ans[b - 1] == undefined) {
            ans[b - 1] = ans[a - 1];
          } else {
              ans[b - 1] += ans[a - 1];
          }
        });
      }
  }

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