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



import java.io.BufferedReader;

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.math.BigInteger;


import java.util.*;

public class random_num {
public static long x,y,d;
public static int mod= (int) (Math.pow(10,9)+7);
	public static void main(String args[]){
		InputReader s= new InputReader(System.in);
		OutputStream outputStream= System.out;
		PrintWriter out= new PrintWriter(outputStream);
		int n=s.nextInt();
		int q=s.nextInt();
		int a[]=new int[n+1];
		int t_old=0,k_old=0,d_old=0; 
		for(int i=0;i<q;i++){
			int t=s.nextInt();
			int k=s.nextInt();
			int d=s.nextInt();
			int sum=0;
			int occupied=0;
			for(int j=1;j<=n;j++){
				if(a[j]>t-t_old){
					occupied++;
				}
			}
			if(n-occupied>=k){
				for(int j=1;j<=n;j++){
					if(k>0){
						if(a[j]<=t-t_old){
							a[j]=d;
							k--;
							sum+=j;
						}
						else{
							a[j]-=(t-t_old);
						}
					}
					else{
						int pr=a[j];
						a[j]-=(t-t_old);
						if(a[j]<=0){
							a[j]=0;
						}
					}
				}
				
				System.out.println(sum);
				//System.out.println("occupied "+occupied);
				sum=0;
				t_old=t;
			}
			else{
				System.out.println(-1);
			}
		}
		out.close();
	}
	static class InputReader {
		
	    public BufferedReader reader;
	    public StringTokenizer tokenizer;
 
	    public InputReader(InputStream inputstream) {
	      reader = new BufferedReader(new InputStreamReader(inputstream));
	      tokenizer = null;
	    }
	    
	    public String nextLine(){
	    	String fullLine=null;
	    	while (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	              fullLine=reader.readLine();
	            } catch (IOException e) {
	              throw new RuntimeException(e);
	            }
	            return fullLine;
	          }
	          return fullLine;
	    }
		public String next() {
	      while (tokenizer == null || !tokenizer.hasMoreTokens()) {
	        try {
	          tokenizer = new StringTokenizer(reader.readLine());
	        } catch (IOException e) {
	          throw new RuntimeException(e);
	        }
	      }
	      return tokenizer.nextToken();
	    }
		public long nextLong() {
		      return Long.parseLong(next());
		    }
	    public int nextInt() {
	      return Integer.parseInt(next());
	    }
	  }
	
	public static HashMap<Integer,Long> getcatalan(int n){
		HashMap<Integer,Long> a=new HashMap<Integer,Long>();
		a.put(0,(long)1);
		for(int i=1;i<=n+1;i++){
			long m=2*(2*i-1);
			long m1=m*a.get(i-1);
			long m3=m1/(i+1);
			//out.println(m+" "+m1+" "+m2+" "+m3);
			
			a.put(i,m3%1000000007);
		}
		return a;
	}
	
	public static int getGdc(int[] x) {
	    // get the smallest of all number no need to check for higher values
	    int smallest = getSmallest(x);

	    for(int i = smallest; i >= 1; i--) {
	       int j;
	       for(j = 0; j < x.length; ++j) {
	           if(x[j] % i != 0)
	               break;
	       }
	       // if we pass through the array with all % == 0 return the value
	       if(j == x.length)
	           return i;
	    }
	    // so the only possible is 1
	    return 1;
	}

	// return smallest number of an array of int
	public static int getSmallest(int[] x) {
	    int smallest = x[0];
	    for(int i = 1; i < x.length; ++i) {
	        if(x[i] < smallest)
	            smallest = x[i];
	    }
	    return smallest;
	}
	public static long gcd(long number1, long number2) {  
		if(number2 == 0){
			return number1;
		} 
		return gcd(number2, number1%number2); 
	}
	
	public static void extendedEuclidean(long a,long b){
		if(b == 0) {
	        d = a;
	        x = 1;
	        y = 0;
	    }
	    else {
	        extendedEuclidean(b, a%b);
	        long temp = x;
	        x = y;
	        y = temp - (a/b)*y;
	    }
	}
	
	public static int combinations(int n,int r){
		if(n==r) return 1;
		if(r==1) return n;
		if(r==0) return 1;
		return combinations(n-1,r)+ combinations(n-1,r-1);
	}
	public static long binomialCoeff(int n, int k)
	{
	    long C[][]= new long[n+1][k+1];
	    int i, j;
	 
	    // Caculate value of Binomial Coefficient in bottom up manner
	    for (i = 0; i <= n; i++)
	    {
	        for (j = 0; j <= Math.min(i, k); j++)
	        {
	            // Base Cases
	            if (j == 0 || j == i)
	                C[i][j] = 1;
	 
	            // Calculate value using previosly stored values
	            else
	                C[i][j] = C[i-1][j-1] + C[i-1][j];
	        }
	    }
	 
	    return C[n][k];
	}
	public static long expo(long a, long b){
	    if (b==1)
	        return a%mod;
	    if (b==2)
	        return (a%mod)*(a%mod);

	    if (b%2==0){
	            return expo(expo(a%mod,(b%mod)/2),2);
	    }
	    else{
	        return a*(expo(expo(a%mod,((b%mod-1%mod)%mod)/2),2));
	    }
	}
	
	public static int[] sieve(int N){
		int arr[]= new int[N+1];
		int b[]=new int[N+1];
		for(int i=2;i<Math.sqrt(N);i++){
			if(arr[i]==0){
				
				for(int j= i*i;j<= N;j= j+i){
					arr[j]=1;
				}
			}
		}
		return arr;
		// All the i for which arr[i]==0 are prime numbers.
	}
	static class Pair implements Comparable<Pair>
    {
        int f,s;
        Pair(int ii, int cc)
        {
            f=ii;
            s=cc;
        }
        
        public int compareTo(Pair o) 
        {
            return Integer.compare(this.f, o.f);
        }
        
    }
	public static class company{
		public int t;
		public int d;
		public company(int m,int f){
			this.t=m;
			this.d=f;
		}
		public int get_t(){
			return this.t;
		}
		public int get_d(){
			return this.d;
		}
	}
	public static class pair_comparator implements Comparator<company>{

		@Override
		public int compare(company arg0, company arg1) {
			// TODO Auto-generated method stub
			return arg0.t-arg1.t;
		}
		
	}

}