/*
 * Warmup Contest #2, September 4, 2010 Problem F 
 * Solution by Tom Conerly 
 * Originally from http://2008.nwerc.eu/contest/problemset (Problem I) 
 * ACM NWERC 2008 Problem I
 * 
 * The distance between two polygons is the closest distance between
 * any pair of lines one of each polygon. (You can visualize this and
 * prove it to yourself.)
 *
 * The java libraries has line to point distance to make this problem
 * easy. (The closest distance between two lines is the distance from
 * one line to the endpoint of the other.)
 *
 */


import java.awt.geom.Line2D;
import java.awt.geom.Point2D;
import java.util.*;
import static java.lang.Math.*;

public class F {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int T = sc.nextInt();
		for(int zz = 0; zz < T;zz++){
			int Na = sc.nextInt();
			Point2D[] A = new Point2D[Na];
			for(int i = 0; i < Na;i++)
				A[i] = new Point2D.Double(sc.nextInt(), sc.nextInt());
			int Nb = sc.nextInt();
			Point2D[] B = new Point2D[Nb];
			for(int i = 0; i < Nb;i++)
				B[i] = new Point2D.Double(sc.nextInt(), sc.nextInt());
			
			double ans = Long.MAX_VALUE;
			for(int i = 0; i < Na; i++){
				for(int j = 0; j < Nb;j++){
					Line2D l = new Line2D.Double(B[j], B[(j+1)%Nb]);
					ans = min(ans, l.ptSegDist(A[i]));
				}
			}
			
			for(int i = 0; i < Nb; i++){
				for(int j = 0; j < Na;j++){
					Line2D l = new Line2D.Double(A[j], A[(j+1)%Na]);
					ans = min(ans, l.ptSegDist(B[i]));
				}
			}
			System.out.format("%.09f\n", ans/2);
		}
	}
}
