// Arup Guha
// 5/11/2017
// Solution to 2016 NCPC Problem K: Keeping the Dogs Apart

import java.util.*;
import java.io.*;

public class k {

	final public static double EPSILON = 1e-9;

	public static int n;
	public static pt[] dog1;
	public static seg[] seg1;

	public static int m;
	public static pt[] dog2;
	public static seg[] seg2;

	public static void main(String[] Args) throws Exception {

		BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
		n = Integer.parseInt(stdin.readLine().trim());
		dog1 = new pt[n];

		// Read in first dog's info, storing total distance from start in d1t.
		for (int i=0; i<n; i++) {
			StringTokenizer tok = new StringTokenizer(stdin.readLine());
			int x = Integer.parseInt(tok.nextToken());
			int y = Integer.parseInt(tok.nextToken());
			dog1[i] = new pt(x,y);
		}

		// Create each line segment for first dog.
		seg1 = new seg[n-1];
		for (int i=0; i<n-1; i++)
			seg1[i] = new seg(dog1[i], dog1[i+1]);

		m =  Integer.parseInt(stdin.readLine().trim());
		dog2 = new pt[m];

		// Read in second dog's info, again storing total distance from start in d2t.
		for (int i=0; i<m; i++) {
			StringTokenizer tok = new StringTokenizer(stdin.readLine());
			int x = Integer.parseInt(tok.nextToken());
			int y = Integer.parseInt(tok.nextToken());
			dog2[i] = new pt(x,y);
		}

		// Create a line segment for second dog.
		seg2 = new seg[m-1];
		for (int i=0; i<m-1; i++)
			seg2[i] = new seg(dog2[i], dog2[i+1]);

		int i = 0, j = 0;

		// Start both dogs at their starting locations.
		double res = dog1[0].dist(dog2[0]);

		// loop till sleep.
		while (i < n-1 && j < m-1) {

			// First dog finishes a line segment first.
			if (seg1[i].mag < seg2[j].mag - EPSILON) {

				// Calculate line segments of equal length that represent this portion of both dog's walks.
				pt endb = seg2[j].eval(seg1[i].mag);
				seg b = new seg(seg2[j].start, endb);

				// Update minimum, if necesary.
				double cur = seg1[i].closest(b);
				res = Math.min(res, cur);

				// Move both dogs.
				seg2[j] = new seg(endb, dog2[j+1]);
				i++;
			}

			// Second dog finishes a line segment first.
			else if (seg2[j].mag < seg1[i].mag - EPSILON) {

				// Calculate line segments of equal length that represent this portion of both dog's walks.
				pt enda = seg1[i].eval(seg2[j].mag);
				seg a = new seg(seg1[i].start, enda);

				// Update minimum, if necessary.
				double cur = seg2[j].closest(a);
				res = Math.min(res,  cur);

				// Move both dogs.
				seg1[i] = new seg(enda, dog1[i+1]);
				j++;
			}

			// Both end a segment close enough.
			else {
				double cur = seg1[i].closest(seg2[j]);
				res = Math.min(res,  cur);
				i++;
				j++;
			}
		}

		System.out.println(res);
	}
}

class pt {

	final public static double EPSILON = 1e-5;

	public double x;
	public double y;

	public pt(double myx, double myy) {
		x = myx;
		y = myy;
	}

	public double dist(pt other) {
		return Math.sqrt((x-other.x)*(x-other.x) + (y-other.y)*(y-other.y));
	}
}

class seg {

	final public static double EPSILON = 1e-5;

	public pt start;
	public pt end;
	public pt dir;
	public double mag;

	public seg(pt a, pt b) {
		start = a;
		end = b;
		mag = a.dist(b);
		dir = new pt( (b.x-a.x)/mag, (b.y-a.y)/mag );
	}

	public pt eval(double t) {
		return new pt(start.x+t*dir.x, start.y+t*dir.y);
	}

	// other must be same length.
	public double closest(seg other) {

		double res = start.dist(other.start);
		res = Math.min(res, end.dist(other.end));

		double deltaX = dir.x - other.dir.x;
		double deltaY = dir.y - other.dir.y;

		if (Math.abs(deltaX) < EPSILON && Math.abs(deltaY) < EPSILON) return res;

		double t = (other.dir.x-dir.x)*(start.x-other.start.x)+(other.dir.y-dir.y)*(start.y-other.start.y);
		t /= (deltaX*deltaX+deltaY*deltaY);

		if (t > 0 && t < mag) {
			pt critMe = eval(t);
			pt critOther = other.eval(t);
			res = Math.min(res, critMe.dist(critOther));
		}

		return res;
	}
}