#include <bits/stdc++.h>
using namespace std;
const int MAX = 109;
int t[MAX];
int main() {
  int n, q;
  cin >> n >> q;
  while (q--) {
    int a, b, c, cnt = 0, id = 0;
    cin >> a >> b >> c;
    for (int i = 1; i <= n; i++) cnt += (t[i] <= a);
    if (cnt >= b) {
      int cnt = 0;
      for (int i = 1; i <= n, cnt < b; i++)
        if (t[i] <= a) t[i] = a + c, id += i, cnt++;
      cout << id << '\n';
    } else
      cout << -1 << '\n';
  }
}
