#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
int n, q, sum, t, k, d, koi;
int vq[105];
int main() {
  while (cin >> n >> q) {
    memset(vq, 0, sizeof vq);
    for (int i = 0; i < q; i++) {
      cin >> t >> k >> d;
      koi = k;
      for (int j = 1; j <= n; j++) {
        if (vq[j] <= t) {
          koi--;
        }
        if (!koi) break;
      }
      if (koi) {
        cout << "-1\n";
      } else {
        sum = 0;
        koi = k;
        for (int j = 1; j <= n; j++) {
          if (vq[j] <= t) {
            koi--;
            sum += j;
            vq[j] = t + d;
          }
          if (!koi) break;
        }
        cout << sum << "\n";
      }
    }
  }
  return 0;
}
