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

namespace ConsoleApp3
{
    internal class Program
    {
        static void pisi(long n, long[] niz)
        {
            long i = 0;
            for (i = 0; i < n; i++)
            {
                Console.Write(niz[i]);
                Console.Write(' ');
            }
            Console.WriteLine();
        }
        static void Main()
        {
            string[] s = Console.ReadLine().Split(' ');
            long n = long.Parse(s[0]);
            long m = long.Parse(s[1]);
            long[] niz = new long[m];
            s = Console.ReadLine().Split(' ');
            long MAX = long.Parse(s[0]);
            long rez = MAX;
            long br = 0, i;
            long MIN = long.Parse(s[1]);
            for (i = 0; i < m; i++)
            {
                s = Console.ReadLine().Split(' ');
                long min = long.Parse(s[0]);
                long max = long.Parse(s[1]);
                if(min < MAX)
                {
                    niz[i] = min;
                    MAX -= min;
                    br++;
                }
            }
            Console.WriteLine(rez);
            Console.WriteLine(br);
            for (i = 0; i < m; i++)
            {
                if (niz[i] != 0)
                {
                     Console.WriteLine("{1} {2} {3}", 1, i + 1, niz[i]);
                }
            }
        }
    }
}