Problem:
Counter-Clockwise

For given three points p0, p1, p2, print

COUNTER_CLOCKWISE

if p0, p1, p2 make a counterclockwise turn (1),

CLOCKWISE

if p0, p1, p2 make a clockwise turn (2),

ONLINE_BACK

if p2 is on a line p2, p0, p1 in this order (3),

ONLINE_FRONT

if p2 is on a line p0, p1, p2 in this order (4),

ON_SEGMENT

if p2 is on a segment p0p1 (5).

Input

xp0 yp0 xp1 yp1
q
xp20 yp20
xp21 yp21
...
xp2q-1 yp2q-1

In the first line, integer coordinates of p0 and p1 are given. Then, q queries are given for integer coordinates of p2.

Output

For each query, print the above mentioned status.

Constraints

1 ≤ q ≤ 1000

-10000 ≤ xi, yi ≤ 10000

p0 and p1 are not identical.

Sample Input 1

0 0 2 0
2
-1 1
-1 -1

Sample Output 1

COUNTER_CLOCKWISE
CLOCKWISE

Sample Input 2

0 0 2 0
3
-1 0
0 0
3 0

Sample Output 2

ONLINE_BACK
ON_SEGMENT
ONLINE_FRONT

Solution in C# (judge verdict: Accepted)

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()
    {
        var A = new Point(Reader.Int(), Reader.Int());
        var B = new Point(Reader.Int(), Reader.Int());
        int NQ = Reader.Int();
        var seg = new Segment(A, B);

        for (int q = 0; q < NQ; q++)
        {
            var P = new Point(Reader.Int(), Reader.Int());
            Console.WriteLine(CCW(seg, P));
        }
        Console.ReadLine();
    }


    public enum CCWType
    {
        COUNTER_CLOCKWISE, CLOCKWISE, ON_SEGMENT, ONLINE_FRONT, ONLINE_BACK
    }

    // seg.A -> seg.B -> p
    public CCWType CCW(Segment seg, Point p)
    {
        var b = seg.B - seg.A;
        var c = p - seg.A;
        var det = b.Det(c);
        if (det > 0) return CCWType.COUNTER_CLOCKWISE;
        if (det < 0) return CCWType.CLOCKWISE;
        if (b.Dot(c) < 0) return CCWType.ONLINE_BACK;
        if (b.Dot(b) < c.Dot(c)) return CCWType.ONLINE_FRONT;
        return CCWType.ON_SEGMENT;
    }

    public class Segment
    {
        public Point A, B;
        public Segment(Point a, Point b) { A = a; B = b; }
    }

    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 *(Point p, double d)
        {
            return new Point(p.X * d, p.Y * d);
        }
        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 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;
        }
    }
}


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;
    }
}