#pragma GCC opmize(2)
#pragma GCC opmize(2)
#include<bits/stdc++.h>
#define mem(a) memset(a, 0, sizeof a)
#define Buff ios::sync_with_stdio(false)
using namespace std;
const double eps = 1e-6;
const double PI = acos(-1);
const int N = 1e5+7;
int dcmp(double x)
{
    if(fabs(x) < eps)   return 0;
    else                return x < 0 ? -1 : 1;
}
//直线，向量
struct Point
{
    double x;
    double y;
    Point(double x=0, double y=0):x(x), y(y) {}
};
typedef Point Vector;
double operator * (const Vector & v, const Vector & w)  {return v.x * w.x + v.y * w.y;}
double operator ^ (const Vector & v, const Vector & w)  {return v.x * w.y - v.y * w.x;}
Vector operator - (const Vector & v, const Vector & w)  {return {v.x - w.x, v.y - w.y};}
Vector operator + (const Vector & v, const Vector & w)  {return {v.x + w.x, v.y + w.y};}
Vector operator * (const Vector & v, double k)          {return {v.x * k, v.y * k};}
double sqr(Vector v)                                    {return v * v;}
double length(Vector v)                                 {return sqrt(v * v);}
bool OnSeg(Point O, Point A, Point B)                   {return !dcmp((A - O) ^ (B - O)) && dcmp((A - O) * (B - O)) <= 0;}
Vector rotate(Vector v, double rad)                     {return {v.x * cos(rad) - v.y * sin(rad), v.x * sin(rad) + v.y * cos(rad)};}
Vector normal(Vector v)                                 {return Vector(-v.y/length(v), v.x/length(v));}
bool operator == (const Point & A, const Point & B)     {return !dcmp(A.x-B.x) && !dcmp(A.y-B.y);}
bool operator < (const Vector & v, const Vector & w)    {return v.y == w.y ? v.x < w.x : v.y < w.y;}
struct Line
{
    Point p;
    Vector v;
    double ang;
    Line()  {}
    Line(Point p, Vector v) : p(p), v(v) {ang = atan2(v.y, v.x);}
    Point point(double t)           {return p + v * t;}
    bool operator < (Line & l)      {return ang < l.ang;}
    Line move(double t)             {return Line(p + normal(v) * t, v);}
    bool Onleft(Point P)            {return dcmp(v ^ (P - p)) > 0;}
    Point operator & (Line & l)
    {
        Vector u = p - l.p;
        double t = (l.v ^ u) / (v ^ l.v);
        return p + v * t;
    }
};
vector<Point> res;
bool cmp(Point a, Point b)//极角排序
{
    double t = (a - res[0]) ^ (b - res[0]);
    if(dcmp(t) < 0)   return false;
    if(!t && length(a - res[0]) > length(b - res[0]))   return false;
    return true;
}
double area(vector<Point>Polygon)
{
    sort(Polygon.begin(), Polygon.end(), cmp);
    int n = Polygon.size();
//    cout << n <<endl;
    double ans=0;
    for(int i = 1; i < n-1; i++)
    {
        ans += (Polygon[i] - Polygon[0]) ^ (Polygon[i + 1] - Polygon[0]);
//        cout << ans <<endl;
    }
//    puts("++++++++++++");
    return fabs(ans/2);
}
int n, m;
Point p[N];
Line l;

int main()
{
    scanf("%d", &n);
    for(int i = 0 ; i < n; i++)
    {
        double a, b;
        scanf("%lf%lf", &a, &b);
        p[i] = {a, b};
    }
    scanf("%d", &m);
    while(m --)
    {
        double a, b, c, d;
        scanf("%lf%lf%lf%lf", &a, &b, &c, &d);
        l = Line({a, b}, {c - a, d - b});
        int left = 0, right = 0, mid = 0;
        for(int i = 0; i < n; i ++)
            if(l.Onleft(p[i]))  res.push_back(p[i]);
        for(int i = 0; i < n; i ++)
            if(l.Onleft(p[i]) != l.Onleft(p[(i + 1) % n]))
            {
                Point t = (Line(p[i], p[i] - p[(i + 1) % n])) & l;
                res.push_back(t);
                if(res.size())
                {
                    if(res.back() < res[0])
                        swap(res.back(), res[0]);
                }
            }
        printf("%.10f\n", area(res));
        res.clear();
    }
    return 0;
}

