using System;
using System.Numerics;
using System.Reflection.Metadata.Ecma335;
class Program
{
    static long MaxIndex(long[,] nn, long n)
    {
        long max = nn[1, 0];
        long imax = nn[0, 0];
        for(int i = 0; i < n; i++)
        {
            if(nn[1, i]>= max) max = nn[1, i]; imax = nn[0, i];
        }
        return imax;

    }
    static long MinIndex(long[,] nn, long n)
    {
        long min = nn[1, 0];
        long imin = nn[0, 0];
        for (int i = 0; i < n; i++)
        {
            if (nn[1, i] <= min) min = nn[1, i]; imin = nn[0, i];
        }
        return imin;

    }
    static long Euklid(long[,] nn, long n, long[,] mm, long m)
    {
        long euklid = (nn[2, 0] - mm[2, 0]) ^ 2 + (nn[1, MaxIndex(nn, n)] - mm[1, MinIndex(mm, m)]) ^ 2;
        return euklid;
    }
    static void Main()
    {
        string[] s = Console.ReadLine().Split();
        long n = long.Parse(s[0]);
        long m = long.Parse(s[1]);
        long k = 1;

        long[,] nn = new long[3, n];
        long[,] mm = new long[3, m];

        for (long i = 0; i < n; i++)
        {
            string[] s1 = Console.ReadLine().Split();
            nn[0, i] = i;
            nn[1, i] =(long.Parse(s1[0]));
            nn[2, i] = (long.Parse(s1[1]));
        }
        List<long> xm = new List<long>();
        for (long i = 0; i < m; i++)
        {
            string[] s1 = Console.ReadLine().Split();
            mm[0, i] = i;
            mm[1, i] = (long.Parse(s1[0]));
            mm[2, i] = (long.Parse(s1[1]));
        }
        long euklid = 0;

        if (nn[1, 0] < mm[1, 0])
        {
            Console.WriteLine(Euklid(nn, n, mm, m));
            Console.WriteLine(nn[1, MaxIndex(nn, n)] + "  " + nn[2, 0]);
            Console.WriteLine(mm[1, MinIndex(mm, m)] + "  " + mm[2, 0]);
        }
        else
        {
            Console.WriteLine(Euklid(mm, m, nn, n));
            Console.WriteLine(nn[1, MinIndex(nn, n)] + "  " + nn[2, 0]);
            Console.WriteLine(mm[1, MaxIndex(mm, m)] + "  " + mm[2, 0]);
        }



    }
}