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

namespace ConsoleApplication1
{
    enum CCW { COUNTER_CLOCKWISE = 1, CLOCKWISE = -1, ONLINE_BACK = 2, ONLINE_FRONT = -2, ON_SEGMENT = 0 }

    class Program
    {
        static void Main(string[] args)
        {
            double[] input = Array.ConvertAll(Console.ReadLine().Split(' '), double.Parse);
            Pt a = new Pt(input[0], input[1]);
            Pt b = new Pt(input[2], input[3]);

            int q = int.Parse(Console.ReadLine());
            
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < q; i++)
            {
                input = Array.ConvertAll(Console.ReadLine().Split(' '), double.Parse);
                Pt p = new Pt(input[0], input[1]);

                sb.AppendLine(CheckCCW(a, b, p).ToString());
            }
            Console.Write(sb);
        }

        static CCW CheckCCW(Pt p0, Pt p1, Pt p2)
        {
            Pt a = p1 - p0;
            Pt b = p2 - p0;

            if (a.Cross(b) > 0) return CCW.COUNTER_CLOCKWISE;
            if (a.Cross(b) < 0) return CCW.CLOCKWISE;
            if (a.Dot(b) < 0) return CCW.ONLINE_BACK;
            if (a.Norm < b.Norm) return CCW.ONLINE_FRONT;
            return CCW.ON_SEGMENT;
        }
    }

    struct Pt : IComparable<Pt>
    {
        static readonly double EPS = 1E-10;

        internal double x, y;

        public Pt(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(Pt p) { return x * p.x + y * p.y; }
        public double Cross(Pt p) { return x * p.y - y * p.x; }

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

        public int CompareTo(Pt other)
        {
            return x != other.x ? (int)(x - other.x) : (int)(y - other.y);
        }

        public override bool Equals(object obj)
        {
            Pt other = (Pt)obj;
            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:f10} {1:f10}", x, y);
        }
    }

    struct Seg
    {
        internal Pt p1, p2;

        public Seg(Pt a, Pt b)
        {
            p1 = a;
            p2 = b;
        }
    }
}

Measured memory_bytes: 9764