#include <bits/stdc++.h>

using namespace std;

namespace {

    typedef double real;
    typedef long long ll;

    const real EPS = 1e-7;

    template<class T> ostream& operator<<(ostream& os, const vector<T>& vs) {
        if (vs.empty()) return os << "[]";
        os << "[" << vs[0];
        for (int i = 1; i < vs.size(); i++) os << " " << vs[i];
        return os << "]";
    }
    template<class T> istream& operator>>(istream& is, vector<T>& vs) {
        for (auto it = vs.begin(); it != vs.end(); it++) is >> *it;
        return is;
    }

    struct Point {
        double x, y;
        Point() {}
        Point(double x, double y) : x(x), y(y) {}
        Point operator+(const Point& p) const { return Point(x + p.x, y + p.y); }
        Point operator-(const Point& p) const { return Point(x - p.x, y - p.y); }
        Point operator*(double k) const { return Point(k * x, k * y); }
        Point operator/(double k) const { return Point(x / k, y / k); }
    };
    double dot(const Point& a, const Point& b) { return a.x * b.x + a.y * b.y; }
    double cross(const Point& a, const Point& b) { return a.x * b.y - a.y * b.x; }
    double norm(const Point& a) { return sqrt(dot(a, a)); }
    Point rot90(const Point& p) { return Point(-p.y, p.x); } // ?????´????????\?±???§??????90?????????????????¢ 
    double angle(const Point& a) { return atan2(a.y, a.x); } // x????????§??????????????¨??\?±???§????????´???????§?????§??¢?????????????????¢???????????§????????????a???????????±?????????    ostream& operator<<(ostream& os, const Point& p) { return os << "(" << p.x << "," << p.y << ")"; }
    istream& operator>>(istream& is, Point& p) { return is >> p.x >> p.y; }

    int ccw(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;                          
    }

    struct Segment {
        Point a, b;
        Segment() {}
        Segment(const Point& a, const Point& b) : a(a), b(b) {}
    };
    bool intersects(const Segment& s, const Segment& t) {
        return ccw(s.a, s.b, t.a) * ccw(s.a, s.b, t.b) <= 0 && ccw(t.a, t.b, s.a) * ccw(t.a, t.b, s.b) <= 0;
    }
    Point projection(const Segment& l, const Point& p) {
        Point u = (p - l.a), v = (l.b - l.a);
        return l.a + (v / norm(v)) * (dot(u, v) / norm(v));
    }
    double dist(const Segment& s, const Point& p) {
        Point q = projection(Segment(s.a, s.b), p);
        Segment t(p, q);
        if (intersects(s, t)) return norm(t.b - t.a);
        return min(norm(s.a - p), norm(s.b - p));
    }
    double dist(const Segment& s, const Segment& t) {
        if (intersects(s, t)) return 0;
        return min( min(dist(s, t.a), dist(s, t.b)),
                min(dist(t, s.a), dist(t, s.b)) );
    }

    int N1, N2;
    vector<Point> A, B;
    void input() {
        cin >> N1;
        A.clear(); A.resize(N1 + 2);
        A[0] = Point(0, 0);
        for (int i = 1; i <= N1; i++) {
            cin >> A[i];
        }
        A[N1 + 1] = Point(1000, 0);
        cin >> N2;
        B.clear(); B.resize(N2 + 2);
        B[0] = Point(0, 1000);
        for (int i = 1; i <= N2; i++) {
            cin >> B[i];
        }
        B[N2 + 1] = Point(1000, 1000);
    }

    void solve() {
        real ans = 1e8;
        for (int i = 0; i < A.size() - 1; i++) {
            Segment s(A[i], A[i + 1]);
            for (int j = 0; j < B.size() - 1; j++) {
                Segment t(B[j], B[j + 1]);
                ans = min(ans, dist(s, t));
            }
        }
        cout << fixed << setprecision(12) << ans << endl;
    }
}

int main() {
    input(); solve();
    return 0;
}

Measured memory_bytes: 3284