#include <bits/stdc++.h>
using namespace std;
long long n,m,a[50005],b[50005],na,nb,sol[50005],temp,k;
int main(){
  scanf("%lld%lld",&n,&m);
  k=m;
  if(n==1){
      scanf("%lld%lld",&na,&nb);
    for(int i=1; i<=m; i++){
      scanf("%lld%lld",&a[i],&b[i]);
      if(b[i]==0)k--;
      sol[i]=a[i];
      temp+=a[i];
    }
    for(int i=1; i<=m; i++){
       if(nb-temp>b[i]-a[i]){
          sol[i]=b[i];
          temp+=b[i]-a[i];
       }
       else{
        sol[i]+=nb-temp;
        temp=nb;
        break;
       }
    }
    printf("%lld ",temp);
    printf("%lld \n",k);
    for(int i=1; i<=m; i++)
      printf("1 %d %lld\n",i,sol[i]);
  }
  else return -1;
  return 0;
}