#include <bits/stdc++.h>
#include <unistd.h>
using namespace std;

const double eps = 1e-10;

int dcmp(double x) {
        if(fabs(x) < eps) return 0;
        return x < 0 ? -1 : 1;
}

bool same(double a, double b) {return dcmp(a - b) == 0;}
#define Vector P
struct P {
        double x, y;
        P(double x = 0, double y = 0): x(x), y(y) {}
        P operator + (P b) {return P(x + b.x, y + b.y);}
        P operator - (P b) {return P(x - b.x, y - b.y);}
        P operator * (double b) {return P(x * b, y * b);}
        P operator / (double b) {return P(x / b, y / b);}
        double operator * (P b) {return x * b.x + y * b.y;} // Dot
        double operator ^ (P b) {return x * b.y - y * b.x;} // Cross
        double abs() {return hypot(x, y);}
        P unit() {return *this / abs();}
        P spin(double o) {
                double c = cos(o), s = sin(o);
                return P(c * x - s * y, s * x + c * y);
        }
};

struct Line {
        //ax + by + c = 0
        double a, b, c, o;
        P pa, pb;
        Line(): a(0), b(0), c(0), o(0), pa(), pb() {}
        Line(P pa, P pb): a(pa.y - pb.y), b(pb.x - pa.x), c(pa ^ pb), o(atan2(-a, b)), pa(pa), pb(pb) {}    
                P projection(P p) {return pa + (pb - pa).unit() * ((pb - pa) * (p - pa) / (pb - pa).abs());}
                P reflection(P p) {return p + (projection(p) - p) * 2;}
        double get_ratio(P p) {return (p - pa) * (pb - pa) / ((pb - pa).abs() * (pb - pa).abs());}
        P dis(P p) {return ((pb - pa) ^ (p - pa)) / (pb - pa).abs();} // directed distance
};
bool is_parallel(Line l, Line r) {return same(l.a * r.b, l.b * r.a);}
P line_intersection(Line l, Line r) { // check l and r are not parallel first
        return P(l.b * r.c - l.c * r.b, l.c * r.a - l.a * r.c) / (l.a * r.b - l.b * r.a);
}
struct Circle {
        P c;
        double r;
        Circle(P c, double r = 0): c(c), r(r) {}
};
double dis(P a, P b) {return (a - b).abs();}
vector<P> ps;
bool cmp(Line a, Line b) {
        return same(a.o, b.o) ? dcmp((b.pb - b.pa) ^ (a.pb - b.pa)) == 1 : a.o < b.o;
}
bool check(Line l1, Line l2, Line l) {
        if(is_parallel(l1, l2)) return 0;
        P p = line_intersection(l1, l2);
        /*
        cout << "p: " << p.x << ' ' << p.y << '\n';
        cout << l.a << "x + " << l.b << "y + " << l.c << " = 0\n";
        cout << "pa: " << l.pa.x << ' ' << l.pa.y << " pb: " << l.pb.x << ' ' << l.pb.y << '\n';
        cout << "result = " << ((l.pb - l.pa) ^ (p - l.pa)) << "\n\n";
        */
        return dcmp((l.pb - l.pa) ^ (p - l.pa)) != -1;
}
vector<P> HPI(vector<Line> ls) {
        sort(ls.begin(), ls.end(), cmp);
        vector<Line> vec;
        for(int i = 0; i < int(ls.size()); i++) {
                if(!vec.empty() && dcmp(ls[i].o - vec.back().o) == 0) continue;
                vec.push_back(ls[i]);
        }
        deque<Line> dq;
        for(int i = 0; i < int(vec.size()); i++) {
                while(dq.size() >= 2 && !check(dq[dq.size() - 2], dq[dq.size() - 1], vec[i])) dq.pop_back();                while(dq.size() >= 2 && !check(dq[0], dq[1], vec[i])) dq.pop_front();
                dq.push_back(vec[i]);
        //for(int i = 0; i < dq.size(); i++) cout << dq[i].a << "x + " << dq[i].b << "y + " << dq[i].c << " = 0\n";

        }
        while(dq.size() >= 2 && !check(dq[dq.size() - 2], dq[dq.size() - 1], dq[0])) dq.pop_back();
        while(dq.size() >= 2 && !check(dq[0], dq[1], dq[dq.size() - 1])) dq.pop_front();
        //for(int i = 0; i < dq.size(); i++) cout << dq[i].a << "x + " << dq[i].b << "y + " << dq[i].c << " = 0\n";
        vector<P> res;
        for(int i = 0; i < dq.size(); i++) res.push_back(line_intersection(dq[i], dq[(i + 1) % dq.size()]));        return res;
}
double Area(vector<P> &p) {
        double res = 0;
        for(int i = 1; i < (int)p.size() - 1; i++)
                res += (p[i] - p[0]) ^ (p[i + 1] - p[0]);
        return res * 0.5;
}

int main() {
        ios_base::sync_with_stdio(false); cin.tie(0);
        int n; cin >> n;
        vector<Line> ls;
        for(int i = 0; i < n; i++) {
                P p; cin >> p.x >> p.y;
                ps.push_back(p);
        }
        for(int i = 0; i < n; i++) {
                ls.push_back(Line(ps[i], ps[(i + 1) % n]));
        }
        /*
        vector<P> v = HPI(ls);
        for(P p : v) cout << p.x << ' ' << p.y << '\n';
        */
        int q; cin >> q;
        while(q--) {
                vector<Line> lss = ls;
                P p1, p2; cin >> p1.x >> p1.y >> p2.x >> p2.y;
                lss.push_back(Line(p1, p2));
                vector<P> res = HPI(lss);

                double ans = Area(res);
                cout << fixed << setprecision(12) << ans << '\n';
        }
        return 0;
}


Measured memory_bytes: 3624