#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <complex>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

using Point = complex<long double>;
const long double EPS = 1e-9;
const long double PI = acos(-1);
bool equals(long double a, long double b) { return abs(b - a) < EPS; }
long double dot(const Point &a, const Point &b) { return real(a) * real(b) + imag(a) * imag(b); }
long double cross(const Point &a, const Point &b) { return real(a) * imag(b) - imag(a) * real(b); }
struct Line
{
    Point a, b;
    Line(Point a, Point b) : a(a), b(b) {}
};
struct Segment : Line { Segment(Point a, Point b) : Line(a, b) {}};

Point getProjection(const Segment &l, const Point &p)
{
    long double t = dot(p - l.a, l.a - l.b) / norm(l.a - l.b);
    return l.a + (l.a - l.b) * t;
}
int ccw(const Point &a, Point b, Point c)
{
    b = b - a, c = c - a;
    if(cross(b, c) > EPS) return 1;
    if(cross(b, c) < -EPS) return -1;
    if(dot(b, c) < 0) return 2;
    if(norm(b) < norm(c)) return -2;
    return 0;
}
bool isIntersect(const Segment &s, const Point &p) { return ccw(s.a, s.b, p) == 0; }
long double getDistance(const Segment &s, const Point &p)
{
    Point r = getProjection(s, p);
    if(isIntersect(s, r)) return abs(r - p);
    return min(abs(s.a - p), abs(s.b - p));
}
long double getDistance(const Segment &s, const Segment &t)
{
    return min({getDistance(s, t.a), getDistance(s, t.b), getDistance(t, s.a), getDistance(t, s.b)});
}
long double calc(vector<Point> &p, vector<Segment> &s)
{
    long double res = 1e9;
    for(int i = 0; i < p.size(); i++)
    {
        for(int j = 0; j < s.size(); j++)
        {
            long double tmp = getDistance(s[j], p[i]);
            res = min(res, tmp);
        }
    }
    return res;
}
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(8);
    int N1, N2;
    cin >> N1;
    vector<Point> v, u;
    v.emplace_back(0, 0);
    u.emplace_back(0, 1000);
    for(int i = 0; i < N1; i++)
    {
        long double x, y; cin >> x >> y;
        v.emplace_back(x, y);
    }
    cin >> N2;
    for(int i = 0; i < N2; i++)
    {
        long double x, y; cin >> x >> y;
        u.emplace_back(x, y);
    }
    v.emplace_back(1000, 0);
    u.emplace_back(1000, 1000);
    vector<Segment> segv, segu;
    for(int i = 1; i < v.size(); i++) segv.emplace_back(v[i], v[i - 1]);
    for(int i = 1; i < u.size(); i++) segu.emplace_back(u[i], u[i - 1]);
    long double res = 0.0;
    res = max(calc(v, segu), calc(u, segv));
    for(int i = 0; i < segv.size(); i++)
    {
        for(int j = 0; j < segu.size(); j++)
        {
            long double tmp = getDistance(segv[i], segu[j]);
            res = min(res, tmp);
        }
    }
    cout << res << endl;
    return 0;
}




Measured memory_bytes: 3376