#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);++i)
#define rep2(i,a,b) for (int i=(a);i<(b);++i)
#define rrep(i,n) for (int i=(n)-1;i>=0;--i)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;--i)
#define chmin(a,b) (a)=min((a),(b));
#define chmax(a,b) (a)=max((a),(b));
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(_v) cout<<(#_v)<<":";for(auto(_x):(_v)){cout<<" "<<(_x);}cout<<endl;
#define printVS(vs) cout<<(#vs)<<":"<<endl;for(auto(s):(vs)){cout<<(s)<< endl;}
#define printVV(vv) cout<<(#vv)<<":"<<endl;for(auto(v):(vv)){for(auto(x):(v)){cout<<" "<<(x);}cout<<endl;}
#define printP(p) cout<<(#p)<<(p).first<<" "<<(p).second<<endl;
#define printVP(vp) cout<<(#vp)<<":"<<endl;for(auto(p):(vp)){cout<<(p).first<<" "<<(p).second<<endl;}

inline void output(){ cout << endl; }
template<typename First, typename... Rest>
inline void output(const First& first, const Rest&... rest) {
    cout << first << " "; output(rest...);
}

using ll = long long;
using Pii = pair<int, int>;
using TUPLE = tuple<int, int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
const int inf = 1e9;
const int mod = 1e9 + 7;
using Graph = vector<vector<int>>;

using P = complex<double>;
using G = vector<P>;
#define here(g, i) g[i]
#define next(g, i) g[(i + 1) % g.size()]
#define prev(g, i) g[(i - 1 + g.size()) % g.size()]
const double EPS = 1e-8;
const double INF = 1e12;
const double PI = acos(-1);
inline int sgn(double a, double b = 0) { return a < b - EPS ? -1 : a > b + EPS ? 1 : 0; }

struct L {
    P a, b, v, h;
    L(){}
    L(P _a, P _b) : a(_a), b(_b), v(b - a), h(v / abs(v) * P(0, 1)) {}
    L(double _ax, double _ay, double _bx, double _by) : L(P(_ax, _ay), P(_bx, _by)) {}
    void trans(double d) {
        a += d * h;
        b += d * h;
    }
    void print() {
        cerr << "{(" << a.real() << ", " << a.imag() << "), (" << b.real() << ", " << b.imag() << ")}" << endl;
    }
};
using S = L;

P readP() {
    double x, y;
    cin >> x >> y;
    return P(x, y);
}

double cross(P a, P b) {
    return imag(conj(a) * b);
}

double dot(P a, P b) {
    return real(conj(a) * b);
}

int ccw(P p0, P p1, P p2) {
    p1 -= p0; p2 -= p0;
    if (sgn(cross(p1, p2)) == 1) return +1;         // counter-clockwise
    if (sgn(cross(p1, p2)) == -1) return -1;        // clockwise
    if (sgn(dot(p1, p2)) == -1) return +2;          // p2 -- p0 -- p1
    if (sgn(norm(p1), norm(p2)) == -1) return -2;   // p0 -- p1 -- p2
    return 0;                                       // p0 -- p2 -- p1
}

// !! ???????????????????????¨?????? "<" !!
bool intersectSS(L l1, L l2) {
    return (ccw(l1.a, l1.b, l2.a) * ccw(l1.a, l1.b, l2.b) < 0 &&
            ccw(l2.a, l2.b, l1.a) * ccw(l2.a, l2.b, l1.b) < 0);
}

int n[2];
P p[2][1000];

main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    rep(i, 2) cin >> n[i];
    rep(k, 2) {
        rep(i, n[k]) {
            p[k][i] = readP();
        }
    }

    double ans = INF;
    rep(k, 2) {
        S wall(p[k^1][0], p[k^1][1]);
        rep(i, n[k]) {
            rep(j, n[k]) {
                vector<S> segs;
                segs.emplace_back(S(p[k][0], p[k][i]));
                segs.emplace_back(S(p[k][i], p[k][j]));
                segs.emplace_back(S(p[k][j], p[k][1]));
                if (none_of(all(segs), [&](S s){return intersectSS(s, wall);})) {
                    chmin(ans, [&](){
                        double ret = abs(wall.a - wall.b);
                        for (auto s : segs) {
                            ret += abs(s.a - s.b);
                        }
                        return ret;
                    }());
                }
            }
        }
    }

    cout << fixed << setprecision(10) << (sgn(ans, INF) >= 0 ? -1 : ans) << endl;
}

Measured memory_bytes: 3376