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.Linq;//リストの使用
using System.Collections.Generic;
class Program
{

	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');//Splitで区切り文字を指定して複数個受け取る。
		Vector2 beginPoint = new Vector2(decimal.Parse(input[0]), decimal.Parse(input[1]));
    Vector2 endPoint = new Vector2(decimal.Parse(input[2]), decimal.Parse(input[3]));
		long q = long.Parse(Console.ReadLine());

    for(long i = 0; i < q; i++)
    {
      string[] inputSub = Console.ReadLine().Split(' ');
      Vector2 QuestionPoint = 
        new Vector2(decimal.Parse(inputSub[0]), decimal.Parse(inputSub[1]));
      Vector2.WhereVector(beginPoint, endPoint, QuestionPoint);
    }
	}
}

class Vector2//2次元ベクトル
{
static decimal verySmallDecimal = 1e-10m;//小数比較

  public Vector2 (decimal X, decimal Y)
  {
    this.x = X;
    this.y = Y;
  }

  public decimal x {private set; get;}
  public decimal y {private set; get;}

  public static Vector2 operator + (Vector2 ob1, Vector2 ob2)//ベクトルの基本演算
  {
    return new Vector2 (ob1.x + ob2.x, ob1.y + ob2.y);
  }
  public static Vector2 operator - (Vector2 ob1, Vector2 ob2)
  {
    return new Vector2 (ob1.x - ob2.x, ob1.y - ob2.y);
  }
  public static Vector2 operator * (Vector2 ob, decimal scalar)
  {
    return new Vector2 (ob.x * scalar, ob.y * scalar);
  }
  public static Vector2 operator * (decimal scalar, Vector2 ob)
  {
    return new Vector2 (ob.x * scalar, ob.y * scalar);
  }

  public decimal Length()//ベクトルの長さ
  {
    return x * x + y * y;
  }
  public static decimal DotProduct(Vector2 ob1, Vector2 ob2)//内積
  {
    return ob1.x * ob2.x + ob1.y * ob2.y;
  }
  public static decimal CrossProduct(Vector2 ob1, Vector2 ob2)//内積
  {
    return ob1.x * ob2.y - ob1.y * ob2.x;
  }

  public static Vector2 Projection(Vector2 beginPoint, Vector2 endPoint, Vector2 point)//点の射影
  {
    Vector2 segment = endPoint - beginPoint;
    decimal ratio = Vector2.DotProduct(point - beginPoint, segment) / segment.Length();
    return beginPoint + segment * ratio;//始点にたす
  }

  public static void WhereVector(Vector2 beginPoint, Vector2 endPoint, Vector2 point)
  {
    Vector2 segment = endPoint - beginPoint;
    Vector2 aimVec = point - beginPoint;
    if(Vector2.CrossProduct(segment, aimVec) > verySmallDecimal)
      Console.WriteLine("COUNTER_CLOCKWISE");
    else if(Vector2.CrossProduct(segment, aimVec) < -verySmallDecimal)
      Console.WriteLine("CLOCKWISE");
    else if(Vector2.DotProduct(segment, aimVec) < -1+verySmallDecimal)
      Console.WriteLine("ONLINE_BACK");
    else if(segment.Length() < aimVec.Length())
      Console.WriteLine("ONLINE_FRONT");
    else
      Console.WriteLine("ON_SEGMENT");
  }
  
}