#include <bits/stdc++.h>
using namespace std;
int const inf = 0x3f3f3f3f;
typedef struct {
  int d, t, k;
} node;
int main() {
  int n, q;
  node a[100005];
  int s[105];
  while (cin >> n >> q) {
    memset(s, 0, sizeof(s));
    for (int i = 1; i <= q; i++) {
      scanf("%d %d %d", &a[i].t, &a[i].k, &a[i].d);
    }
    for (int i = 1; i <= q; i++) {
      int sum = 0;
      int ans = 0;
      int tk = 0;
      for (int j = 1; j <= n; j++) {
        if (s[j] < a[i].t) {
          tk++;
        }
      }
      if (tk < a[i].k) {
        puts("-1");
        continue;
      }
      for (int j = 1; j <= n && sum < a[i].k; j++) {
        if (a[i].t > s[j]) {
          ans += j;
          sum++;
          s[j] = a[i].t + a[i].d - 1;
        }
      }
      printf("%d\n", ans);
    }
  }
  return 0;
}
