#include <cstdio>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>

using namespace std;

#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) (EQ((a).real(),(b).real()) && EQ((a).imag(),(b).imag()))

typedef complex<double> P;
typedef pair<P,P> Edge;
typedef long long ll;

const double PI=4*atan(1.0);
const int MAX_SIZE = 10000;

// àÏ
double dot(P a, P b) {
  return (a.real() * b.real() + a.imag() * b.imag());
}
// OÏ
double cross(P a, P b) {
  return (a.real() * b.imag() - a.imag() * b.real());
}
// _cª¼üabãÉ é©È¢©
int is_point_on_line(P a, P b, P c) {
  return EQ( cross(b-a, c-a), 0.0 );
}
// 2¼üÌ¼s»è
int is_orthogonal(P a1, P a2, P b1, P b2) {
  return EQ( dot(a1-a2, b1-b2), 0.0 );
}
// 2¼üÌ½s»è
int is_parallel(P a1, P a2, P b1, P b2) {
  return EQ( cross(a1-a2, b1-b2), 0.0 );
}
// _a,bðÊé¼üÆ_cÌÔÌ£
double distance_l_p(P a, P b, P c) {
  return abs(cross(b-a, c-a)) / abs(b-a);
}
// _a,bð[_Æ·éüªÆ_cÆÌ£
double distance_ls_p(P a, P b, P c) {
  if ( dot(b-a, c-a) < EPS ) return abs(c-a);
  if ( dot(a-b, c-b) < EPS ) return abs(c-b);
  return abs(cross(b-a, c-a)) / abs(b-a);
}
// a1,a2ð[_Æ·éüªÆb1,b2ð[_Æ·éüªÌð·»è
int is_intersected_ls(P a1, P a2, P b1, P b2) {
    // üªª½sÈêÍdÈÁÄ¢È¢±ÆÉ·é
    if(abs(cross(a2-a1,b2-b1)) < EPS){
        return 0;
    }
    return ( cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1) < EPS ) &&
        ( cross(b2-b1, a1-b1) * cross(b2-b1, a2-b1) < EPS );
}

int na;
int nb;
P ap[1001];
P bp[1001];
const int INF=1000000000;

int main(){

	cin>>na>>nb;
	for(int i=0;i<na;i++){
		int x,y;
		cin>>x>>y;
		ap[i]=P(x,y);
	}
	for(int i=0;i<nb;i++){
		int x,y;
		cin>>x>>y;
		bp[i]=P(x,y);
	}
	// ½s,Ü½ÍNXµÈ¢
	if(!is_intersected_ls(ap[0],ap[1],bp[0],bp[1])){
		double res=abs(ap[0]-ap[1])+abs(bp[0]-bp[1]);
		printf("%.10f\n",res);
	}
	else{
		double res=INF;
		// apðÅèµÄbpð®©·
		for(int i=2;i<nb;i++)
			if(!is_intersected_ls(ap[0],ap[1],bp[0],bp[i])&&!is_intersected_ls(ap[0],ap[1],bp[i],bp[1]))
				res=min(res,abs(ap[0]-ap[1])+abs(bp[0]-bp[i])+abs(bp[1]-bp[i]));
		for(int i=2;i<nb;i++){
			for(int j=2;j<nb;j++){
				if(i==j)continue;
				if(!is_intersected_ls(ap[0],ap[1],bp[0],bp[i])&&!is_intersected_ls(ap[0],ap[1],bp[i],bp[j])&&!is_intersected_ls(ap[0],ap[1],bp[j],bp[1]))
					res=min(res,abs(ap[0]-ap[1])+abs(bp[0]-bp[i])+abs(bp[1]-bp[j])+abs(bp[i]-bp[j]));
			}
		}

		// bpðÅèµÄapð®©·
		for(int i=2;i<na;i++)
			if(!is_intersected_ls(bp[0],bp[1],ap[0],ap[i])&&!is_intersected_ls(bp[0],bp[1],ap[i],ap[1]))
				res=min(res,abs(bp[0]-bp[1])+abs(ap[0]-ap[i])+abs(ap[1]-ap[i]));
		for(int i=2;i<na;i++){
			for(int j=2;j<na;j++){
				if(i==j)continue;
				if(!is_intersected_ls(bp[0],bp[1],ap[0],ap[i])&&!is_intersected_ls(bp[0],bp[1],ap[i],ap[j])&&!is_intersected_ls(bp[0],bp[1],ap[j],ap[1]))
					res=min(res,abs(bp[0]-bp[1])+abs(ap[0]-ap[i])+abs(ap[1]-ap[j])+abs(ap[i]-ap[j]));
			}
		}
		if(EQ(res,INF))cout<<-1<<endl;
		else printf("%.10f\n",res);
	}
	return 0;
}

Measured memory_bytes: 888