using System;
class Program
{ 
    static void Main()
    {
        string[] s = Console.ReadLine().Split();
        int n = int.Parse(s[0]), m = int.Parse(s[1]);
        int[,] x = new int[n, 2];
        int[,] y = new int[m, 2];
        for (int i = 0; i < n; i++)
        {
            s = Console.ReadLine().Split();
            x[i,0] = int.Parse(s[0]);
            x[i,1] = int.Parse(s[1]);
        }
        for (int i = 0; i < m; i++)
        {
            s = Console.ReadLine().Split();
            y[i,0] = int.Parse(s[0]);
            y[i,1] = int.Parse(s[1]);
        }
        Console.WriteLine("{0}\n1\n1 1 {0}", Math.Min(x[0,1], y[0,1]));
    }
}