#include <bits/stdc++.h>
using namespace std;
long long q, n, a[200], sum;
long long t[200], t1, k, d, tx[200];
int main() {
  cin >> n >> q;
  for (int i = 1; i <= n; i++) a[i] = i;
  while (q--) {
    cin >> t1 >> k >> d;
    int sum = 0;
    for (int i = 1; i <= n; i++) tx[i] = t[i];
    int k1 = k;
    for (int i = 1; i <= n && k1; i++) {
      if (tx[i] <= t1) k1--;
    }
    if (k1 == 0) {
      for (int i = 1; i <= n && k; i++) {
        if (t[i] <= t1) t[i] = t1 + d, k--, sum += a[i];
      }
      cout << sum << "\n";
    } else
      cout << "-1\n";
  }
}
