#include<iostream>
#include<set>
#include<cstdio>
#include<vector>
#include<complex>
#include<algorithm>
#include<queue>
using namespace std;

const int NODE = 300 * 300 + 10;
typedef struct {int t;double cost;}Edge;
vector<Edge> edge[NODE];
bool          ben[NODE];

const double eps = 1e-10;
typedef complex<double> P;
typedef pair<P,P>       Line;

namespace std{
  bool operator==(const P &a,const P & b){
    if (abs(a.real()-b.real()) < 1e-10 && abs(a.imag()-b.imag())<eps)return true;
    return false;
  }
  bool operator<(const P &a,const P & b){
    if (abs(a.real()-b.real()) > 1e-10)return a.real() < b.real();
    return a.imag() < b.imag();
  }
};

double cross(P a,P b){
 return ( a.real()*b.imag() - a.imag()*b.real());
}

bool is_point_online(P a,P b,P c){
 return ( abs(a-c)+abs(b-c) < abs(a-b)+eps);
}

bool is_intersected_ls(P a1,P a2,P b1,P b2){
 if ( is_point_online(a1,a2,b1))return true;
 if ( is_point_online(a1,a2,b2))return true;
 if ( is_point_online(b1,b2,a1))return true;
 if ( is_point_online(b1,b2,a2))return true;
 if (  ( cross(a2-a1,b1-a1) * cross(a2-a1,b2-a1)<eps ) && 
    ( cross(b2-b1,a1-b1)*cross(b2-b1,a2-b1)<eps))return true;
 else return false;
}

P intersection_ls(P a1,P a2,P b1,P b2){
 P b = b2-b1;
 double d1=abs(cross(b,a1-b1));
 double d2=abs(cross(b,a2-b1));
 double t = d1/(d1+d2);
 return a1+(a2-a1)*t;
}



pair<int,int> makegraph(vector<Line> &in,vector<P> & stop,P &s,P &t,int &n){
  vector<P> a=stop;
  
  a.push_back(s);
  a.push_back(t);
  for(int i=0;i<(int)in.size();i++){
    a.push_back(in[i].first);
    a.push_back(in[i].second);
    for(int j=i+1;j<(int)in.size();j++){
      
      if (is_intersected_ls(in[i].first,in[i].second,in[j].first,in[j].second)){
	a.push_back(intersection_ls(in[i].first,in[i].second,in[j].first,in[j].second));
      }
    }
  }
  sort(a.begin(),a.end());
  a.erase(unique(a.begin(),a.end()),a.end());
  /*
  for(int i=0;i<a.size();i++){
    cout << a[i] <<" " ;
  }
  cout << endl;
  */
  n = a.size();
  for(int i=0;i<(int)in.size();i++){
    
    vector<pair<P,int> > cand;
    for(int j=0;j<(int)a.size();j++){
      if (is_point_online(in[i].first,in[i].second,a[j]))cand.push_back(make_pair(a[j],j));
    }
    sort(cand.begin(),cand.end());
    /*
    for(int j=0;j<cand.size();j++){
      cout << cand[j].second <<" " << cand[j].first << endl;
    }
    cout << endl;
    */
    for(int j=1;j<(int)cand.size();j++){
      int f = cand[j-1].second;
      int t = cand[j ].second;
      double len = abs(cand[j-1].first - cand[j].first);
      edge[f].push_back((Edge){t,len});
      edge[t].push_back((Edge){f,len});
    }
  }
  
  pair<int,int> ret;
  for(int i=0;i<(int)a.size();i++){
    if (abs(s-a[i]) < eps)ret.first = i;
    if (abs(t-a[i]) < eps)ret.second = i;
  }
  
  for(int i=0;i<(int)stop.size();i++){
    for(int j=0;j<(int)a.size();j++){
      if (abs(stop[i]-a[j]) < eps)ben[j] = true;
    }
  }
  return ret;
}

bool neighbor[NODE];
bool vis[NODE];
set<pair<int,int> > S;
void dfs(int now,double &a){
  if (vis[now])return;
  vis[now] = true;
  if (ben[now])return;
  for(int i=0;i<(int)edge[now].size();i++){
    int next =edge[now][i].t;
    double cost = edge[now][i].cost;
    int ta=now,tb=next;
    if (ta > tb)swap(ta,tb);
    if (S.count(make_pair(ta,tb)) == 0){
      a += cost,S.insert(make_pair(ta,tb));
    }
    dfs(next,a);
  }
}
double bfs(int s){
  queue<int> Q;
  double ret = 0;
  Q.push(s);
  vis[s] = true;
  while(!Q.empty()){
    int now = Q.front();Q.pop();
    for(int i=0;i<(int)edge[now].size();i++){
      int next = edge[now][i].t;
      int ta = now,tb = next;
      if (ta > tb)swap(ta,tb);
      if (S.count(make_pair(ta,tb)) == 0){
	ret += edge[now][i].cost;
	S.insert(make_pair(ta,tb));
      }
      if (vis[next] || neighbor[next])continue;
      if (!vis[next] && !neighbor[next]){
	Q.push(next);
	vis[next] = true;
      }
    }
  }
  return ret;
}

double solve(int n,int s,int t,double sum){
  double ta = 0;
  S.clear();
  for(int i=0;i<n;i++){
    vis[i] =false;
  }
  
  dfs(t,ta);
  if (vis[s]){
    return -1;
  }
  for(int i=0;i<n;i++){
    neighbor[i] = vis[i];
  }
  
  for(int i=0;i<n;i++){
    vis[i] =false;
  }
  S.clear();
  double tb = bfs(s);
  double tmp = sum;
  for(int i=0;i<n;i++){
    for(int j=0;j<edge[i].size();j++){
      int now =i,next=edge[i][j].t;
      if (now > next)continue;
      if (S.count(make_pair(now,next)) == 0){
	tmp -= edge[i][j].cost;
      }
    }
  }
  
  return sum - tmp;
}

int main(){
  int n,m;
  while(cin>>n>>m && n){
    P s,t;
    double sum = 0;
    for(int i=0;i<NODE;i++){
      edge[i].clear();
      ben[i] = false;
    }
    vector<Line> in(n);
    vector<P> stop(m);
    for(int i=0;i<n;i++){
      cin>>in[i].first.real()>>in[i].first.imag();
      cin>>in[i].second.real()>>in[i].second.imag();
      sum += abs(in[i].first-in[i].second);
    }
    for(int j=0;j<m;j++){
      cin>>stop[j].real()>>stop[j].imag();
    }
    cin>>s.real()>>s.imag();
    cin>>t.real()>>t.imag();
    int node;
    pair<int,int> tmp = makegraph(in,stop,s,t,node);
    /*
    for(int i=0;i<node;i++){
      cout << i <<" is ben? " << ben[i] << endl;
      for(int j=0;j<edge[i].size();j++){
	cout << i <<" " << edge[i][j].t << " " << edge[i][j].cost << endl;
      }
      cout <<"-"<<endl;
    }
    cout << "----------------------------" << endl;
    */
    
    printf("%.10lf\n",solve(node,tmp.first,tmp.second,sum));
  }
  return 0;
}

Measured memory_bytes: 6020