#include <bits/stdc++.h>
using namespace std;
int n, q, end1[110], sum, end2[110], t, k, d;
int main() {
  while (cin >> n >> q) {
    memset(end1, 0, sizeof(end1));
    for (int i = 1; i <= q; i++) {
      sum = 0;
      cin >> t >> k >> d;
      for (int j = 1; j <= n; j++) {
        if (end1[j] < t) {
          end1[j] = t + d - 1;
          sum += j;
          k--;
        }
        if (k <= 0) {
          break;
        }
      }
      if (k != 0) {
        cout << "-1" << endl;
        for (int ii = 1; ii <= n; ii++) {
          end1[ii] = end2[ii];
        }
        sum = 0;
      } else {
        cout << sum << endl;
      }
      for (int j = 1; j <= n; j++) {
        end2[j] = end1[j];
      }
    }
  }
  return 0;
}
