#include<bits/stdc++.h>
using namespace std;
int n,m,a,b,B[500005],A[500005],C[500005];
long long sum;
int main(){
  scanf("%d %d", &n, &m);
  scanf("%d %d", &a, &b);
  for(int i=1; i<=m; i++){
    scanf("%d %d", &A[i], &B[i]);
  }
  for(int i=1; i<=m; i++){
    C[i]=A[i];
    sum+=A[i];
  }
  int mesto=1;
  while(sum-A[mesto]+B[mesto]<b){
    C[mesto]=B[mesto];
    mesto++;
  }
  C[mesto]+=b-sum;
  for(int i=1; i<=m; i++){
    cout << 1 << " " << i << " " << C[i] << "\n";
  }
  return 0;
}