Anton like play chess also like program no wonder decide attend chess class program classesAnton n variant attend chess class ith variant give period time l1ir1i also m variant attend programming class ith variant give period time l2ir2iAnton need choose exactly n possible period time attend chess class exactly m possible period time attend programming class he want rest class possible pair period wants choose distance period maximalthe distance period l1r1 l2r2 minimal possible distance point period point second period minimal possible ij l1ir1 l2jr2 in particular period intersect distance 0anton wants know time rest class good case help Anton find number