#include <bits/stdc++.h>
const long long N = 2e5 + 17;
using namespace std;
long long i, mn, ans = 0, als = 0, v, ii, r4 = 0, r1, r2, r3, mx, p, q, d, l, r,
                 m, n, k, j;
string d1, d3, d2, s;
char kl, km, mk, lk;
double fg;
int inout() {
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  cin >> n >> q;
  map<long long, long long> mp;
  while (q--) {
    cin >> r1 >> r2 >> r3;
    als = 0;
    ii = 0;
    for (i = 1; i <= n; i++) {
      if (r1 >= mp[i]) als++;
      if (als == r2) break;
    }
    if (als == r2) {
      for (i = 1; i <= n && r2; i++) {
        if (r1 >= mp[i]) {
          mp[i] = r1 + r3;
          ii += i;
          r2--;
        }
      }
      cout << ii << "\n";
    } else
      cout << "-1"
           << "\n";
  }
  return 0;
}
