using System;
//using System.Collections.Generic;
//using System.Linq;
//using Vector = CGL.Point;
//using Line = CGL.Segment;
//using Polygon = System.Collections.Generic.List<CGL.Point>;

namespace CGL
{
    class Program
    {
        static void Main(string[] args)
        {
            var t = scan;
            var q = scan[0];
            var p0 = new Point(t[0], t[1]);
            var p1 = new Point(t[2], t[3]);

            for (int i = 0; i < q; i++)
            {
                t = scan;
                var p2 = new Point(t[0], t[1]);
                var k = (p1 - p0).CCW(p2 - p0);
                if (k == 1) Console.WriteLine("COUNTER_CLOCKWISE");
                else if (k == -1) Console.WriteLine("CLOCKWISE");
                else if (k == 2) Console.WriteLine("ONLINE_BACK");
                else if (k == -2) Console.WriteLine("ONLINE_FRONT");
                else Console.WriteLine("ON_SEGMENT");
            }

            /*var q = scan[0];
            for (int i = 0; i < q; i++)
            {
                var t = scan;
                var P = new Point[4];
                for (int j = 0; j < 4; j++)
                {
                    P[j] = new Point(t[j * 2], t[j * 2 + 1]);
                }
                var s1 = new Segment(P[0], P[1]);
                var s2 = new Segment(P[2], P[3]);
                Console.WriteLine(s1.GetDistance(s2));
            }*/
        }
        static int[] scan { get { return Array.ConvertAll(Console.ReadLine().Split(), int.Parse); } }
    }
    
    struct Point
    {
        static readonly double EPS = 1E-10;
        public double x, y;
        public Point(double x, double y)
        {
            this.x = x;
            this.y = 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 a, Point b) { return new Point(a.x - b.x, a.y - b.y); }
        public static Point operator *(double k, Point a) { return new Point(k * a.x, k * a.y); }
        public static Point operator /(double k, Point a) { return new Point(a.x / k, a.y / k); }
        
        public double Abs { get { return Math.Sqrt(Norm); } }  
        public double Norm { get { return x * x + y * 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 ? 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 override bool Equals(object p){  return Math.Abs(x - ((Point)p).x) < EPS && Math.Abs(y - ((Point)p).y) < EPS; }
        public override int GetHashCode(){ return x.GetHashCode() ^ y.GetHashCode(); }

        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 double GetDistance(Point p) { return (this - p).Abs; }

        public int CCW(Point b)
        {
            if (Cross(b) > EPS) return 1;
            if (Cross(b) < -EPS) return -1;
            if (Dot(b) < -EPS) return 2;
            if (Norm < b.Norm) return -2;
            return 0;
        }
    }
    struct Segment
    {
        public Point p1, p2;
        public Segment(Point p1, Point p2)
        {
            this.p1 = p1;
            this.p2 = p2;
        }
        public Point Projection(Point p)
        {
            Point b = p2 - p1;
            double r = b.Dot(p - p1) / b.Norm;
            return p1 + r * b;
        }
        public Point Reflection(Point p)
        {
            return p + 2 * (Projection(p) - p);
        }
        public double GetD_LP(Point p)
        {
            return Math.Abs((p - p1).Cross(p2 - p1) / (p2 - p1).Abs);
        }
        public double GetD_SP(Point p)
        {
            if ((p - p1).Dot(p2 - p1) < 0) return (p - p1).Abs;
            if ((p - p2).Dot(p1 - p2) < 0) return (p - p2).Abs;
            return GetD_LP(p);
        }
        public double GetDistance(Segment s)
        {
            //if (this.Intersect(s)) return 0;
            return Math.Min(Math.Min(GetD_SP(s.p1), GetD_SP(s.p2)), Math.Min(s.GetD_SP(p1), s.GetD_SP(p2)));
        }
    }
    /*struct Circle
    {
        public Point c; double r;
        public Circle(Point c, double r)
        {
            this.c = c;
            this.r = r;
        }

    }*/
}

Measured memory_bytes: 9112