#include <bits/stdc++.h>
#define SZ(v) int(v.size())
using namespace std;

typedef long double ld;
struct pt {
	ld x, y;
};

struct ln {
	pt p;
	pt v;
};

ld operator%(pt a, pt b) {
	return a.x*b.y - a.y*b.x;
}

ld operator*(pt a, pt b) {
	return a.x*b.x + a.y*b.y;
}

pt operator*(ld a, pt b) {
	return pt{a*b.x, a*b.y};
}

pt operator-(pt a, pt b) {
	return pt {a.x-b.x, a.y-b.y};
}

pt operator+(pt a, pt b) {
	return pt {a.x+b.x, a.y+b.y};
}

ostream &operator<<(ostream &o, pt p) {
	return o << "(" << p.x << ", " << p.y << ")";
}

ln through(pt a, pt b) {
	return ln {a, a-b};
}

pt inter(ln a, ln b) {
	assert(abs(a.v%b.v) > 1e-9);
	pt p = a.v%(a.p-b.p)/(a.v%b.v) * b.v + b.p;
	// assert(abs((p - a.p)%a.v) < 1e-9);
	return p;
}

pair<vector<pt>, int> make_chull(vector<pt> ns){
	vector<pt> r;
	sort(ns.begin(), ns.end(), [&](pt a, pt b) {
		return a.x < b.x;
	});
	for(auto p : ns) {
		while(SZ(r) >= 2 && (r.back() - r[SZ(r)-2])%(p-r.back()) > 0)
			r.pop_back();
		r.push_back(p);
	}
	r.pop_back();
	int k=SZ(r);
	reverse(ns.begin(), ns.end());
	for(auto p : ns) {
		while(SZ(r) >= k+2 && (r.back() - r[SZ(r)-2])%(p-r.back()) > 0)
			r.pop_back();
		r.push_back(p);
	}
	r.pop_back();
	return {r, k};
}

ld eps = 1e-9;
int max_dir(vector<pt> &chull, int k, pt v) {
	int n = SZ(chull);
	int lo, hi;
	v.y += eps;
	if(v.y > 0) lo=-1, hi=k;
	else lo=k-1, hi=n;
	while(hi-lo > 1) {
		int mid = (hi+lo)/2;
		if((chull[(mid+1)%n] - chull[mid%n])*v>0) lo = mid;
		else hi = mid;
	}
	// cout << v << " => " << chull[hi%n] << endl;
	return hi%n;
}

pair<int, int> intersect(vector<pt> &chull, int k, ln l) {
	int n = SZ(chull);
	auto i = max_dir(chull, k, {l.v.y, -l.v.x});
	auto j = max_dir(chull, k, {-l.v.y, l.v.x});
	int lo = i;
	int hi = j;
	if(hi < lo) hi += n;
	if(l.v%(chull[lo%n]-l.p) >= -eps) return {-1, -1};
	while(hi-lo > 1) {
		int mid = (hi+lo)/2;
		if(l.v%(chull[mid%n]-l.p) < 0) lo = mid;
		else hi = mid;
	}
	int a = lo;
	lo = j;
	hi = i;
	if(hi < lo) hi += n;
	if(l.v%(chull[lo%n]-l.p) <= eps) return {-2, -2};
	while(hi-lo > 1) {
		int mid = (hi+lo)/2;
		if(l.v%(chull[mid%n]-l.p) > 0) lo = mid;
		else hi = mid;
	}
	int b = lo;
	return {a%n, b%n};
}

int main() {
	int n;
	cin >> n;
	vector<pt> ns(n);
	for(auto&p : ns) cin >> p.x >> p.y;
	auto lala = make_chull(ns);
	auto chull = lala.first;
	int k = lala.second;
	n = SZ(chull);
	vector<ld> partials = {0};
	for(int t = 0; t < 2*int(SZ(chull)); ++t) {
		partials.push_back(partials.back() + (chull[(t+1)%n]%chull[t%n]));
	}

	// cout << k << endl;
	int test;
	cin >> test;
	while(test --> 0) {
		ln l;
		cin >> l.p.x >> l.p.y >> l.v.x >> l.v.y;
		l.v = l.v - l.p;
		auto lulu = intersect(chull, k, l);
		int i = lulu.first;
		int j = lulu.second;
		ld res;
		if(i == -2) {
			res = 0.0;
		} else if (i== -1) {
			res = partials.back()*0.25;
		} else {
			// cout << chull[i%n].x << " " << chull[i%n].y << "  "
				// << chull[j].x << " " << chull[j].y << endl;

			if(j < i) j += n;
			ld total = partials[j] - partials[i];
			pt a = inter(l, through(chull[i%n], chull[(i+1)%n]));
			pt b = inter(l, through(chull[j%n], chull[(j+1)%n]));
			// cout << chull[i%n] << chull[(i+1)%n] << endl;
			total -= a%chull[i%n];
			total += b%chull[j%n];
			total -= b%a;
			// cout << "(" << a.x << ", " << a.y << ")" << endl;
			// cout << "(" << b.x << ", " << b.y << ")" << endl;
			res = total*0.5;
		}
		cout << setprecision(12) << fixed;
		cout << res << endl;
	}
}



Measured memory_bytes: 3308