using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using System.Diagnostics;
//using System.Numerics;
using Enu = System.Linq.Enumerable;

public class Program
{
    public void Solve()
    {
        int N = Reader.Int();
        var poly = new Polygon(Enu.Range(0, N).Select(i => new Point(Reader.Int(), Reader.Int())));
        int NQ = Reader.Int();

        for (int q = 0; q < NQ; q++)
        {
            var A = new Point(Reader.Int(), Reader.Int());
            var B = new Point(Reader.Int(), Reader.Int());
            var line = new Line(A, B);
            var curr = CutConvexPolygon(poly, line);
            Console.WriteLine(curr.Area());
        }

        Console.ReadLine();
    }

    public class Line
    {
        public Point A, B;
        public Point this[int i]
        {
            get { if (i == 0) return A; if (i == 1) return B; throw new ArgumentException(); }
        }
        public Line(Point a, Point b) { Debug.Assert(a != b); A = a; B = b; }
        public override string ToString() { return A + " - " + B; }
    }

    public Polygon CutConvexPolygon(Polygon poly, Line line, bool left = true)
    {
        var P = new List<Point>();
        for (int i = 0; i < poly.N; i++)
        {
            if (left && CCW(line[0], line[1], poly[i]) != CCWType.Right) P.Add(poly[i]);
            else if (!left && CCW(line[0], line[1], poly[i]) != CCWType.Left) P.Add(poly[i]);
            if ((int)CCW(line[0], line[1], poly[i]) * (int)CCW(line[0], line[1], poly[i + 1]) < 0)
                P.Add(CrossPoint(new Line(poly[i], poly[i + 1]), line));
        }
        return new Polygon(P);
    }

    public enum CCWType
    {
        Left = 1, Right = -1, OnSegment = 0, OnLineFront = -2, OnLineBack = 2
    }

    // A -> B -> C
    public CCWType CCW(Point A, Point B, Point C)
    {
        var b = B - A;
        var c = C - A;
        var det = b.Det(c);
        if (det > 0) return CCWType.Left; // counter-clockwise
        if (det < 0) return CCWType.Right; // clockwise
        if (b.Dot(c) < 0) return CCWType.OnLineBack;
        if (b.Dot(b) < c.Dot(c)) return CCWType.OnLineFront;
        return CCWType.OnSegment;
    }

    public Point CrossPoint(Line a, Line b)
    {
        double A = (a[1] - a[0]).Det(b[1] - b[0]);
        double B = (a[1] - a[0]).Det(a[1] - b[0]);
        if (A == 0 && B == 0) return b[0]; // same line
        Debug.Assert(A != 0);
        return b[0] + B / A * (b[1] - b[0]);
    }

    public struct Point : IEquatable<Point>, IComparable<Point>
    {
        public static readonly double Eps = 1e-10;
        public double X, Y;

        public Point(double x, double y) { X = x; Y = y; }

        public static Point operator +(Point a, Point b)
        {
            return new Point(Add(a.X, b.X), Add(a.Y, b.Y));
        }
        public static Point operator -(Point a, Point b)
        {
            return new Point(Add(a.X, -b.X), Add(a.Y, -b.Y));
        }
        public static Point operator *(double d, Point p)
        {
            return new Point(p.X * d, p.Y * d);
        }
        public static Point operator *(Point p, double d) { return d * p; }
        public double Dot(Point b) { return Add(X * b.X, Y * b.Y); }
        public double Det(Point b) { return Add(X * b.Y, -Y * b.X); }
        public bool Equals(Point b) { return X == b.X && Y == b.Y; }
        public override bool Equals(object obj) { return Equals((Point)obj); }
        public static bool operator ==(Point a, Point b) { return a.Equals(b); }
        public static bool operator !=(Point a, Point b) { return !a.Equals(b); }
        public int CompareTo(Point b) { return X != b.X ? Math.Sign(X - b.X) : Math.Sign(Y - b.Y); }
        public override int GetHashCode() { return (int)(X * 100000 + Y); }
        public override string ToString() { return X + ", " + Y; }

        private static double Add(double a, double b)
        {
            if (Math.Abs(a + b) < Eps * (Math.Abs(a) + Math.Abs(b))) return 0;
            return a + b;
        }
    }
    public class Polygon
    {
        public readonly Point[] P;
        public Polygon(Point[] points) { P = points; }
        public Polygon(IEnumerable<Point> points) { P = points.ToArray(); }
        public int N { get { return P.Length; } }
        public Point this[int i] { get { return P[(i % N + N) % N]; } }

        public double Area() { return Math.Abs(SignedArea()); }
        public double SignedArea()
        {
            double area = 0;
            for (int i = 0; i < P.Length; i++)
                area += P[i].Det(P[(i + 1) % P.Length]);
            return area / 2;
        }
        public bool IsConvex()
        {
            for (int i = 1; i < P.Length; i++)
                if ((P[i] - P[i - 1]).Det(P[(i + 1) % P.Length] - P[i]) < 0)
                    return false;
            return true;
        }
    }

}


class Entry { static void Main() { new Program().Solve(); } }
class Reader
{
    private static TextReader reader = Console.In;
    private static readonly char[] separator = { ' ' };
    private static readonly StringSplitOptions op = StringSplitOptions.RemoveEmptyEntries;
    private static string[] A = new string[0];
    private static int i;
    private static void Init() { A = new string[0]; }
    public static void Set(TextReader r) { reader = r; Init(); }
    public static void Set(string file) { reader = new StreamReader(file); Init(); }
    public static bool HasNext() { return CheckNext(); }
    public static string String() { return Next(); }
    public static int Int() { return int.Parse(Next()); }
    public static long Long() { return long.Parse(Next()); }
    public static double Double() { return double.Parse(Next()); }
    public static int[] IntLine() { return Array.ConvertAll(Split(Line()), int.Parse); }
    public static int[] IntArray(int N) { return Enu.Range(0, N).Select(i => Int()).ToArray(); }
    public static int[][] IntTable(int H) { return Enu.Range(0, H).Select(i => IntLine()).ToArray(); }
    public static string[] StringArray(int N) { return Enu.Range(0, N).Select(i => Next()).ToArray(); }
    public static string Line() { return reader.ReadLine().Trim(); }
    private static string[] Split(string s) { return s.Split(separator, op); }
    private static string Next() { CheckNext(); return A[i++]; }
    private static bool CheckNext()
    {
        if (i < A.Length) return true;
        string line = reader.ReadLine();
        if (line == null) return false;
        if (line == "") return CheckNext();
        A = Split(line);
        i = 0;
        return true;
    }
}

Measured memory_bytes: 9732