#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 7;
int n, q, arr[N];
int t, k, d;
int main() {
  cin >> n >> q;
  int sum = 0, icount = 0;
  while (q--) {
    cin >> t >> k >> d;
    icount = 0, sum = 0;
    bool flag = false;
    for (int i = 1; i <= n; i++) {
      if (arr[i] <= t) icount++;
      if (icount >= k) {
        for (int j = 1; j <= i; j++) {
          if (arr[j] <= t) {
            arr[j] = t + d;
            sum += j;
          }
        }
        flag = true;
        break;
      }
    }
    if (!flag)
      puts("-1");
    else
      cout << sum << endl;
  }
  return 0;
}
