using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace B_krompir
{
    internal class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int n = int.Parse(s[0]);
            int m = int.Parse(s[1]);
            s = Console.ReadLine().Split(' ');
            int i1 = int.Parse(s[0]);
            int i2 = int.Parse(s[1]);
            int[] x = new int[m];
            int[] j1 = new int[m];
            int zbir = 0;
            for (int i = 0; i < m; i++)
            {
                s = Console.ReadLine().Split(' ');
                x[i] = int.Parse(s[1]);
                zbir += int.Parse(s[1]);
                j1[i] = int.Parse(s[0]);
            }
            if(zbir >= i1 && zbir <= i2)
            {
                for(int i = 0; i < m; i++)
                {
                    if (x[i] >= 1)
                    {
                        Console.WriteLine("1 " + (i+1) + " " + x[i]);
                    }
                }
            }
            else
            {
                int razlika = zbir - i2;
                for(int i = 0; i < m; i++)
                {
                    if(razlika == 0)
                    {
                        for (int j = 0; j < m; j++)
                        {
                            if (x[j] >= 1)
                            {
                                Console.WriteLine("1 " + (j + 1) + " " + x[j]);
                            }
                        }
                        break;
                    }
                    if (x[i] < razlika)
                    {
                        razlika -= x[i] - j1[i];
                        x[i] = j1[i];
                    }
                    else
                    {
                        x[i] = razlika;
                        razlika = 0;
                    }
                }
            }
        }
    }
}