#include <iostream>
#include <iomanip>
#include <algorithm>
#include <assert.h>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e15;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const ll EPS = 1e-10;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> tri;
typedef pair<double,double> point;
typedef complex<double> Point;
const ll MAX = 30000;
constexpr ll nx[8] = {1,0,-1,0,1,-1,1,-1};
constexpr ll ny[8] = {0,1,0,-1,1,1,-1,-1};
int sgn(const double a){
    return (a < -EPS ? -1 : (a > EPS ? +1 : 0));
}
double dot(Point z1,Point z2){
    return (z1*conj(z2)).real();
}
double cross(Point z1,Point z2){
    return (conj(z1)*z2).imag();
}
int pplace(const Point& a,const Point& b,const Point& c){
    int f = sgn(cross(b-a,c-a));
    if (f == 1){
        return +1;//right
    }
    else if (f == -1){
        return -1;//left
    }
    else{
        if (sgn(dot(b-a,c-b)) > 0){
            return +2; //abc
        }
        else if (sgn(dot(a-b,c-a))){
            return -2; // cab
        }
        else{
            return 0; // acb etc.
        }
    }
}
struct Line{
    Point begin,end;

    Line(){
        begin = Point(-1,-1),end = Point(1,1);
    }
    Line(const Point& b,const Point&e){
        begin = b,end = e;
    }
    //ax+by+c = 0
    Line(const double a,const double b,const double c){
        if (sgn(a) == 0 && sgn(b) == 0){
            assert(-1);
        }
        if (sgn(b) == 0){
            begin = Point(-c/a,0.0);
            end = Point(-c/a,1.0);
        }
        else{
            begin = Point(0.0,-c/b);
            end = Point(1.0,-(a+c)/b);
        }
    }
    Point vec() const{
        return end - begin;
    }
    Point cvec() const{
        return begin - end;
    }

};

typedef Line Ray;
typedef Line Segment;

int parallel(const Line& l1,const Line& l2){
    if ((sgn(abs(l1.begin-l2.begin)) == 0 && sgn(abs(l1.end-l2.end)) == 0) || (sgn(abs(l1.begin-l2.end)) == 0 && sgn(abs(l1.end-l2.begin)) == 0)){
        return -1;
    }
    else if (sgn(cross(l1.vec(),l2.vec())) == 0){
        return 1;
    }
    else{
        return 0;
    }
}

Point lineIntersection(const Line& l1,const Line& l2){
    return l1.begin+l1.vec()*abs(cross(l2.end-l1.begin,l2.vec())/cross(l1.vec(),l2.vec()));
}

pair<int,Point> segmentIntersection(const Segment& s1,const Segment& s2){
    if (pplace(s1.begin,s1.end,s2.begin)*pplace(s1.begin,s1.end,s2.end) <= 0 &&
    pplace(s2.begin,s2.end,s1.begin)*pplace(s2.begin,s2.end,s1.end) <= 0){
        if (sgn(cross(s1.vec(),s2.vec())) == 0){
            return make_pair(-1,Point(0,0)); //parallel
        }
        else{
            return make_pair(1,lineIntersection(s1,s2));
        }
    }
    return make_pair(0,Point(0,0));
}

double distPointLine(const Point& p,const Line& l){
    return abs(cross(l.vec(),p-l.begin)/abs(l.vec()));
}

double distPointSegment(const Point& p,const Segment& s){
    if (sgn(dot(s.vec(),p-s.begin)) < 0 || sgn(dot(s.cvec(),p-s.end)) < 0){
        return min(abs(p-s.begin),abs(p-s.end));
    }
    return distPointLine(p,s);
}

double distSegmentSegment(const Segment& s1,const Segment& s2){
    if (segmentIntersection(s1,s2).first){
        return 0.0;
    }
    return min({distPointSegment(s1.begin,s2)
            ,distPointSegment(s1.end,s2)
            ,distPointSegment(s2.begin,s1)
            ,distPointSegment(s2.end,s1)});
}

int main(){
    //cin.tie(0);
    //ios::sync_with_stdio(false);
    ll n1,n2;
    cin >> n1;
    vector<Point> line1,line2;
    line1.push_back(Point(0.0,0.0));
    line2.push_back(Point(0.0,1000.0));
    rep(i,n1){
        double x,y;
        cin >> x >> y;
        line1.push_back(Point(x,y));
    }
    cin >> n2;
    rep(i,n2){
        double x,y;
        cin >> x >> y;
        line2.push_back(Point(x,y));
    }
    line1.push_back(Point(1000.0,0.0));
    line2.push_back(Point(1000.0,1000.0));
    double ans = 1e9;
    rep(i,n1+1){
        rep(j,n2+1){
            Segment s1(line1[i],line1[i+1]),s2(line2[j],line2[j+1]);
            chmin(ans,distSegmentSegment(s1,s2));
        }
    }
    printf("%.10lf\n",ans);
}



Measured memory_bytes: 3364