#include <bits/stdc++.h>
using namespace std;
long long MOD = 1e9 + 7;
long long MAX = 1e17;
long long end_time[105], ans[100005];
int main() {
  ios_base::sync_with_stdio(0);
  ;
  long long n, q;
  cin >> n >> q;
  for (int i = 0; i < q; i++) {
    long long t, k, d, have = 0ll;
    cin >> t >> k >> d;
    for (long long j = 1; j <= n; j++) {
      if (end_time[j] <= t) have++;
    }
    if (have < k) {
      ans[i] = -1ll;
      continue;
    }
    long long used = 0ll, cur_ans = 0ll;
    for (long long j = 1; j <= n; j++) {
      if (end_time[j] <= t) {
        end_time[j] = t + d;
        used++;
        cur_ans += j;
      }
      if (used == k) break;
    }
    ans[i] = cur_ans;
  }
  for (int i = 0; i < q; i++) {
    cout << ans[i] << endl;
  }
}
