#include <bits/stdc++.h>
using namespace std;
inline void read(long long &n) {
  char c;
  n = 0;
  long long x = 1;
  while (!isdigit(c = fgetc(stdin)) && c != '-')
    ;
  if (c == '-') x = -1, c = fgetc(stdin);
  while (isdigit(c)) n = n * 10 + c - '0', c = fgetc(stdin);
  n *= x;
}
inline void read(int &n) {
  long long x;
  read(x);
  n = x;
}
template <typename T1, typename T2>
inline void read(T1 &a, T2 &b) {
  read(a);
  read(b);
}
template <typename T1, typename T2, typename T3>
inline void read(T1 &a, T2 &b, T3 &c) {
  read(a);
  read(b);
  read(c);
}
template <typename T1, typename T2, typename T3, typename T4>
inline void read(T1 &a, T2 &b, T3 &c, T4 &d) {
  read(a);
  read(b);
  read(c);
  read(d);
}
multiset<long long> servers;
int main() {
  int n, m;
  read(n, m);
  for (__typeof(0) i = (0) - ((0) > (m)), a = (m) - ((0) > (m)); i != a;
       i += 1 - 2 * ((0) > (m)))
    servers.insert(1);
  for (__typeof(0) i = (0) - ((0) > (n)), a = (n) - ((0) > (n)); i != a;
       i += 1 - 2 * ((0) > (n))) {
    long long s, t;
    read(s, t);
    long long e = max(*servers.begin(), s + 1) + t - 1;
    servers.erase(servers.begin());
    servers.insert(e + 1);
    printf("%I64d\n", e);
  }
  return 0;
}
