#include <bits/stdc++.h>
#define x real()
#define y imag()
using namespace std;
typedef complex<double> point;
vector <point> pl;

double dot(point a,point b){return a.x*b.x+a.y*b.y;}
double cross(point a,point b){return a.x*b.y-a.y*b.x;}
int ccw(point a,point b,point c){
  point d = b-a,e = c-a;
  if(cross(d,e)>0) return 1;//"COUNTER_CLOCKWISE"
  if(cross(d,e)<0) return -1;//"CLOCKWISE"
  if(dot(d,e)<0) return 2;//"ONLINE_BACK"
  if(abs(d) < abs(e)) return -2;//"ONLINE_FRONT"
  return 0;//"ON_SEGMENT"
}

point crosspoint(point a,point b,point c,point d){
  a-=d;b-=d;c-=d;
  return d+a+(b-a)*imag(a/c)/imag(a/c-b/c);
}

bool intersection(point a,point b,point c,point d){
  return (ccw(a,b,c)*ccw(a,b,d)<=0&&ccw(c,d,a)*ccw(c,d,b)<=0);
}

vector<point> ConvexCut(vector<point> &polygon,point a,point b){
  vector <point> res;
  for(int i=0;i<polygon.size();i++){
    point A=polygon[i],B=polygon[(i+1)%polygon.size()];
    if(ccw(a,b,A)!=-1)res.push_back(A);
    if(ccw(a,b,A)*ccw(a,b,B)==-1)res.push_back(crosspoint(a,b,A,B));
  }
  return res;
}

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


int main(){
  int n;
  cin>>n;
  for(int i=0,a,b;i<n;i++) cin>>a>>b,pl.push_back(point(a,b));

  int m;
  cin>>m;
  for(int i=0,c,d;i<m;i++){
    cin>>c>>d;
    point a,b;
    a=point(c,d);
    cin>>c>>d;
    b=point(c,d);
    vector<point> res=ConvexCut(pl,a,b);
    printf("%.8f\n",get_area(res));
  }


  return 0;
}