#include <bits/stdc++.h>
using namespace std;
int work[103];
int n;
int q;
int arK[100004];
int arD[100004];
int arrange(int k, int d) {
  vector<int> v;
  for (int i = 1; i <= n; ++i)
    if (work[i] == 0) v.push_back(i);
  if (v.size() < k)
    return -1;
  else {
    int sum = 0;
    for (int i = 0; i < k; ++i) {
      work[v[i]] += d;
      sum += v[i];
    }
    return sum;
  }
}
void pass(int t) {
  for (int i = 1; i <= n; ++i) {
    work[i] -= t;
    if (work[i] < 0) work[i] = 0;
  }
}
void init() {
  memset(work, 0, sizeof(work));
  memset(arK, 0, sizeof(arK));
  memset(arD, 0, sizeof(arD));
}
int main() {
  init();
  cin >> n >> q;
  int ttemp = 0;
  int t;
  for (int i = 1; i <= q; ++i) {
    cin >> t >> arK[i] >> arD[i];
    pass(t - ttemp);
    ttemp = t;
    int res = arrange(arK[i], arD[i]);
    cout << res << endl;
  }
  return 0;
}
