#include <bits/stdc++.h>
int s[110];
int main() {
  int n, i, j, r, l, q, t, k, d;
  scanf("%d %d", &n, &q);
  for (i = 1; i <= n; i++) s[i] = 0;
  std::vector<std::pair<int, int> > ch;
  for (i = 0; i < q; i++) {
    scanf("%d %d %d", &t, &k, &d);
    r = 0;
    l = 0;
    j = 1;
    ch.clear();
    while ((j <= n) && (l < k)) {
      if (s[j] <= t) {
        l++;
        ch.push_back(std::make_pair(j, t + d));
        r += j;
      }
      j++;
    }
    if (l < k)
      printf("-1\n");
    else {
      printf("%d\n", r);
      for (j = 0; j < ch.size(); j++) s[ch[j].first] = ch[j].second;
    }
  }
  return 0;
}
