#include <bits/stdc++.h>
using namespace std;
long long working[200];
int main() {
  long long n, q, ti, ki, di;
  cin >> n >> q;
  for (int k = 0; k < q; k++) {
    cin >> ti >> ki >> di;
    long long sum = 0, lol = (ti + di), cnt = 0;
    for (int l = 1; l <= n; l++)
      if (working[l] <= ti) cnt++;
    if (cnt < ki) {
      cout << "-1" << endl;
      continue;
    }
    cnt = 0;
    for (int l = 1; l <= n; l++) {
      if (working[l] <= ti) {
        working[l] = lol;
        sum += l;
        cnt++;
      }
      if (cnt == ki) break;
    }
    if (cnt == ki) {
      cout << sum << endl;
    } else {
      cout << "-1" << endl;
    }
  }
}
