#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 <bitset>

using namespace std;

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
template <typename T> void print_container(ostream& os, const T& c) { const char* _s = " "; if (!c.empty()) { __typeof__(c.begin()) last = --c.end(); foreach (it, c) { os << *it; if (it != last) os << _s; } } }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& c) { print_container(os, c); return os; }
template <typename T> ostream& operator<<(ostream& os, const set<T>& c) { print_container(os, c); return os; }
template <typename T> ostream& operator<<(ostream& os, const multiset<T>& c) { print_container(os, c); return os; }
template <typename T> ostream& operator<<(ostream& os, const deque<T>& c) { print_container(os, c); return os; }
template <typename T, typename U> ostream& operator<<(ostream& os, const map<T, U>& c) { print_container(os, c); return os; }
template <typename T, typename U> ostream& operator<<(ostream& os, const pair<T, U>& p) { os << "(" << p.first << ", " << p.second << ")"; return os; }

template <typename T> void print(T a, int n, const string& split = " ") { for (int i = 0; i < n; i++) { cout << a[i]; if (i + 1 != n) cout << split; } cout << endl; }
template <typename T> void print2d(T a, int w, int h, int width = -1, int br = 0) { for (int i = 0; i < h; ++i) { for (int j = 0; j < w; ++j) { if (width != -1) cout.width(width); cout << a[i][j] << ' '; } cout << endl; } while (br--) cout << endl; }
template <typename T> void input(T& a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }
#define dump(v) (cerr << #v << ": " << v << endl)

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define erep(i, n) for (int i = 0; i <= (int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define clr(a, x) memset(a, x, sizeof(a))
#define sz(a) ((int)(a).size())
#define mp(a, b) make_pair(a, b)
#define ten(n) ((long long)(1e##n))

template <typename T, typename U> void upmin(T& a, const U& b) { a = min<T>(a, b); }
template <typename T, typename U> void upmax(T& a, const U& b) { a = max<T>(a, b); }
template <typename T> void uniq(T& a) { sort(a.begin(), a.end()); a.erase(unique(a.begin(), a.end()), a.end()); }
template <class T> string to_s(const T& a) { ostringstream os; os << a; return os.str(); }
template <class T> T to_T(const string& s) { istringstream is(s); T res; is >> res; return res; }
void fast_io() { cin.tie(0); ios::sync_with_stdio(false); }
bool in_rect(int x, int y, int w, int h) { return 0 <= x && x < w && 0 <= y && y < h; }

typedef long long ll;
typedef pair<int, int> pint;

const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };




const double PI = acos(-1.0);
typedef double gtype;
const gtype EPS_FOR_LIB = 1e-9;
typedef complex<gtype> Point;

namespace std
{
	bool operator<(const Point& a, const Point& b)
	{
		return a.real() != b.real() ? a.real() < b.real() : a.imag() < b.imag();
	}
	std::istream& operator>>(std::istream& is, Point& p)
	{
		gtype a, b;
        is >> a >> b;
		p = Point(a, b);
		return is;
	}
	std::ostream& operator<<(std::ostream& os, const Point& p)
	{
		return os << "(" << p.real() << ", " << p.imag() << ")";
	}
};
struct Line
{
	Point first, second;
	Line() {}
    Line(const Point& first, const Point& second)
        : first(first), second(second)
    {
        // 距離で割るときにNaNになるのを防ぐ
        if (first == second)
            this->first.real(this->first.real() + 1e-12);
    }
};
typedef Line Seg;
ostream& operator<<(ostream& os, const Line& line)
{
    return os << "(" << line.first << ", " << line.second << ")";
}

struct Circle
{
    Point p;
    gtype r;
    Circle() {}
    Circle(const Point& p, gtype r)
        : p(p), r(r)
    {
    }
};
ostream& operator<<(ostream& os, const Circle& c)
{
    return os << "(" << c.p << ", " << c.r << ")";
}


gtype to_rad(gtype deg)
{
    return deg * PI / 180;
}
gtype to_deg(gtype rad)
{
    return rad * 180 / PI;
}


typedef vector<Point> G;
typedef G Convex;
Seg side_G(const G& g, int i)
{
    return Seg(g[i], g[(i + 1) % g.size()]);
}


gtype dot(const Point& a, const Point& b)
{
	return a.real() * b.real() + a.imag() * b.imag();
}
gtype cross(const Point& a, const Point& b)
{
	return a.real() * b.imag() - a.imag() * b.real();
}

enum res_ccw
{
	counter_clockwise = +1,
	clockwise = -1,
	on = 0,
};
res_ccw ccw(const Point& a, const Point& b, const Point& c)
{
    const gtype feps = 1e-10;
	Point p = b - a, q = c - a;
	if (cross(p, q) > feps) return counter_clockwise;
	else if (cross(p, q) < -feps) return clockwise;
	return on;
}


//// 交差判定

// 直交判定
// AOJ0058
bool is_orthogonal(const Line& line1, const Line& line2)
{
	return abs(dot(line1.second - line1.first, line2.second - line2.first)) < 1e-9;
}
// AOJ0021, AOJ0187
bool is_parallel(const Line& line1, const Line& line2)
{
	return abs(cross(line1.second - line1.first, line2.second - line2.first)) < 1e-9;
}

bool intersect_LP(const Line& line, const Point& p)
{
	return abs(cross(line.second - line.first, p - line.first)) < 1e-20;
}
bool intersect_SP(const Line& seg, const Point& p)
{
	return abs(seg.first - p) + abs(p - seg.second) < abs(seg.first - seg.second) + EPS_FOR_LIB;
}


bool intersect_LL(const Line& line1, const Line& line2)
{
	return !is_parallel(line1, line2);
}
// AOJ1183
bool intersect_LS(const Line& line, const Line& seg)
{
	return cross(line.second - line.first, seg.first - line.first)
		* cross(line.second - line.first, seg.second - line.first) < EPS_FOR_LIB;
}
bool intersect_SL(const Line& seg, const Line& line)
{
    return intersect_LS(line, seg);
}
// AOJ0187, AOJ1183
bool intersect_SS(const Line& seg1, const Line& seg2)
{
    const gtype feps = 1e-9;
	return (cross(seg1.second - seg1.first, seg2.first - seg1.first) * cross(seg1.second - seg1.first, seg2.second - seg1.first) < -feps
            && cross(seg2.second - seg2.first, seg1.first - seg2.first) * cross(seg2.second - seg2.first, seg1.second - seg2.first) < -feps)
		|| intersect_SP(seg1, seg2.first)
		|| intersect_SP(seg1, seg2.second)
		|| intersect_SP(seg2, seg1.first)
		|| intersect_SP(seg2, seg1.second);
}


//// 距離
gtype dist_LP(const Line& line, const Point& p)
{
	return abs(cross(line.first - line.second, p - line.second) / abs(line.first - line.second));
}
gtype dist_PL(const Point& p, const Line& line)
{
    return dist_LP(line, p);
}
gtype dist_LL(const Line& line1, const Line& line2)
{
	return is_parallel(line1, line2) ? dist_LP(line1, line2.first) : 0;
}
gtype dist_LS(const Line& line, const Line& seg)
{
	if (intersect_LS(line, seg))
		return 0;
	else
		return min(dist_LP(line, seg.first), dist_LP(line, seg.second));
}
gtype dist_SL(const Line& seg, const Line& line)
{
    return dist_LS(line, seg); // 写すとき注意！！！
}
gtype dist_SP(const Line& seg, const Point& p)
{
	if (dot(seg.second - seg.first, p - seg.first) < 0)
		return abs(seg.first - p);
	else if (dot(seg.first - seg.second, p - seg.second) < 0)
		return abs(seg.second - p);
	else
		return dist_LP(seg, p);
}
gtype dist_PS(const Point& p, const Line& seg)
{
    return dist_SP(seg, p);
}
// AOJ1157
gtype dist_SS(const Line& seg1, const Line& seg2)
{
	if (intersect_SS(seg1, seg2))
		return 0;
	else
		return min(min(dist_SP(seg1, seg2.first), dist_SP(seg1, seg2.second))
			, min(dist_SP(seg2, seg1.first), dist_SP(seg2, seg1.second)));
}


vector<Line> inp(int y)
{
    int n;
    cin >> n;
    vector<Point> p;
    p.push_back(Point(0, y));
    rep(i, n)
    {
        Point w;
        cin >> w;
        p.push_back(w);
    }
    p.push_back(Point(1000, y));

    vector<Line> seg;
    rep(i, sz(p) - 1)
        seg.push_back(Line(p[i], p[i + 1]));
    return seg;
}
int main()
{
    auto a = inp(0);
    auto b = inp(1000);

    double res = 1e9;
    for (auto& p : a)
    {
        for (auto& q : b)
        {
            upmin(res, dist_SS(p, q));
        }
    }
    printf("%.10f\n", res);
}

Measured memory_bytes: 1272