#include <algorithm>
#include <vector>
#include <cfloat>
#include <string>
#include <cmath>
#include <set>
#include <cstdlib>
#include <map>
#include <ctime>
#include <iomanip>
#include <functional>
#include <deque>
#include <iostream>
#include <cstring>
#include <queue>
#include <cstdio>
#include <stack>
#include <climits>
#include <sys/time.h>
#include <cctype>

using namespace std;

typedef long long ll;


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

class Point {
 public:
  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 norm() { return x*x+y*y; }
  double abs() { return sqrt(norm()); }

  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 <Vector> Polygon;

class Segment {
 public:
  Point p1, p2;

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

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

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

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

// ?????????|a||b|cos
double cross(Vector a, Vector b) {
  return a.x*b.y-a.y*b.x;
}
// ?????????|a||b|sin
double dot(Vector a, Vector b) {
  return a.x*b.x+a.y*b.y;
}

// s1???s2????????§???????????????????????????????????§?????????????????¨???????????¶????????????
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;
}

// 1:???????¨??????? -1:????¨??????? 2:p2-p0-p1 -2:p0-p1-p2 0:p2???p0-p1???
int ccw(Point p0, Point p1, Point p2) {
  Vector a = p1-p0;
  Vector b = p2-p0;
  if (cross(a, b) > EPS) return 1;
  if (cross(a, b) < -EPS) return -1;
  if (dot(a, b) < -EPS) return 2;
  if (a.norm() < b.norm()) return -2;

  return 0;
}

// p1!=p2????????????p3!=p4????????¶
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);
}

// poly???????¨?????????????????¨???????????????????????????´???l??§?????£????????´???????????????????????????
// ?????´?????????????????´????????´???l??????????????????????????°??????swap(l.p1, l.p2)
Polygon convex_cut(const Polygon &poly, Segment l) {
  Polygon ret;
  int n = poly.size();
  for (int i = 0; i < n; i++) {
    Vector a = poly[i], b = poly[(i+1)%n];
    if (ccw(l.p1, l.p2, a) != -1) ret.push_back(a);  // ????¨?????????§???????????°??????
    if (ccw(l.p1, l.p2, a)*ccw(l.p1, l.p2, b) < 0 &&
        abs(ccw(l.p1, l.p2, a)) == 1) { // ??????????????´?????????????????????
      ret.push_back(getCrossPoint(Segment(a, b), l));
    }
  }
  return ret;
}

// ????§???¢?????¢???
double polygonArea(vector<Vector> &poly) {
  double ret = 0;
  int n = poly.size();
  if (n < 3) return 0;
  for (int i = 1; i < n-1; i++) {
    ret += fabs(cross(poly[i]-poly[0], poly[i+1]-poly[0]));
    // ret += poly[i].x*poly[(i+1)%n].y-poly[(i+1)%n].x*poly[i].y;
  }
  return ret*0.5;
}

int main() {
  int n;
  cin >> n;
  Polygon poly;
  for (int i = 0; i < n; i++) {
    Vector point;
    cin >> point.x >> point.y;
    poly.push_back(point);
  }
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    Segment l;
    cin >> l.p1.x >> l.p1.y >> l.p2.x >> l.p2.y;
    Polygon cuted = convex_cut(poly, l);
    printf("%.20lf\n", polygonArea(cuted));
    // cout << fixed << setprecision(20) << polygonArea(cuted) << endl;
  }
}

Measured memory_bytes: 1260