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[] j2 = new int[m];
            int zbir = 0;
            for (int i = 0; i < m; i++)
            {
                s = Console.ReadLine().Split(' ');
                x[i] = int.Parse(s[0]);
                zbir += int.Parse(s[0]);
                j2[i] = int.Parse(s[1]);
            }
            if(zbir >= i1 && zbir <= i2)
            {
                for(int i = 0; i < m; i++)
                {
                    if (x[i] >= 1)
                    {
                        Console.WriteLine("1 " + (i+1) + " " + x[i]);
                    }
                }
            }
            else
            {
                for(int i = 0; i < m; i++)
                {
                    if (j2[i] > x[i])
                    {
                        if (zbir + j2[i] - x[i] > i2)
                        {
                            zbir -= x[i];
                            x[i] = i2 - j2[i];
                            zbir += x[i];
                        }
                        else
                        {
                            zbir -= x[i];
                            x[i] = j2[i];
                            zbir += x[i];
                        }
                        if(zbir >= i1 && zbir <= i2)
                        {
                            for (int j = 0; j < m; j++)
                            {
                                if (x[j] >= 1)
                                {
                                    Console.WriteLine("1 " + (j + 1) + " " + x[j]);
                                }
                            }
                            break;
                        }
                    }
                }
            }
        }
    }
}