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

namespace ConsoleApp5
{
    internal class Program
    {
        static void f1(int a, int b, int[] c, int[] d, int n)
        {
            int[,] matrica = new int[n, 3];
            int br = 0, i;
            for (i = 0; i < n; i++)
            {
                if (a > c[i])
                {
                    matrica[br, 0] = i + 1;
                    matrica[br, 1] = a;
                    br++;
                }
                else if (c[i] != 0)
                {
                    matrica[br, 0] = i + 1;
                    matrica[br, 1] = c[i];
                    br++;
                }
            }
            Console.WriteLine(b);
            Console.WriteLine(br);
            for (i = 0; i < br - 1; i++)
            {
                Console.Write("1 ");
                Console.Write(matrica[i, 0]); Console.Write(' ');
                Console.Write(matrica[i, 1]);Console.WriteLine();
            }
            Console.Write("1 ");
            Console.Write(matrica[i, 0]); Console.Write(' ');
            Console.Write(matrica[i, 1]);
        }
        static void Main(string[] args)
        {
            int i;
            var s = Console.ReadLine().Split();
            int n = int.Parse(s[0]);
            int m = int.Parse(s[1]);
            int[] a = new int[n], b = new int[n], c = new int[m], d = new int[m];
            for (i = 0; i < n; i++)
            {
                s = Console.ReadLine().Split();
                a[i] = int.Parse(s[0]);
                b[i] = int.Parse(s[1]);
            }
            for (i = 0; i < m; i++)
            {
                s = Console.ReadLine().Split();
                c[i] = int.Parse(s[0]);
                d[i] = int.Parse(s[1]);
            }

            if (n == 1)
                f1(a[0], b[0], c, d, m);
        }
    }
}