100 1
1000000 100 1000
 5 3
1 4 10
2 2 5
3 1 6
 10 4
1 5 20
2 5 200
100 6 20
101 1 100
 5 3
1 3 4
4 3 4
6 4 1
 4 1
6 1 1
 8 6
1 3 20
4 2 1
6 6 5
9 1 1
15 3 6
21 8 8
 4 5
1 2 3
2 1 3
3 1 2
4 3 3
5 4 1
 8 4
1 3 2
2 3 100
10 6 20
11 5 20
 4 10
1 1 1
3 1 2
4 1 2
6 1 2
8 1 2
13 1 2
16 1 1
17 1 2
19 3 1
20 1 1
 5 3
1 4 4
4 2 2
5 5 2
 4 3
1 3 10
2 2 15
12 4 1
 5 4
1 1 4
2 4 4
5 2 20
11 5 2
 1 10
4 1 1
9 1 1
10 1 1
12 1 1
13 1 1
15 1 1
16 1 1
18 1 1
19 1 1
20 1 1

5050
 10
-1
5
 15
40
-1
1
 6
-1
10
 1
 6
9
-1
4
15
36
 3
3
4
-1
10
 6
15
-1
21
 1
1
2
1
1
1
1
1
6
1
 10
-1
15
 6
-1
10
 1
14
-1
15
 1
1
1
1
1
1
1
1
1
1

#include <bits/stdc++.h>
using namespace std;
inline int gcd(int a, int b) { return (b == 0 ? a : gcd(b, a % b)); }
inline int lcm(int a, int b) { return (a * (b / gcd(a, b))); }
inline long long int bigmod(long long int a, long long int b, long long int m) {
  if (b == 0) return 1 % m;
  long long int x = bigmod(a, b / 2, m);
  x = (x * x) % m;
  if (b % 2 == 1) {
    x = (x * a) % m;
  }
  return x;
}
inline long long int phi(long long int n) {
  long long int ret = n;
  for (long long int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      while (n % i == 0) n /= i;
    }
    ret -= ret / i;
  }
  if (n > 1) {
    ret -= ret / n;
  }
  return ret;
}
long long int missing_number(long long int A[], long long int n) {
  long long int x1 = A[0], x2 = 1;
  for (int i = 1; i < n; i++) x1 ^= A[i];
  for (int i = 2; i <= n + 1; i++) x2 ^= i;
  return (x1 ^ x2);
}
bool isFibo(long long int n) {
  long long int A = (5 * n * n + 4);
  long long int B = (5 * n * n - 4);
  long long int C = sqrt(A);
  long long int D = sqrt(B);
  return (A == (C * C) || B == (D * D));
}
long long int classini(long long int n) { return (n & 1) ? -1 : 1; }
long long int factorial(int n) {
  return (n == 1 || n == 0) ? 1 : factorial(n - 1) * n;
}
long long int catanal(long long int n) {
  return (factorial(2 * n) / ((factorial(n + 1) * factorial(n))));
}
string orientation_3_ordered_point(vector<pair<int, int> > V) {
  long long int value =
      (V[1].second - V[0].second) * (V[2].first - V[1].first) -
      (V[1].first * V[0].first) * (V[2].second - V[1].second);
  string res;
  if (value == 0) res = "colinear";
  value == 1 ? res = "clockwise" : res = "counterclockwise";
  return res;
}
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
int fx[] = {+0, +0, +1, -1, -1, +1, -1, +1};
int fy[] = {-1, +1, +0, +0, +1, +1, -1, -1};
string make_string(long long int num) {
  stringstream ss;
  ss << num;
  string s;
  ss >> s;
  return s;
}
long long int make_num(string s) {
  stringstream ss;
  long long int tmp;
  ss << s;
  ss >> tmp;
  return tmp;
}
int SET(int mask, int pos) { return (mask | (1 << pos)); }
int check(int mask, int pos) { return (mask & (1 << pos)); }
long long int server[110];
int main() {
  int n, q;
  scanf("%d", &n), scanf("%d", &q);
  memset(server, 0, sizeof(server));
  int prev = 0;
  while (q--) {
    int t, k, d, ans = 0, cnt = 0;
    scanf("%d", &t), scanf("%d", &k);
    scanf("%d", &d);
    for (int i = 1; i <= n; i++) {
      if (cnt < k && server[i] < t) {
        server[i] = t + d - 1;
        ans += i;
        cnt++;
      }
    }
    if (cnt == k)
      printf("%d\n", ans);
    else
      printf("-1\n");
  }
  return 0;
}
