#include <bits/stdc++.h>
using namespace std;
int a[105];
int main() {
  int n, q;
  while (scanf("%d %d", &n, &q) != EOF) {
    for (int i = 1; i <= n; i++) {
      a[i] = 1;
    }
    int t, p, lt;
    for (int i = 0; i < q; i++) {
      scanf("%d %d %d", &t, &p, &lt);
      int num = 0;
      for (int j = 1; j <= n; j++) {
        if (a[j] <= t) num++;
      }
      int ans = -1;
      if (num >= p) {
        num = ans = 0;
        for (int j = 1; j <= n; j++) {
          if (a[j] <= t) {
            a[j] = t + lt;
            num++;
            ans += j;
            if (num >= p) break;
          }
        }
      }
      cout << ans << endl;
    }
  }
  return 0;
}
