#include <algorithm>
#include <array>
#include <assert.h>
#include <bitset>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstring>
#include <functional>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <istream>

#include <map>
#include <math.h>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

namespace asl
{
    
    template <typename numeric_type>
    class point
    {
    public:
        numeric_type x, y;

        point(numeric_type x = 0, numeric_type y = 0) : x(x), y(y) {}

        point<numeric_type> &operator+=(const point<numeric_type> &ri)
        {
            x += ri.x;
            y += ri.y;
            return *this;
        }

        point<numeric_type> &operator-=(const point<numeric_type> &ri)
        {
            x -= ri.x;
            y -= ri.y;
            return *this;
        }

        point<numeric_type> &operator*=(const point<numeric_type> &ri)
        {
            auto _x = x * ri.x - y * ri.y;
            auto _y = x * ri.y + y * ri.x;
            x = _x;
            y = _y;
            return *this;
        }

        friend point<numeric_type> operator+(const point<numeric_type> &a, const point<numeric_type> &b)
        {
            return point<numeric_type>(a) += b;
        }

        friend point<numeric_type> operator-(const point<numeric_type> &a, const point<numeric_type> &b)
        {
            return point<numeric_type>(a) -= b;
        }

        friend point<numeric_type> operator*(const point<numeric_type> &a, const point<numeric_type> &b)
        {
            return point<numeric_type>(a) *= b;
        }

    };

    template <typename numeric_type>
    std::istream &operator>>(std::istream &is, point<numeric_type> &p)
    {
        return is >> p.x >> p.y;
    }

    template <typename numeric_type>
    class line
    {
    public:
        point<numeric_type> p, q;

    };

    template <typename numeric_type>
    std::istream &operator>>(std::istream &is, line<numeric_type> &l)
    {
        return is >> l.p >> l.q;
    }

    template <typename numeric_type>
    numeric_type cross(point<numeric_type> a, point<numeric_type> b)
    {
        return a.x * b.y - a.y * b.x;
    }

    template <typename numeric_type>
    numeric_type dot(point<numeric_type> a, point<numeric_type> b)
    {
        return a.x * b.x + a.y * b.y;
    }

    enum PointOrder
    {
        CounterClockwise = +1,
        Clockwise = -1,
        AlignedFirst = +2,
        AlignedLast = -2,
        AlignedIn = 0,
    };

    template <typename numeric_type>
    PointOrder ccw(point<numeric_type> a, point<numeric_type> b, point<numeric_type> c)
    {
        b -= a;
        c -= a;
        if (cross(b, c) > 0)
            return PointOrder::CounterClockwise;
        else if (cross(b, c) < 0)
            return PointOrder::Clockwise;
        else if (dot(b, c) < 0)
            return PointOrder::AlignedFirst; 
        else if (dot(b, b) < dot(c, c))
            return PointOrder::AlignedLast; 
        else
            return PointOrder::AlignedIn; 
    }

    template <const int eps_exp = 9>
    int sign(double v)
    {
        const double eps = std::pow(10, -eps_exp);

        if (v < -eps)
            return -1;
        else if (v > eps)
            return +1;
        else
            return 0;
    }

#include <stdint.h>

    template <typename T>
    std::istream &operator>>(std::istream &is, std::vector<T> &vec)
    {
        for (auto &value : vec)
            is >> value;
        return is;
    }

} 

#include <experimental/optional>

#define _NEXT(i) (((i) + 1) == n ? 0 : ((i) + 1))

namespace asl
{
    template <typename numeric_type>
    using polygon = std::vector<point<numeric_type>>;

    template <typename numeric_type>
    numeric_type area2(const polygon<numeric_type> &P)
    {
        numeric_type A = 0;
        for (int i = 0, n = P.size(); i < n; ++i)
            A += cross(P[i], P[(_NEXT(i))]);
        return A;
    }

    template <typename numeric_type>
    polygon<numeric_type> convex_cut(const polygon<numeric_type> &P, const line<numeric_type> &l)
    {
        polygon<numeric_type> Q;
        for (int i = 0, n = P.size(); i < n; ++i)
        {
            point<numeric_type> A = P[i], B = P[(i + 1) % n];
            if (ccw(l.p, l.q, A) != -1)
                Q.push_back(A);
            if (ccw(l.p, l.q, A) * ccw(l.p, l.q, B) < 0)
                Q.push_back(crosspoint((line<numeric_type>){A, B}, l));
        }
        return Q;
    }

    template <typename numeric_type>
    point<numeric_type> crosspoint(const line<numeric_type> &l, const line<numeric_type> &m)
    {
        double A = cross(l.q - l.p, m.q - m.p);
        double B = cross(l.q - l.p, l.q - m.p);

        if (sign(A) == 0 && sign(B) == 0)
            return m.p; 

        if (sign(A) == 0)
            assert(false); 

        return m.p + B / A * (m.q - m.p);
    }
} 
 
#include <random>

#define endl '\n'

using namespace asl;
using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(12);
    cout << fixed;

    int n;
    cin >> n;

    polygon<double> pol(n);
    cin >> pol;

    int q;
    cin >> q;

    while (q--)
    {
        line<double> l;
        cin >> l;

        auto cur = convex_cut(pol, l);

        cout << area2(cur) / 2 << endl;
    }

    return 0;
}





Measured memory_bytes: 3308