using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static readonly double EPS = 1E-10;

        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            Point[] ps = new Point[n];

            for (int i = 0; i < n; i++)
            {
                double[] input = Array.ConvertAll(Console.ReadLine().Split(' '), double.Parse);
                ps[i] = new Point(input[0], input[1]);
            }

            StringBuilder sb = new StringBuilder();
            int q = int.Parse(Console.ReadLine());

            for (int i = 0; i < q; i++)
            {
                double[] input = Array.ConvertAll(Console.ReadLine().Split(' '), double.Parse);
                Segment l = new Segment(input[0], input[1], input[2], input[3]);

                List<Point> pt = ConvexCut(ps, l);
                sb.AppendLine(Area(pt).ToString());
            }
            Console.Write(sb);
        }

        static List<Point> ConvexCut(Point[] ps, Segment l)
        {
            List<Point> ret = new List<Point>();
            int n = ps.Length;

            for (int i = 0; i < n; i++)
            {
                Point a = ps[i], b = ps[(i + 1) % n];
                Segment ab = new Segment(a, b);
                int ccwA = CCW(l.p1, l.p2, a);
                int ccwB = CCW(l.p1, l.p2, b);

                if (ccwA != -1) ret.Add(a);
                if (ccwA * ccwB < 0) ret.Add(CrossPoint(ab, l));
            }
            return ret;
        }

        static Point CrossPoint(Segment l, Segment m)
        {
            double a = (l.p2 - l.p1).Cross(m.p2 - m.p1);
            double b = (l.p2 - l.p1).Cross(l.p2 - m.p1);

            if (Math.Abs(a) < EPS && Math.Abs(b) < EPS) return m.p1;
            return m.p1 + (m.p2 - m.p1) * b / a;
        }

        static int CCW(Point a, Point b, Point c)
        {
            b -= a;
            c -= a;

            if (b.Cross(c) > EPS) return 1;
            if (b.Cross(c) < -EPS) return -1;
            if (b.Dot(c) < -EPS) return 2;
            if (b.Norm < c.Norm) return -2;
            return 0;
        }

        static double Area(List<Point> pt)
        {
            double sum = 0.0;
            int n = pt.Count;

            for (int i = 0; i < n; i++)
            {
                sum += pt[i].Cross(pt[(i + 1) % n]);
            }
            return sum / 2;
        }
    }

    class Point : IComparable<Point>
    {
        static readonly double EPS = 1E-10;

        internal double x, y;

        public Point(double x, double y)
        {
            this.x = x;
            this.y = y;
        }

        public double Abs { get { return Math.Sqrt(Norm); } }
        public double Norm { get { return x * x + y * y; } }

        public double Dot(Point p) { return x * p.x + y * p.y; }
        public double Cross(Point p) { return x * p.y - y * p.x; }

        public static Point operator +(Point a, Point b) { return new Point(a.x + b.x, a.y + b.y); }
        public static Point operator -(Point a, Point b) { return new Point(a.x - b.x, a.y - b.y); }
        public static Point operator *(Point p, double d) { return new Point(p.x * d, p.y * d); }
        public static Point operator /(Point p, double d) { return new Point(p.x / d, p.y / d); }
        public static bool operator <(Point a, Point b) { return Math.Abs(a.x - b.x) > EPS ? a.x < b.x : a.y < b.y; }
        public static bool operator >(Point a, Point b) { return Math.Abs(a.x - b.x) > EPS ? a.x > b.x : a.y > b.y; }
        public static bool operator ==(Point a, Point b) { return Math.Abs(a.x - b.x) < EPS && Math.Abs(a.y - b.y) < EPS; }
        public static bool operator !=(Point a, Point b) { return Math.Abs(a.x - b.x) >= EPS || Math.Abs(a.y - b.y) >= EPS; }

        public int CompareTo(Point other)
        {
            return Math.Abs(x - other.x) < EPS ? (int)(x - other.x) : (int)(y - other.y);
        }

        public override bool Equals(object obj)
        {
            Point other = obj as Point;
            return Math.Abs(x - other.x) < EPS && Math.Abs(y - other.y) < EPS;
        }

        public override int GetHashCode()
        {
            return x.GetHashCode() ^ y.GetHashCode();
        }

        public override string ToString()
        {
            return string.Format("{0} {1}", x, y);
        }
    }

    class Segment
    {
        internal Point p1, p2;

        public Segment(Point p1, Point p2)
        {
            this.p1 = p1;
            this.p2 = p2;
        }

        public Segment(double ax, double ay, double bx, double by)
        {
            p1 = new Point(ax, ay);
            p2 = new Point(bx, by);
        }
    }

    class Circle
    {
        internal Point p;
        internal double r;

        public Circle(Point p, double r)
        {
            this.p = p;
            this.r = r;
        }
    }
}

Measured memory_bytes: 9444