#include <stdio.h>
int main()
{
    int n, m;
    int jeca = 0;
    scanf("%d %d", &n, &m);
    int a;
    int b;
    int c[m];
    int d[m];
    int matrica[1][m];
    scanf("%d %d", &a, &b);
    int rejl = b;
    for(int i = 0; i < m; i++)
    {
        scanf("%d %d", &c[i], &d[i]);
    }
    matrica[0][0] = d[0];

    int rale = b;
    for(int i = 1; i < m; i++)
    {
        if(b - d[i - 1] <= d[i])
           {
            matrica[0][i] = b - d[i - 1];
            b = 0;
           }
        else{

            matrica[0][i] = d[i];
             b = b - d[i - 1];
        }
        if(b == 0)
            {
                jeca = i + 1;
                break;
            }
    }
    printf("%d\n", rejl);
    printf("%d\n", jeca);
   for(int j = 0; j < m - 1; j++)
        {
            if(matrica[0][j] != 0)
                printf("1 %d %d\n",j + 1, matrica[0][j]);

        }


}