#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, q;
  cin >> n >> q;
  vector<long long int> v(n, 0);
  long long int t[q], k[q], d[q];
  for (long long int i = 0; i < q; i++) {
    cin >> t[i] >> k[i] >> d[i];
  }
  long long int cnt = 0;
  long long int ans = 0;
  long long int flag = 0;
  for (long long int i = 0; i < q; i++) {
    cnt = 0;
    flag = 0;
    ans = 0;
    long long int nos = k[i];
    long long int time = d[i];
    if (i == 0) {
      for (long long int i = 0; i < n; i++) {
        if (v[i] == 0) {
          v[i] = v[i] + time;
          cnt++;
          ans = ans + i + 1;
        }
        if (cnt == nos) {
          cout << ans << endl;
          flag = 1;
          break;
        }
      }
      if (!flag) cout << -1 << endl;
    } else {
      long long int diff = t[i] - t[i - 1];
      for (long long int i = 0; i < n; i++) {
        if (v[i] != 0) v[i] = v[i] - diff;
        if (v[i] < 0) v[i] = 0;
      }
      for (long long int i = 0; i < n; i++) {
        if (v[i] == 0) {
          cnt++;
        }
        if (cnt == nos) {
          break;
        }
      }
      if (cnt == nos) {
        for (long long int i = 0; i < n; i++) {
          if (v[i] == 0 && cnt != 0) {
            v[i] = v[i] + time;
            ans = ans + i + 1;
            cnt--;
          }
        }
        cout << ans << endl;
      } else
        cout << -1 << endl;
    }
  }
}
