#include<cstdio>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;

#define mp make_pair
#define fi first
#define se second
#define pb push_back
typedef double db;
const db eps=1e-6;
const db pi=acos(-1.0);

int sign(db k){//-----------
    if (k>eps) return 1; else if (k<-eps) return -1; return 0;
}
int cmp(db k1,db k2){return sign(k1-k2);}  //-----------
struct point{
    db x,y;
    // point (double _x =0,double _y=0){x=_x;y=_y;}//------
    // point operator + (const point &k1) const {return point(k1.x+x,k1.y+y);}//------
    // point operator - (const point &k1) const {return point(x-k1.x,y-k1.y);}//------
    // point operator * (db k1) const  {return point(x*k1,y*k1);};//--------
    // point operator / (db k1) const{return point(x/k1,y/k1);}
    point operator + (const point &k1) const{return (point){k1.x+x,k1.y+y};}  //两个点相加-----
    point operator - (const point &k1) const{return (point){x-k1.x,y-k1.y};}  //两个点相减------
    point operator * (db k1) const{return (point){x*k1,y*k1};}  //与原点的距离扩大k1倍-------
    point operator / (db k1) const{return (point){x/k1,y/k1};}  //与原点的距离缩小k1倍
    int operator == (const point &k1) const{return cmp(x,k1.x)==0&&cmp(y,k1.y)==0;}  //判断两个点相等
    point turn(db k1){return (point){x*cos(k1)-y*sin(k1),x*sin(k1)+y*cos(k1)};} // 绕原点逆时针旋转
    point turn2(db k1, point p){return p+((*this)-p).turn(k1);}//绕p逆时针旋转k1度
    point turn90(){return (point){-y,x};}   //逆时针旋转90度
    //在点k1左边返回1 相等时在下边返回1  根据（x，y）排序-------------
    bool operator < (const point k1) const{
        int a=cmp(y,k1.y);
        if (a==-1) return 1; else if (a==1) return 0; else return cmp(x,k1.x)==-1;
    }
    db abs(){return sqrt(x*x+y*y);}//返回距离原点欧式距离
    db abs2(){return x*x+y*y;}  //返回距离原点欧式距离的平方
    db dis(point k1){return ((*this)-k1).abs();}    //返回两个点之间的欧式距离
    point unit(){db w=abs(); return (point){x/w,y/w};}  //返回单位向量
    void scan(){double k1,k2; scanf("%lf%lf",&k1,&k2); x=k1; y=k2;} //输入一个点--------
    void print(){printf("%.f %.f\n",x,y);}    //输出一个点--------
    db getw(){return atan2(y,x);}   //返回方位角  取值[-π，π]
    //如果 x>=0&&y>=0 不变，其他关于原点对称
    point getdel(){if (sign(x)==-1||(sign(x)==0&&sign(y)==-1)) return (*this)*(-1); else return (*this);}
};
db cross(point k1,point k2){return k1.x*k2.y-k1.y*k2.x;}    //叉积-----
struct line{
    // p[0]->p[1]  p[0]起点
    point p[2];
    line(point k1,point k2){p[0]=k1; p[1]=k2;}//---------
    point& operator [] (int k){return p[k];}//-------
    int include(point k){return sign(cross(p[1]-p[0],k-p[0]))>0;} //在右侧-----
    point dir(){return p[1]-p[0];} //--------
    line push(){ // 向内 ( 右手边 ) 平移 eps
        const db eps = 1e-6;
        point delta=(p[1]-p[0]).turn90().unit()*eps;
        return {p[0]-delta,p[1]-delta};
    }
};

int clockwise(point k1,point k2,point k3){// k1 k2 与 k1 k3 逆时针 1 顺时针 -1 否则 0  ---------
    return sign(cross(k2-k1,k3-k1));
}
point getLL(point k1,point k2,point k3,point k4){//直线 k1-k2 与 k3-k4 的交点  (调用前保证两直线有唯一交点-----
    db w1=cross(k1-k3,k4-k3),w2=cross(k4-k3,k2-k3); return (k1*w2+k2*w1)/(w1+w2);
}
vector<point> convexcut(vector<point>A,point k1,point k2){
    // 保留 k1,k2,p 逆时针的所有点
    int n=A.size(); A.push_back(A[0]); vector<point>ans;
    for (int i=0;i<n;i++){
        int w1=clockwise(k1,k2,A[i]),w2=clockwise(k1,k2,A[i+1]);
        if (w1>=0) ans.push_back(A[i]);
        if (w1*w2<0) ans.push_back(getLL(k1,k2,A[i],A[i+1]));
    }
    return ans;
}
db area(vector<point> A){ // 多边形的面积，多边形用 vector<point> 表示 , 逆时针
    db ans=0;
    for (int i=0;i<A.size();i++) ans+=cross(A[i],A[(i+1)%A.size()]);
    return ans/2;
}
vector < point > ans;
int main()
{
    int n;
    ans.clear();
    scanf("%d", &n);
    for(int i = 0; i < n;i++)
    {
        point a;
        a.scan();
        ans.push_back(a);
    }
    int k;
    scanf("%d", &k);
    while(k--)
    {
        point a,b;
        a.scan();
        b.scan();
        vector < point > ans_ = convexcut(ans, a,b);
        db areas = area(ans_);
        printf("%.12f\n",areas);
    }
    return 0;
}



Measured memory_bytes: 2784