#include <bits/stdc++.h>
#include <cmath>

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = LONG_LONG_MAX / 100;
//const ll INF = (1ll << 31) - 1;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

//bool contain(set<P> &s, P a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
typedef priority_queue<long long, vector<long long>, greater<long long>> PQ_ASK;


void print_line(vector<string> &line) {
    if (line.size() == 0ll) {
        cout << endl;
        return;
    }
    for (ll i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}

#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)

struct Point {
    double x, y;

    Point(double x = 0, double y = 0) : x(x), y(y) {}

    Point operator+(Point p) { return Point(x + p.x, y + p.y); }

    Point operator-(Point p) { return Point(x - p.x, y - p.y); }

    Point operator*(double a) { return Point(a * x, a * y); }

    Point operator/(double a) { return Point(x / a, y / a); }

    double abs() { return sqrt(norm()); }

    double norm() { return x * x + y * y; }

    bool operator<(const Point &p) const {
        return x != p.x ? x < p.x : y < p.y;
    }

    bool operator==(const Point &p) const {
        return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
    }
};

typedef Point Vector;
typedef vector<Point> Polygon;


static const int IN = 2;
static const int ON = 1;
static const int OUT = 0;

double dot(Vector a, Vector b) {
    return a.x * b.x + a.y * b.y;
}

double cross(Vector a, Vector b) {
    return a.x * b.y - a.y * b.x;
}

static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;   // p2->p0->p1
static const int ONLINE_FRONT = -2; // p0->p1->p2
static const int ON_SEGMENT = 0;    // p0->p2->p1

double norm(Point a) {
    return a.x * a.x + a.y * a.y;
}

int ccw(Point p0, Point p1, Point p2) {
    Vector a = p1 - p0;
    Vector b = p2 - p0;
    if (cross(a, b) > EPS) return COUNTER_CLOCKWISE;
    if (cross(a, b) < -EPS) return CLOCKWISE;
    if (dot(a, b) < -EPS) return ONLINE_BACK;
    if (norm(a) < norm(b)) return ONLINE_FRONT;
    return ON_SEGMENT;
}

Polygon f(Polygon g) {
    Polygon u, l;
    if (g.size() < 3) return g;
    sort(g.begin(), g.end());
    u.push_back(g[0]);
    u.push_back(g[1]);
    l.push_back(g[g.size() - 1]);
    l.push_back(g[g.size() - 2]);

    // upper
    for (int i = 2; i < g.size(); i++) {
        for (int n = u.size(); n >= 2 && ccw(u[n - 2], u[n - 1], g[i]) == COUNTER_CLOCKWISE; n--) {
            u.pop_back();
        }
        u.push_back(g[i]);
    }

    // lower
    for (int i = g.size() - 3; i >= 0; i--) {
        for (int n = l.size(); n >= 2 && ccw(l[n - 2], l[n - 1], g[i]) == COUNTER_CLOCKWISE; n--) {
            l.pop_back();
        }
        l.push_back(g[i]);
    }

    reverse(l.begin(), l.end());
    for (int i = u.size() - 2; i >= 1; i--) l.push_back(u[i]);

    return l;
}


double abs(Point a) {
    return sqrt(norm(a));
}


double getDistance(Point a, Point b) {
    return abs(a - b);
}


double convexDiameter(Polygon g) {
    double d = 0.0;
    int n = g.size();
    int is = 0, js = 0;
    for (int i = 1; i < n; i++) {
        if (g[i].y > g[is].y) is = i;
        if (g[i].y < g[js].y) js = i;
    }
    d = getDistance(g[is], g[js]);

    int i = is, j = js, maxi = is, maxj = js;
    do {
        if (cross(g[(i + 1) % n] - g[i], g[(j + 1) % n] - g[j]) >= 0.0) j = (j + 1) % n;
        else i = (i + 1) % n;
        if (getDistance(g[i], g[j]) > d) {
            d = getDistance(g[i], g[j]);
            maxi = i, maxj = j;
        }
    } while (i != is || j != js);

    return d;
}

struct Segment {
    Point p1, p2;

    Segment(Point p1, Point p2) : p1(p1), p2(p2) {}
};

typedef Segment Line;

bool isParallel(Vector a, Vector b) {
    return equals(cross(a, b), 0.0);
}

bool isParallel(Point a1, Point a2, Point b1, Point b2) {
    return isParallel(a1 - a2, b1 - b2);
}

bool isParallel(Segment s1, Segment s2) {
    return equals(cross(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0);
}



bool intersect(Point p1, Point p2, Point p3, Point p4){
    return (ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0 &&
            ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0);
}
bool intersect(Segment s1, Segment s2){
    return intersect(s1.p1, s1.p2, s2.p1, s2.p2);
}



Point getCrossPoint(Segment s1, Segment s2){
    Vector base = s2.p2 - s2.p1;
    double d1 = abs(cross(base, s1.p1-s2.p1));
    double d2 = abs(cross(base, s1.p2-s2.p1));
    double t = d1 / (d1 + d2);
    return s1.p1 + (s1.p2 - s1.p1) * t;
}



Polygon andrewScan(Polygon g){
    Polygon u, l;
    if(g.size() < 3)    return g;
    sort(g.begin(), g.end());
    u.push_back(g[0]);
    u.push_back(g[1]);
    l.push_back(g[g.size()-1]);
    l.push_back(g[g.size()-2]);

    // upper
    for(int i = 2; i < g.size(); i++){
        for(int n = u.size(); n >= 2 && ccw(u[n-2], u[n-1], g[i]) != CLOCKWISE; n--){
            u.pop_back();
        }
        u.push_back(g[i]);
    }

    // lower
    for(int i = g.size()-3; i >= 0; i--){
        for(int n = l.size(); n >= 2 && ccw(l[n-2], l[n-1], g[i]) != CLOCKWISE; n--){
            l.pop_back();
        }
        l.push_back(g[i]);
    }

    reverse(l.begin(), l.end());
    for(int i = u.size()-2; i >= 1; i--)    l.push_back(u[i]);

    return l;
}


double area(Polygon g){
    if(g.size() < 3)    return 0;
    int n = g.size();
    Point o(0.0, 0.0);
    double s = 0.0;
    for(int i = 0; i < n; i++)  s += cross(g[i]-o, g[(i+1)%n]-o);
    return abs(s) / 2.0;
}

int main() {
    int n;
    cin >> n;
    Polygon g;
    for (int i = 0; i < n; i++) {
        double x, y;
        cin >> x >> y;
        g.push_back(Point(x, y));
    }
    int q;
    cin >> q;
    while (q-- > 0) {
        double px, py, qx, qy;
        cin >> px >> py >> qx >> qy;
        Point a(px, py), b(qx, qy);
        Vector diff = b - a;
        a = a - diff * 10001;
        b = b + diff * 10001;
        Polygon h;
        for (int i = 0; i < n; i++) {
            if (!isParallel(g[i], g[(i + 1) % n], a, b) && intersect(g[i], g[(i + 1) % n], a, b))
                h.push_back(getCrossPoint(Segment(g[i], g[(i + 1) % n]), Segment(a, b)));
        }
        for (int i = 0; i < n; i++) {
            if (cross(b - a, g[i] - a) >= 0.0) h.push_back(g[i]);
        }
        h = andrewScan(h);
        cout << fixed << setprecision(12) << area(h) << endl;
    }
    return 0;
}


Measured memory_bytes: 3308