#include<bits/stdc++.h>
#define EPS (1e-8)
using namespace std;
typedef complex<double> point;
typedef pair<point,point> line;

//??????
double dot(point a,point b){
  return real(conj(a)*b);
}

//??????
double cross(point a,point b){
  return imag(conj(a)*b);
}

point crosspoint_ll(line l1, line l2){
  double a=cross(l1.second-l1.first,l2.second-l2.first);
  double b=cross(l1.second-l1.first,l1.second-l2.first);
  if(fabs(a)<EPS&&fabs(b)<EPS)return l2.first;
  else if(fabs(a)>=EPS) return l2.first+b/a*(l2.second-l2.first);
} 

int ccw(point a,point b,point c){
  point d=b-a;
  point e=c-a;
  if(cross(d,e)>0)return 1;//?????´
  if(cross(d,e)<0)return -1;//?????´
  if(dot(d,e)<0)return 2;//onlineback
  if(abs(d)<abs(e))return -2;//onlinefront
  return 0;//onsegment
}

vector<point> Convex_Cut(vector<point> polygon,line l){
  vector<point> res;
  for(int i=0;i<polygon.size();i++){
    point a=polygon[i],b=polygon[(i+1)%polygon.size()];
    if(ccw(l.first,l.second,a)!=-1)res.push_back(a);
    if(ccw(l.first,l.second,a)*ccw(l.first,l.second,b)<0)
      res.push_back(crosspoint_ll(line(a,b),l));
  }
  return res;
}

double get_area(vector<point> polygon){
  double res=0;
  for(int i=0;i<polygon.size();i++)
    res+=cross(polygon[i],polygon[(i+1)%polygon.size()]);
  return res/2;
}

int main(){
  int n,q,x,y;
  vector<point> v;
  cin>>n;
  for(int i=0;i<n;i++)
    cin>>x>>y,v.push_back(point(x,y));
  cin>>q;
  for(int i=0;i<q;i++){
    point p1,p2;
    cin>>x>>y;
    p1=point(x,y);
    cin>>x>>y;
    p2=point(x,y);
    printf("%.8f\n",get_area(Convex_Cut(v,line(p1,p2))));
  }
  return 0;
}