#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int,int> P;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max()/2;
const int MOD = 1e9+7;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

typedef long double ld;
typedef complex<ld> Point;

const ld eps = 1e-9, pi = acos(-1.0);

namespace std {
	bool operator<(const Point &lhs, const Point &rhs) {
		if (lhs.real() < rhs.real() - eps) return true;
		if (lhs.real() > rhs.real() + eps) return false;
		return lhs.imag() < rhs.imag();
	}
}

Point input_point() {
	ld x, y;
	cin >> x >> y;
	return Point(x, y);
}

bool eq(ld a, ld b) {
	return (abs(a - b) < eps);
}

// dot of a and b
ld dot(Point a, Point b) {
	return real(conj(a) * b);
}

// cross of a and b
ld cross(Point a, Point b) {
	return imag(conj(a) * b);
}

class Line {
public:
	Point a, b;
	Line() : a(Point(0, 0)), b(Point(0, 0)) {}
	Line(Point a, Point b) : a(a), b(b) {}
};

// CCW::counter clockwise
int ccw(Point a, Point b, Point c) {
	b -= a; c -= a;
	if (cross(b, c) > eps) return 1;   // a,b,c : counter-clockwise
	if (cross(b, c) < -eps) return -1; // a,b,c : clockwise
	if (dot(b, c) < 0) return 2;       // c,a,b : on a line
	if (norm(b) < norm(c)) return -2;  // a,b,c : on a line
	return 0;                          // a,c,b : on a line
}

bool isis_ss(Line s, Line 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;
}

ld dist_pp(Point a, Point b){
    ld d = (a.imag()-b.imag())*(a.imag()-b.imag())+(a.real()-b.real())*(a.real()-b.real());
    return sqrt(d);
}

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

    int na,nb;cin>>na>>nb;
    vector<vector<ld>> dis(1111,vector<ld>(1111,INF));
    vector<Point> tota(na),tute(nb);
    for(int i=0;i<na;i++){
        tota[i]=input_point();
    }
    for(int i=0;i<nb;i++){
        tute[i]=input_point();
    }
    ld res=INF;
    Line l=Line(tota[0],tota[1]);
    for(int i=0;i<nb;i++) dis[i][i]=0;
    for(int i=0;i<nb;i++){
        for(int j=i+1;j<nb;j++){
            Line ltmp=Line(tute[i],tute[j]);
            if(isis_ss(l,ltmp)) continue;
            ld dtmp=dist_pp(tute[i],tute[j]);
            dis[i][j]=dis[j][i]=dtmp;
        }
    }
    for(int k=0;k<nb;k++){
        for(int i=0;i<nb;i++){
            for(int j=0;j<nb;j++){
                dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
            }
        }
    }
    if(dis[0][1]>=INF) ;
    else{
        res=dist_pp(tota[0],tota[1]) + dis[0][1];
    }

    l =Line(tute[0],tute[1]);
    for(int i=0;i<na;i++)for(int j=i+1;j<na;j++)dis[i][j]=dis[j][i]=INF;
    for(int i=0;i<na;i++){
        for(int j=i+1;j<na;j++){
            Line ltmp=Line(tota[i],tota[j]);
            if(isis_ss(l,ltmp)) continue;
            ld dtmp=dist_pp(tota[i],tota[j]);
            dis[i][j]=dis[j][i]=dtmp;
        }
    }
    for(int k=0;k<na;k++){
        for(int i=0;i<na;i++){
            for(int j=0;j<na;j++){
                dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
            }
        }
    }
    if(dis[0][1]>=INF) ;
    else{
        res=min(res,dist_pp(tute[0],tute[1]) + dis[0][1]);
    }
    if(res>=INF) cout<<-1<<endl;
    else cout<<fixed<<setprecision(10)<<res<<endl;
}


Measured memory_bytes: 22428