#include <bits/stdc++.h>
using namespace std;
int Free[100005];
int main() {
  int n, q;
  scanf("%d%d", &n, &q);
  for (int i = 1, t, k, d; i <= q; ++i) {
    scanf("%d%d%d", &t, &k, &d);
    int available = 0;
    for (int i = 1; i <= n; ++i) {
      if (Free[i] <= t) ++available;
    }
    if (available >= k) {
      int ans = 0;
      for (int i = 1; i <= n; ++i) {
        if (Free[i] <= t) {
          Free[i] = t + d;
          ans += i;
          --k;
          if (k <= 0) break;
        }
      }
      printf("%d\n", ans);
    } else {
      printf("-1\n");
    }
  }
  return 0;
}
