#include <bits/stdc++.h>
using namespace std;
using namespace std;
int arr[105];
vector<int> v;
int main() {
  int n, q, i, t, k, d, c = 0, idx = 0, j, l;
  memset(arr, 0, sizeof(arr));
  scanf("%d %d", &n, &q);
  for (i = 0; i < q; i++) {
    scanf("%d %d %d", &t, &k, &d);
    c = 0;
    for (j = 1; j <= n; j++) {
      if (arr[j] < t) {
        c += 1;
      }
    }
    if (c >= k) {
      j = 1, c = 0, idx = 0;
      while (c < k) {
        if (arr[j] < t) {
          idx += j;
          arr[j] = t + d - 1;
          c += 1;
        }
        j++;
      }
      v.push_back(idx);
    } else {
      v.push_back(-1);
    }
  }
  for (i = 0; i < q; i++) printf("%d\n", v[i]);
  return 0;
}
