#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;



ld torad(int deg) {return (ld)(deg) * pi / 180;}
ld todeg(ld ang) {return ang * 180 / pi;}

struct Point {
    ld x, y;
    Point(ld x = 0.0, ld y = 0.0) : x(x), y(y) {}
    friend ostream& operator << (ostream &s, const Point &p) {return s << '(' << p.x << ", " << p.y << ')';}
};

Point operator + (const Point &p, const Point &q) {return Point(p.x + q.x, p.y + q.y);}
Point operator - (const Point &p, const Point &q) {return Point(p.x - q.x, p.y - q.y);}
Point operator * (const Point &p, ld a) {return Point(p.x * a, p.y * a);}
Point operator * (ld a, const Point &p) {return Point(a * p.x, a * p.y);}
Point operator * (const Point &p, const Point &q) {return Point(p.x * q.x - p.y * q.y, p.x * q.y + p.y * q.x);}
Point operator / (const Point &p, ld a) {return Point(p.x / a, p.y / a);}
Point conj(const Point &p) {return Point(p.x, -p.y);}
Point rot(const Point &p, ld ang) {return Point(cos(ang) * p.x - sin(ang) * p.y, sin(ang) * p.x + cos(ang) * p.y);}
Point rot90(const Point &p) {return Point(-p.y, p.x);}
ld cross(const Point &p, const Point &q) {return p.x * q.y - p.y * q.x;}
ld dot(const Point &p, const Point &q) {return p.x * q.x + p.y * q.y;}
ld norm(const Point &p) {return dot(p, p);}
ld abs(const Point &p) {return sqrt(dot(p, p));}
ld amp(const Point &p) {ld res = atan2(p.y, p.x); if (res < 0) res += pi*2; return res;}
bool eq(const Point &p, const Point &q) {return abs(p - q) < eps;}
bool operator < (const Point &p, const Point &q) {return (abs(p.x - q.x) > eps ? p.x < q.x : p.y < q.y);}
bool operator > (const Point &p, const Point &q) {return (abs(p.x - q.x) > eps ? p.x > q.x : p.y > q.y);}
Point operator / (const Point &p, const Point &q) {return p * conj(q) / norm(q);}

int ccw(const Point &a, const Point &b, const Point &c) {
    if (cross(b-a, c-a) > eps) return 1;
    if (cross(b-a, c-a) < -eps) return -1;
    if (dot(b-a, c-a) < 0) return 2;
    if (norm(b-a) < norm(c-a)) return -2;
    return 0;
}

struct Line : vector<Point> {
    Line(Point a = Point(0.0, 0.0), Point b = Point(0.0, 0.0)) {
        this->push_back(a);
        this->push_back(b);
    }
};


Point proj(Point p, Line l) {//射影
    ld t = dot(p - l[0], l[1] - l[0]) / norm(l[1] - l[0]);
    return l[0] + (l[1] - l[0]) * t;
}
Point refl(Point p, Line l) {//対象な点
    return p + (proj(p, l) - p) * 2;
}
bool isinterPL(Point p, Line l) {//点pが直線lに含まれるか
    return (abs(p - proj(p, l)) < eps);
}
bool isinterPS(Point p, Line s) {//点pが線分sに含まれるか
    return (ccw(s[0], s[1], p) == 0);
}
bool isinterLL(Line l, Line m) {//直線l,mが交わるか
    return (abs(cross(l[1] - l[0], m[1] - m[0])) > eps ||
            abs(cross(l[1] - l[0], m[0] - l[0])) < eps);
}
bool isinterSS(Line s, Line t) {//線分s,tが交わるか
    return (ccw(s[0], s[1], t[0]) * ccw(s[0], s[1], t[1]) <= 0 && 
            ccw(t[0], t[1], s[0]) * ccw(t[0], t[1], s[1]) <= 0);
}
ld distancePL(Point p, Line l) {//点pと直線lの距離
    return abs(p - proj(p, l));
}
ld distancePS(Point p, Line s) {//点pと線分sの距離
    Point h = proj(p, s);
    if (isinterPS(h, s)) { return abs(p - h); }
    return min(abs(p - s[0]), abs(p - s[1]));
}
ld distanceLL(Line l, Line m) {//直線l,mの距離
    if (isinterLL(l, m)) return 0;
    else return distancePL(m[0], l);
}
ld distanceSS(Line s, Line t) {//線分s,tの距離
    if (isinterSS(s, t)) return 0;
    else return min(min(distancePS(s[0], t), distancePS(s[1], t)), min(distancePS(t[0], s), distancePS(t[1], s)));
}

int n1,n2;
Point p1[55],p2[55];
Line l1[55],l2[55];

void solve(){
  cin >> n1;
  p1[0].x=0;p1[0].y=0;
  p1[n1+1].x=1000;p1[n1+1].y=0;
  rep(i,n1){
    cin >> p1[i+1].x >> p1[i+1].y;
  }
  rep(i,n1+1){
    l1[i][0]=p1[i];l1[i][1]=p1[i+1];
  }
  cin >> n2;
  p2[0].x=0;p2[0].y=1000;
  p2[n2+1].x=1000;p2[n2+1].y=1000;
  rep(i,n2){
    cin >> p2[i+1].x >> p2[i+1].y;
  }
  rep(i,n2+1){
    l2[i][0]=p2[i];l2[i][1]=p2[i+1];
  }
  ld ans=INF;
  rep(i,n1+1){
    rep(j,n2+1){
      ans=min(ans,distanceSS(l1[i],l2[j]));
    }
  }
  cout << ans << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}


Measured memory_bytes: 3340