#include <bits/stdc++.h>
using namespace std;
 
using ll = long long; using ld = long double; using ull = unsigned long long; using uint = unsigned int;
using vi  = vector<int>; using vb  = vector<bool>; using vd  = vector<double>; using vl  = vector<ll>;
using vvi = vector<vi>;  using vvb = vector<vb>;   using vvd = vector<vd>;     using vvl = vector<vl>;
 
#define REP(i,n) for(ll i=0; i<(n); ++i)
#define FOR(i,b,n) for(ll i=(b); i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define TEN(x) ((ll)1e##x)
 
template<typename T> inline string join(const vector<T>& vec, string sep = " ") { stringstream ss; REP(i, vec.size()) ss << vec[i] << ( i+1 == vec.size() ? "" : sep ); return ss.str(); }
 
 
///////////////
 
#define EPS (1e-10)
#define NEXT(x, i) (x[(i + 1) % x.size()])
 
template<class T> using CR = const T &;
using P = complex<ld>;
using G = vector<P>;
 
int sgn(ld a, ld b = 0) {
    if (a > b + EPS) return 1;
    if (a < b - EPS) return -1;
    return 0;
}
 
ld dot(P a, P b) { return real(conj(a)*b); }
ld cross(P a, P b) { return imag(conj(a)*b); }
 
int ccw(P a, P b, P c) {
    b -= a;
    c -= a;
    if (sgn(cross(b, c))) return sgn(cross(b, c)); // clockwise or counter clockwise
    if (sgn(dot(b, c)) == -1) return 2;            // c--a--b
    if (sgn(norm(b), norm(c)) == -1) return -2;    // a--b--c
    return 0;                                      // a--c--b
}
 
struct L : public vector<P> {
    L(P a, P b) { push_back(a); push_back(b); }
};

P pLL(CR<L> l, CR<L> m) {
	ld a = cross(l[1] - l[0], m[1] - m[0]);
	ld b = cross(l[1] - l[0], l[1] - m[0]);
	assert(sgn(a)); // parallel or same line
	return m[0] + b / a * (m[1] - m[0]);
}
bool iLS(CR<L> l, CR<L> s, bool strict = false) {
	int c = sgn(cross(l[1] - l[0], s[0] - l[0])) * sgn(cross(l[1] - l[0], s[1] - l[0]));
	return c <= 0 && (!strict || c == -1);
}
G convex_cut(CR<G> g, CR<L> l) {
	G q;
	REP(i, g.size()) {
		if (ccw(l[0], l[1], g[i]) != -1) q.push_back(g[i]);
		L s = { g[i], g[(i + 1) % g.size()] };
		if (iLS(l, s, true)) q.push_back(pLL(l, s));
	}
	return q;
}
ld area2(CR<G> g) {
	ld s = 0;
	REP(i, g.size()) s += cross(g[i], NEXT(g, i));
	return s;
}

//////////////
 
int main() {
#ifdef INPUT_FROM_FILE
    ifstream cin("sample.in");
    ofstream cout("sample.out");
#endif
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(30);
	ll n; cin >> n;
	G g(n);
	REP(i, n) {
		ld x, y;
		cin >> x >> y;
		g[i] = { x, y };
	}
	ll q; cin >> q;
	REP(i, q) {
		ld x1, y1, x2, y2;
		cin >> x1 >> y1 >> x2 >> y2;
		cout << area2(convex_cut(g, { { x1, y1 }, { x2, y2 } })) / 2 << endl;
	}

    return 0;
}