#include <bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;
long long const inf = 3e18, linf = 2e9, mod = 1e9 + 7, inf2 = 1e12;
int const mxn = 2e5 + 10;
long long poww(long long a, long long b, long long md = mod) {
  return (!b ? 1
             : (b & 1 ? a * poww(a * a % md, b / 2, md) % md
                      : poww(a * a % md, b / 2, md) % md));
}
int n, q, tim[200], pas;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> q;
  for (int qq = 1; qq <= q; qq++) {
    int t, k, d, cnt = 0, ans = 0;
    cin >> t >> k >> d;
    if (qq == 1) pas = t;
    for (int i = 1; i <= n; i++) {
      tim[i] = tim[i] - (t - pas);
      if (tim[i] < 0) tim[i] = 0;
      if (tim[i] == 0) cnt++;
    }
    pas = t;
    if (cnt < k) {
      cout << -1 << "\n";
      continue;
    }
    cnt = k;
    for (int i = 1; i <= n; i++) {
      if (!tim[i]) {
        tim[i] = d;
        ans += i;
        cnt--;
      }
      if (cnt == 0) break;
    }
    cout << ans << "\n";
  }
}
