#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_DEPRECATE

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <fstream>
#include <iterator>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

#define FOR(i,n) for(int i = 0; i < (n); i++)
#define sz(c) ((int)(c).size())
#define ten(x) ((int)1e##x)
#define tenll(x) ((ll)1e##x)
template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }


const double EPS(1e-8);
const double PI = acos(-1.0);

typedef double T;

struct P {
	T x, y;
	P() : x(0), y(0) {}
	P(const T& x, const T& y) : x(x), y(y) {}
	P operator+(const P &a)const { return P(x + a.x, y + a.y); }
	P& operator+=(const P &a) { x += a.x; y += a.y; return *this; }
	P operator-(const P &a)const { return P(x - a.x, y - a.y); }
	P& operator-=(const P &a) { x -= a.x; y -= a.y; return *this; }
	P operator*(const T a)const { return P(a*x, a*y); }
	P& operator*=(const T a) { x *= a; y *= a; return *this; }
	P operator/(const T a)const { return P(x / a, y / a); }
	P& operator/=(const T a) { x /= a; y /= a; return *this; }

	//比較用
	bool operator<(const P &a)const { return (x != a.x) ? (x < a.x) : (y < a.y); }
};

struct S {
	P a, b;
	S() {}
	S(const P& a, const P& b) : a(a), b(b) {}
};

T SQ(T x) { return x*x; }
T dist2(const P &a, const P &b) { return SQ(a.x - b.x) + SQ(a.y - b.y); }
T abs2(const P& p) { return SQ(p.x) + SQ(p.y); }
T abs(const P& p) { return sqrt(abs2(p)); }
T dot(const P& a, const P& b) { return a.x*b.x + a.y*b.y; }
T cross(const P& a, const P& b) { return a.x*b.y - a.y*b.x; }
P rot(const P& a, const double theta) {
	return P(a.x*cos(theta) - a.y*sin(theta),
			 a.x*sin(theta) + a.y*cos(theta));
}
double arg(const P &a) { double t = atan2(a.y, a.x); return t<0 ? t + 2 * PI : t; }

enum { CCW = 1, CW = -1, ON = 0 };
int ccw(const P &a, P b, P c) {
	b -= a; c -= a;
	double rdir = cross(b, c);
	double len = abs(b) * abs(c); //誤差対策 (速度がやばい時は外すか、二乗に置き換える)
	if (rdir> EPS * len) return CCW; //cがabより上(反時計周り)
	if (rdir<-EPS * len) return CW; // cがabより下(時計周り)
	return ON; // a,b,cが一直線上
}

double dist2(const S &S, const P &p) {
	if (dot(S.b - S.a, p - S.a) <= 0) return dist2(p, S.a);
	if (dot(S.a - S.b, p - S.b) <= 0) return dist2(p, S.b);
	return (double)SQ(cross(S.b - S.a, p - S.a)) / dist2(S.a, S.b);
}

double dist(const S &S1, const S &S2) {
	return sqrt(min(min(dist2(S1, S2.a), dist2(S1, S2.b)),
		min(dist2(S2, S1.a), dist2(S2, S1.b))));
}

std::istream& operator>>(std::istream& is, P& point) { return (is >> point.x >> point.y); }

int main() {

	int n, m;
	cin >> n;
	vector<P> A(n + 2);
	FOR(i, n) cin >> A[i + 1];
	A[0] = P(0, 0);
	A[n+1] = P(1000, 0);
	cin >> m;
	vector<P> B(m + 2);
	FOR(i, m) cin >> B[i + 1];
	B[0] = P(0, 1000);
	B[m + 1] = P(1000, 1000);

	double ans = 1e100;
	for (auto a : A) for (auto b : B) {
		double tmp = sqrt(dist2(a, b));
		ans = min(ans, tmp);
	}
	FOR(i, sz(A) - 1) for (auto b : B) {
		double tmp = sqrt(dist2(S(A[i],A[i+1]), b));
		if (tmp < ans)
			ans = tmp;
	}
	for (auto a : A) FOR(j,sz(B)-1) {
		double tmp = sqrt(dist2(S(B[j],B[j+1]), a));
		if (tmp < ans)
			ans = tmp;
	}
	printf("%.15lf\n",ans);

	return 0;
}

Measured memory_bytes: 1248