#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 100;
const int INF = 699999999;
const int mod = 1e8;
const int N = 1e6 + 10;
long long gcd(long long a, long long b) { return (b == 0) ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
struct node {
  int s, x, t;
} a[maxn];
int vis[110];
bool cmp(long long a, long long b) { return a > b; }
int main() {
  int n, q;
  cin >> n >> q;
  for (int i = 0; i < q; i++) {
    cin >> a[i].s >> a[i].x >> a[i].t;
  }
  for (int i = 0; i < q; i++) {
    int sum = 0;
    int temp = a[i].s + a[i].t;
    int use = 0;
    for (int j = 1; j <= n; j++) {
      if (vis[j] <= a[i].s) {
        sum += j;
        use++;
        if (use == a[i].x) break;
      }
    }
    if (use == a[i].x) {
      cout << sum << endl;
      for (int j = 1; j <= n; j++) {
        if (vis[j] <= a[i].s) {
          vis[j] = temp;
          use--;
          if (use == 0) break;
        }
      }
    } else
      cout << -1 << endl;
  }
}
