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  x p0  y p0  x p1  y p1  q  x p2 0  y p2 0  x p2 1  y p2 1 ... x p2 q-1  y p2 q-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 ≤ x i , y i ≤ 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 (Python):
import math

class Point():
    def __init__(self, x, y):
        self.x = x
        self.y = y

class Vector():
    def __init__(self, start, end):
        self.x = end.x - start.x
        self.y = end.y - start.y
        self.r = math.sqrt(pow(self.x, 2) + pow(self.y, 2))
        self.theta = math.atan2(self.y, self.x)

x0, y0, x1, y1 = list(map(int, input().split(' ')))
p0, p1 = Point(x0, y0), Point(x1, y1)
vec1 = Vector(p0, p1)

q = int(input())
for i in range(q):
    x2, y2 = list(map(int, input().split(' ')))
    p2 = Point(x2, y2)
    vec2 = Vector(p0, p2)
    if vec2.r == 0:
        print('ON_SEGMENT')
    elif vec1.theta == vec2.theta:
        if vec1.r < vec2.r:
            print('ONLINE_FRONT')
        else:
            print('ON_SEGMENT')
    elif abs(vec1.theta - vec2.theta) == math.pi:
        print('ONLINE_BACK')
    elif (0 < vec2.theta - vec1.theta and vec2.theta - vec1.theta < math.pi)  or vec2.theta - vec1.theta < -1*math.pi:
        print('COUNTER_CLOCKWISE')
    elif (-1*math.pi < vec2.theta - vec1.theta and vec2.theta - vec1.theta < 0) or vec2.theta - vec1.theta > math.pi:
        print('CLOCKWISE')

Solution (Python):
import math
EPS=1e-10


class Point():

    def __init__(self,x,y):
        self.x=x
        self.y=y
    
    def __sub__(self,p):
        return Point(self.x - p.x, self.y - p.y);
    def __add__(self,p):
        return Point(self.x + p.x, self.y + p.y)
           
    def __mul__(self,a): 
        return Point(self.x * a, self.y * a)
    def __truediv__(self,a): 
        return Point(self.x / a, self.y / a)
   
    def __str__(self):
       return  str(self.x)+','+str(self.y)
    def __repr__(self):
        return  'Point('+str(self.x)+','+str(self.y)+')'
    
    def __lt__(self, other):    
        if self.y-other.y==0:
            return self.x<other.x
        else:
            return self.y<other.y
            
    def __eq__(self, other):    
        return abs(self.x-other.x)<EPS and  abs(self.y-other.y)<EPS



class Segment():
    def __init__(self,p1, p2):
        self.p1=p1
        self.p2=p2
    def __str__(self):
        return  'segment:('+str(self.p1)+';'+str(self.p2)+')'
    def __repr__(self):
        return  'segment:('+str(self.p1)+';'+str(self.p2)+')'


class Circle():
    def __init__(self,c, r):
        self.c=c
        self.r=r

    def __str__(self):
       return  'Circle:(center point: '+str(self.c)+'; radius: '+str(self.r)+')'
    def __repr__(self):
       return  'Circle:(center point: '+str(self.c)+'; radius: '+str(self.r)+')'
   
    

class Polygon():
    def __init__(self,ps=[]):
        self.ps=ps
        self.size=len(ps)
  
    def __getitem__(self, i):
        return self.ps[i]  
    def __setitem__(self,i,p): 
        self.ps[i]=p               
    def __iter__(self):     
        return self.ps  
    
    def addpoint(self,i,p):
        self.ps.insert(i,p)
        self.size+=1
    def delpoint(self,i):
        self.size-=1
        return self.ps.pop(i)
    def sortYX(self):
        self.ps.sort()
        
    def __str__(self):
       return  'Polygon:'+str(tuple(self.ps))
    def __repr__(self):
       return  'Polygon:'+str(tuple(self.ps))
        
    def __len__(self):
        return len(self.ps)
    def __eq__(self, other):  
         return self.ps==other.ps
    
    def draw(self):
      
       turtle.screensize(800,800,"black")
       
       turtle.title("Polygon convex hull")
       turtle.setworldcoordinates(-400,-400,400,400) 

       
       
       
       t=turtle.Turtle() 
       
       
       t.pencolor("red")
       for pt in self.ps:
           t.goto(pt.x,pt.y)
           t.dot(10,'white')
       
 




def norm(p):  
    return p.x * p.x + p.y * p.y



def length(p):
    return math.sqrt(p.x * p.x + p.y * p.y)









def dot(a, b) :
    return a.x * b.x + a.y * b.y










def cross( a, b) :
    return a.x * b.y - a.y * b.x


def project(s, p):
    base = s.p2 - s.p1
    r = dot(p - s.p1, base) / norm(base)
    return s.p1 + base * r 



def getDistance(a, b) :
    return length(a - b)


def getDistanceLP(l, p) :
    return abs( cross(l.p2 - l.p1, p - l.p1) / length(l.p2 - l.p1) )


    

def getDistanceSP(s, p) :
    if (dot(s.p2 - s.p1, p - s.p1) < 0.0):
        return length(p - s.p1)
    if (dot(s.p1 - s.p2, p - s.p2) < 0.0):
        return length(p - s.p2)
    return getDistanceLP(s, p)







def isOrthogonalSG(s1, s2) :
    return abs(dot(s1.p2 - s1.p1, s2.p2 - s2.p1))<EPS



def isParallelLN(s1,s2) :
    return abs(cross(s1.p2 - s1.p1, s2.p2 - s2.p1))<0





COUNTER_CLOCKWISE = 1;
CLOCKWISE = -1;
ONLINE_BACK = -2;
ONLINE_FRONT = 2;
ON_SEGMENT = 0;

def ccw(p0, p1, p2) :
    a = p1 - p0
    b = p2 - p0
    if (cross(a, b) > EPS):
        return COUNTER_CLOCKWISE
    if (cross(a, b) < -EPS):
        return CLOCKWISE
    if (dot(a, b) < -EPS):
        return ONLINE_BACK
    if (norm(a) < norm(b)):
        return ONLINE_FRONT
    
    return ON_SEGMENT;


def toleft(p0,p1,p2):
    a = p1 - p0
    b = p2 - p0  
    tmp=cross(a,b)
    if tmp > EPS:
        return 1
    elif abs(tmp)<EPS and norm(a)<=norm(b):
        return 2  
    elif abs(tmp)<EPS and norm(a)>norm(b):
        return -2  
    else:
        return -1



def reflect(s, p) :
    return p + (project(s, p) - p) * 2.0


def intersectP4(p1, p2, p3, p4) :
    return ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0 and \
            ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0



def intersectSG(s1, s2) :
    return intersectP4(s1.p1, s1.p2, s2.p1, s2.p2)



def getDistanceSG(s1, s2) :
    
    if (intersectSG(s1, s2)):
        return 0.0
    return min(getDistanceSP(s1, s2.p1), getDistanceSP(s1, s2.p2),\
        getDistanceSP(s2, s1.p1), getDistanceSP(s2, s1.p2))




s= [int(x) for x in input().split()]
p0=Point(s[0],s[1])
p1=Point(s[2],s[3])

q=int(input())
for i in range(0,q):
    s= [int(x) for x in input().split()]
    p2=Point(s[0],s[1])
    
    vector1=p1-p0
    vector2=p2-p0
    if cross(vector1,vector2)>0:
        print('COUNTER_CLOCKWISE')
    
    if cross(vector1,vector2)<0:
        print('CLOCKWISE')
        
    if cross(vector1,vector2)==0:
        if dot(vector1,vector2)<0:
            print('ONLINE_BACK')     
        elif dot(vector1,vector2)>=0 and length(vector1)>=length(vector2) : 
            print('ON_SEGMENT')
        elif dot(vector1,vector2)>0 and length(vector1)<length(vector2) : 
            print('ONLINE_FRONT')

Solution (Python):



def cross_product(vect1, vect2):
    return vect1[0]*vect2[1] - vect1[1]*vect2[0]


def vector_plus(vect1, vect2):
    return [el1 + el2 for el1, el2 in zip(vect1, vect2)]


def vector_minus(vect1, vect2):
    return [el1 - el2 for el1, el2 in zip(vect1, vect2)]


def vector_product(vect1, vect2):
    return [el1 * el2 for el1, el2 in zip(vect1, vect2)]


def vector_divide(vect1, vect2):
    return [el1 / el2 for el1, el2 in zip(vect1, vect2)]


def which_place(origin, line_to1, line_to2):
    line1 = vector_minus(line_to1, origin)
    line2 = vector_minus(line_to2, origin)
    judge = cross_product(line1, line2)

    if judge > 0:
        return "COUNTER_CLOCKWISE"
    if judge < 0:
        return "CLOCKWISE"
    if judge == 0:
        try:
            judge2 = line2[0]/line1[0]
        except ZeroDivisionError:
            judge2 = line2[1]/line1[1]
        
        if judge2 < 0:
            return "ONLINE_BACK"
        if judge2 > 1:
            return "ONLINE_FRONT"
        else:
            return "ON_SEGMENT"


if __name__ == '__main__':
    xy_list = list(map(int, input().split()))
    p0_list = xy_list[:2]
    p1_list = xy_list[2:]
    Q = int(input())

    for i in range(Q):
        p2_list = list(map(int, input().split()))
        place = which_place(p0_list, p1_list, p2_list)
        print(place)

Solution (Python):
import math

class Vector:
    def __init__(self,x,y):
        self.x = x
        self.y = y
        
    def __add__(self,other):
        return Vector(self.x+other.x,self.y+other.y)
    
    def __sub__(self,other):
        return Vector(self.x-other.x,self.y-other.y)
    
    def __mul__(self,scalar):
        return Vector(self.x*scalar,self.y*scalar)
    def __rmul__(self, scalar):
        return Vector(self.x*scalar,self.y*scalar)
   
    def __repr__(self):
        return str([self.x,self.y])
        
    def norm_2(self):
        return dot(self,self)
    
    def norm(self):
        return math.sqrt(self.norm_2())
    
def v_sum(v1,v2):
    return Vector(v1.x+v2.x,v1.y+v2.y) 
def scalar_multi(k,v):
    return Vector(k*v.x,k*v.y)
def v_diff(v1,v2):
    return v_sum(v1,scalar_multi(-1,v2))
    
def dot(vector1,vector2):
    return vector1.x*vector2.x+vector1.y*vector2.y

def cross(vector1,vector2):
    return vector1.x*vector2.y-vector1.y*vector2.x


x1,y1,x2,y2 = map(float,input().split())
p1 = Vector(x1,y1)
p2 = Vector(x2,y2)

q = int(input())

for i in range(q):
    x,y = map(float,input().split())
    p3 = Vector(x,y)
    
    a = p2-p1
    v = p3-p1
    if cross(a,v) > 0:
        print('COUNTER_CLOCKWISE')
    elif cross(a,v) < 0:
        print('CLOCKWISE')
    else:
        if dot(a,v)<0:
            print('ONLINE_BACK')
        elif dot(a,v)>a.norm_2():
            print('ONLINE_FRONT')
        else:
            print('ON_SEGMENT')

Solution (Python):
import sys
import math
input = sys.stdin.readline


class Vector():
    def __init__(self, x, y):
        self.x = x
        self.y = y

    def __add__(self, vec):
        return Vector(self.x+vec.x, self.y+vec.y)

    def __sub__(self, vec):
        return Vector(self.x-vec.x, self.y-vec.y)

    def __mul__(self, sc):
        return Vector(self.x*sc, self.y*sc)

    def __truediv__(self, sc):
        return Vector(self.x/sc, self.y/sc)

    def __iadd__(self, vec):
        self.x += vec.x
        self.y += vec.y
        return self

    def __isub__(self, vec):
        self.x -= vec.x
        self.y -= vec.y
        return self

    def __imul__(self, sc):
        self.x *= sc
        self.y *= sc
        return self

    def __itruediv__(self, sc):
        self.x /= sc
        self.y /= sc
        return self

    def __str__(self):
        return '{:.9f} {:.9f}'.format(self.x, self.y)

    def __eq__(self, vec):
        return self.x == vec.x and self.y == vec.y

    def dot(self, vec):
        return self.x * vec.x + self.y * vec.y

    def cross(self, vec):
        return self.x * vec.y - self.y * vec.x

    def abs(self):
        return (self.x*self.x + self.y*self.y)**0.5

    def ortho(self):
        return Vector(-self.y, self.x)

x0, y0, x1, y1 = map(int, input().split())
p0 = Vector(x0, y0)
p1 = Vector(x1, y1)
v1 = p1-p0

for _ in [0]*int(input()):
    x, y = map(int, input().split())
    p2 = Vector(x, y)
    v2 = p2-p0

    det = v2.cross(v1)
    if det > 0:
        print('CLOCKWISE')
    elif det < 0:
        print('COUNTER_CLOCKWISE')
    elif v2.dot(v1) < 0:
        print('ONLINE_BACK')
    elif v2.dot(v2) > v1.dot(v1):
        print('ONLINE_FRONT')
    else:
        print('ON_SEGMENT')

Solution (Python):
EPS = 10**(-9)
def is_equal(a,b):
    return abs(a-b) < EPS

def norm(v,i=2):
    import math
    ret = 0
    n = len(v)
    for j in range(n):
        ret += abs(v[j])**i
    return math.pow(ret,1/i)

class Vector(list):
    """
    ベクトルクラス
    対応演算子
    +  : ベクトル和 
    -  : ベクトル差
    *  : スカラー倍、または内積
    /  : スカラー除法
    ** : 外積
    += : ベクトル和
    -= : ベクトル差
    *= : スカラー倍
    /= : スカラー除法

    メソッド
    self.norm(i) : L{i}ノルムを計算
    """
    def __add__(self,other):
        n = len(self)
        ret = [0]*n
        for i in range(n):
            ret[i] = super().__getitem__(i) + other.__getitem__(i)
        return self.__class__(ret)
    
    def __radd__(self,other):
        n = len(self)
        ret = [0]*n
        for i in range(n):
            ret[i] = other.__getitem__(i) + super().__getitem__(i)
        return self.__class__(ret)
    
    def __iadd__(self, other):
        n = len(self)
        for i in range(n):
            self[i] += other.__getitem__(i)
        return self

    def __sub__(self,others):
        n = len(self) 
        ret = [0]*n
        for i in range(n):
            ret[i] = super().__getitem__(i) - others.__getitem__(i)
        return self.__class__(ret)

    def __iadd__(self, other):
        n = len(self)
        for i in range(n):
            self[i] -= other.__getitem__(i)
        return self

    def __rsub__(self,others):
        n = len(self) 
        ret = [0]*n
        for i in range(n):
            ret[i] = others.__getitem__(i) - super().__getitem__(i)
        return self.__class__(ret)
    
    def __mul__(self,other):
        n = len(self)
        if isinstance(other,list):
            ret = 0
            for i in range(n):
                ret += super().__getitem__(i)*other.__getitem__(i)
            return ret
        else:
            ret = [0]*n
            for i in range(n):
                ret[i] = super().__getitem__(i)*other
            return self.__class__(ret)

    def __rmul__(self,other):
        n = len(self)
        if isinstance(other,list):
            ret = 0
            for i in range(n):
                ret += super().__getitem__(i)*other.__getitem__(i)
            return ret
        else:
            ret = [0]*n
            for i in range(n):
                ret[i] = super().__getitem__(i)*other
            return self.__class__(ret)
    
    
    def __truediv__(self,other):
        """
        ベクトルのスカラー除法
        Vector/scalar
        """
        n = len(self)
        ret = [0]*n
        for i in range(n):
            ret[i] = super().__getitem__(i)/other
        return self.__class__(ret)
    
    def norm(self,i):
        """
        L{i}ノルム
        self.norm(i)
        """
        return norm(self,i)
    
    def __pow__(self,other):
        """
        外積
        self**other
        """
        n = len(self)
        ret = [0]*3
        x = self[:]
        y = other[:]
        if n == 2:
            x.append(0)
            y.append(0)
        if n == 2 or n == 3:
            for i in range(3):
                ret[0],ret[1],ret[2] = x[1]*y[2]-x[2]*y[1],x[2]*y[0]-x[0]*y[2],x[0]*y[1]-x[1]*y[0]
            ret = Vector(ret)
            if n == 2:
                return ret
            else:
                return ret

class Segment:
    """
    線分クラス
    """
    def __init__(self,v1,v2):
        self.v1 = v1
        self.v2 = v2
    
    def length(self):
        return norm(self.v1-self.v2)

    def get_unit_vec(self):
        
        dist = norm(self.v2-self.v1)
        if dist != 0:
            return (self.v2-self.v1)/dist
        else:
            return False
    
    def projection(self,vector):
        
        unit_vec = self.get_unit_vec()
        t = unit_vec*(vector-self.v1)
        return self.v1 + t*unit_vec
    
    def is_vertical(self,other):
        
        return is_equal(0,self.get_unit_vec()*other.get_unit_vec())
    
    def is_horizontal(self,other):
        
        return is_equal(0,self.get_unit_vec()**other.get_unit_vec())
    
    def reflection(self,vector):
        
        projection = self.projection(vector)
        v = projection - vector
        return projection + vector
    
    def include(self,vector):
        
        proj = self.projection(vector)
        if not is_equal(norm(proj-vector),0):
            return False
        else:
            n = len(self.v1)
            f = True
            for i in range(n):
                f &= ((self.v1[i] <= vector[i] <= self.v2[i]) or (self.v2[i] <= vector[i] <=self.v1[i]))
            return f
    
    def distance(self,other):
        
        if isinstance(other,Vector):
            proj = self.projection(other)
            if self.include(proj):
                return norm(proj-other)
            else:
                ret = []
                ret.append(norm(self.v1-other))
                ret.append(norm(self.v2-other))
                return min(ret)


class Line(Segment):
    """
    直線クラス
    """
    
    def include(self,vector):
        proj = self.projection(vector)
        return is_equal(norm(proj-vector),0)

xp0,yp0,xp1,yp1 = map(int,input().split())
p0 = Vector([xp0,yp0])
p1 = Vector([xp1,yp1])
p01 = p1-p0
q = int(input())
p2s = [0]*q
p02s = [0]*q
L01 = Line(p0,p1)
S01 = Segment(p0,p1)
for i in range(q):
    p2s[i] = Vector(list(map(int,input().split())))
    p02s[i] = p2s[i]-p0

ans = [0]*q
for i in range(q):
    p02 = p02s[i]
    p2 = p2s[i]
    S21 = Segment(p2,p1)
    S02 = Segment(p0,p2)
    if L01.include(p2):
        if S01.include(p2):
                ans[i] = "ON_SEGMENT"
        elif S02.length != 0 and S02.include(p1):
            ans[i] = "ONLINE_FRONT"
        elif S21.length != 0 and S21.include(p0):
            ans[i] = "ONLINE_BACK"
    else:
        cross = p01**p02
        if cross[2] > 0:
            ans[i] = "COUNTER_CLOCKWISE"
        else:
            ans[i] = "CLOCKWISE"

for i in range(q):
    print(ans[i])

Solution (Python):
import math

class Point:
    def __init__(self, x, y):
        self.x = x
        self.y = y
    def __add__(self, other):
        return Point(self.x + other.x, self.y + other.y)
    def __sub__(self, other):
        return Point(self.x - other.x, self.y - other.y)
    def __mul__(self, other):
        return Point(self.x * other, self.y * other)
    def __floordiv__(self, other):
        return Point(self.x / other, self.y / other)
    def __repr__(self):
        return str(self.x) + ' ' + str(self.y)

class Vector(Point):
    pass

class Line:
    def __init__(self, p1, p2):
        self.p1 = p1
        self.p2 = p2

class Segment(Line):
    pass

def points_to_vector(p1, p2):
    x = p1.x - p2.x
    y = p1.y - p2.y
    return Vector(x, y)

def vector(p):
    return Vector(p.x, p.y)

def dot(v1, v2):
    return v1.x * v2.x + v1.y * v2.y

def cross(v1, v2):
    return v1.x * v2.y - v1.y * v2.x

def norm(v):
    return v.x**2 + v.y**2

def distance(v):
    return math.sqrt(norm(v))

def project(s, p):
    base = points_to_vector(s.p1, s.p2)
    hypo = points_to_vector(p, s.p1)
    r = dot(hypo, base) / norm(base)
    return s.p1 + base * r

def reflect(s, p):
    return p + (project(s, p) -p) * 2

def ccw(p0, p1, p2):
    EPS = 1e-10
    v1 = p1 - p0
    v2 = p2 - p0
    if cross(v1, v2) > EPS:
        return 'COUNTER_CLOCKWISE'
    elif cross(v1, v2) < -EPS:
        return 'CLOCKWISE'
    elif dot(v1, v2) < -EPS:
        return 'ONLINE_BACK'
    elif norm(v1) < norm(v2):
        return 'ONLINE_FRONT'
    else:
        return 'ON_SEGMENT'

import sys


temp = list(map(int, input().split()))
p0 = Point(temp[0], temp[1])
p1 = Point(temp[2], temp[3])
q = int(input())
for i in range(q):
    x, y = map(int, input().split())
    p2 = Point(x, y)
    print(ccw(p0, p1, p2))

Solution (Python):
import math

EPS = 1e-10

COUNTER_CLOCKWISE = 1
CLOCKWISE = -1
ONLINE_BACK = 2
ONLINE_FRONT = -2
ON_SEGMENT = 0

class Segment():
    def __init__(self, p1, p2):
        self.p1 = p1
        self.p2 = p2

class Point():
    def __init__(self, x, y):
        self.x = x
        self.y = y

    def __add__(self, point):
        
        return Point(self.x+point.x, self.y+point.y)

    def __sub__(self, point):
        
        return Point(self.x-point.x, self.y-point.y)

    def __mul__(self, a):
        
        return Point(a*self.x, a*self.y)

    def __truediv__(self, a):
        
        return Point(self.x/a, self.y/a)

    def __abs__(self):
        
        return math.sqrt(self.norm())

    def norm(self):
        return self.x**2+self.y**2

    def __eq__(self, point):
        
        return abs(self.x-point.x) < EPS and abs(self.y-point.y) <EPS

def dot(a, b):
    return a.x*b.x+a.y*b.y

def cross(a, b):
    return a.x*b.y - a.y*b.x

def isOrthogonal(a, b):
    return dot(a, b) == 0

def isParallel(a, b):
    return cross(a, b) == 0

def project(s, p):
    
    base = s.p2 - s.p1
    r = dot(p-s.p1, base)/base.norm()
    return s.p1+base*r

def reflect(s, p):
    return p+(project(s, p)-p)*2

def get_distance(a, b):
    return abs(a-b)

def get_distance_lp(l, p):
    return abs(cross(l.p2-l.p1, p-l.p1)/abs(l.p2-l.p1))

def get_distance_sp(s, p):
    if dot(s.p2-s.p1, p-s.p1) < 0:
        return abs(p-s.p1)
    if dot(s.p1-s.p2, p-s.p2) < 0:
        return abs(p-s.p2)
    return get_distance_lp(s, p)

def intersect(s1, s2):
    return True
    
def get_distance(s1, s2):
    if intersect(s1, s2):
        return 0
    return min([get_distance_sp(s1, s2.p1), get_distance_sp(s1, s2.p2),
                get_distance_sp(s2, s1.p1), get_distance_sp(s2, s1.p2)])

def ccw(p0, p1, p2):
    a = p1 - p0
    b = p2 - p0
    if cross(a, b) > EPS:
        return COUNTER_CLOCKWISE
    if cross(a, b) < -EPS:
        return CLOCKWISE
    if dot(a, b) < -EPS:
        return ONLINE_BACK
    if a.norm() < b.norm():
        return ONLINE_FRONT
    return ON_SEGMENT


if __name__ == '__main__':
    from sys import stdin
    input = stdin.readline

    x0, y0, x1, y1 = map(int, input().split())
    p0 = Point(x0, y0)
    p1 = Point(x1, y1)

    q = int(input())
    for _ in range(q):
        x2, y2 = map(int, input().split())
        p2 = Point(x2, y2)
        
        
        ans = ccw(p0, p1, p2)
        if ans == -2:
            print('ONLINE_FRONT')
        if ans == -1:
            print('CLOCKWISE')
        if ans == 0:
            print('ON_SEGMENT')
        if ans == 1:
            print('COUNTER_CLOCKWISE')
        if ans == 2:
            print('ONLINE_BACK')

Solution (Python):
from math import pi, cos, sin, atan2
EPS = 10**(-9)

def eq(value1, value2):
    return abs(value1-value2) <= EPS

class Point():
    def __init__(self, x, y):
        self.x = x
        self.y = y
        self.arg = atan2(y, x) 
    
    def __str__(self):
        return "{0:.8f} {1:.8f}".format(self.x, self.y)
    
    def __add__(self, other):
        return Point(self.x + other.x, self.y + other.y)
    
    def __sub__(self, other):
        return Point(self.x - other.x, self.y - other.y)
    
    def __mul__(self, scal):
        return Point(self.x*scal, self.y*scal)
    
    def __truediv__(self, scal):
        return Point(self.x/scal, self.y/scal)
    
    def __eq__(self, other):
        return eq(self.x, other.x) and eq(self.y, other.y)

    
    def __abs__(self):
        return (self.x**2+self.y**2)**0.5
    

def Rotation(vec: Point, rad):
    return Point(vec.x*cos(rad)-vec.y*sin(rad), vec.x*sin(rad)+vec.y*cos(rad))


class Circle():
    def __init__(self, p, r):
        self.p = p
        self.r = r


class Line():
    
    def __init__(self, a, b):
        self.a = a
        self.b = b
        self.arg = (a-b).arg % pi
    
    def __str__(self):
        return "[({0}, {1}) - ({2}, {3})]".format(self.a.x, self.a.y, self.b.x, self.b.y)

    
    def par(self, point):
        return Line(point, point+(self.a-self.b))

    
    def tan(self, point):
        return Line(point, point + Rotation(self.a-self.b, pi/2))


class Segment(Line):
    def __init__(self, a, b):
        super(Line, self).__init__(a, b)



def cross(vec1: Point, vec2: Point):
    return vec1.x*vec2.y - vec1.y*vec2.x


def dot(vec1: Point, vec2: Point):
    return vec1.x*vec2.x + vec1.y*vec2.y


def ccw(a, b, c):
    if cross(b-a, c-a) > EPS: return +1 
    if cross(b-a, c-a) < -EPS: return -1 
    if dot(c-a, b-a) < -EPS: return +2 
    if abs(b-a) < abs(c-a): return -2 
    return 0 



def projection(l, p):
    t = dot(l.b-l.a, p-l.a) / abs(l.a-l.b)**2
    return l.a + (l.b-l.a)*t


def reflection(l, p):
    return p + (projection(l, p) - p)*2

def isPararell(l1, l2):
    return eq(cross(l1.a-l1.b, l2.a-l2.b), 0)

def isVertical(l1, l2):
    return eq(dot(l1.a-l1.b, l2.a-l2.b), 0)


def isIntersect_lp(l, p):
    return abs(ccw(l.a, l.b, p)) != 1

def isIntersect_ll(l1, l2):
    return not isPararell(l1, l2) or isIntersect_lp(l1, l2.a)

def isIntersect_sp(s, p):
    return ccw(s.a, s.b, p) == 0

def isIntersect_ss(s1, s2):
    return ccw(s1.a, s1.b, s2.a)*ccw(s1.a, s1.b, s2.b) <= 0 and ccw(s2.a, s2.b, s1.a)*ccw(s2.a, s2.b, s1.b) <= 0

def isIntersect_ls(l, s):
    return cross(l.b - l.a, s.a - l.a) * cross(l.b - l.a, s.b - l.a) < EPS

def isIntersect_cp(c, p):
    return abs(abs(c.p - p) - c.r) < EPS

def isIntersect_cl(c, l):
    return distance_lp(l, c.p) <= c.r + EPS

def isIntersect_cs(c, s):
    pass

def isIntersect_cc(c1, c2):
    pass


def distance_pp(p1, p2):
    return abs(p1-p2)

def distance_lp(l, p):
    return abs(projection(l,p)-p)

def distance_ll(l1, l2):
    return 0 if isIntersect_ll(l1, l2) else distance_lp(l1, l2.a)

def distance_sp(s, p):
    r = projection(s, p)
    if isIntersect_sp(s, r): return abs(r-p)
    return min(abs(s.a-p), abs(s.b-p))

def distance_ss(s1, s2):
    if isIntersect_ss(s1, s2): return 0
    return min([distance_sp(s1, s2.a), distance_sp(s1, s2.b), distance_sp(s2, s1.a), distance_sp(s2, s1.b)])

def distance_ls(l, s):
    if isIntersect_ls(l, s): return 0
    return min(distance_lp(l, s.a), distance_lp(l, s.b))


def crosspoint_ll(l1, l2):
    A = cross(l1.b - l1.a, l2.b - l2.a)
    B = cross(l1.b - l1.a, l1.b - l2.a)
    if eq(abs(A), 0) and eq(abs(B), 0): return l2.a
    return l2.a + (l2.b - l2.a) * B / A

def crosspoint_ss(s1, s2):
    return crosspoint_ll(s1, s2)

def crosspoint_lc(l, c):
    if eq(distance_lp(l, c.p), c.r): return [c.p]
    p = projection(l, c.p)
    e = (l.b - l.a) / abs(l.b-l.a)
    dis = (c.r**2-abs(p-c.p)**2)**0.5
    return [p + e*dis, p - e*dis]

def crosspoint_sc(s, c):
    pass

def crosspoint_cc(c1, c2):
    d = abs(c1.p-c2.p)
    if not abs(c1.r-c2.r) <= d <= c1.r+c2.r:
        return []
    mid_p = (c2.p * (c1.r**2-c2.r**2+d**2) + c1.p * (c2.r**2-c1.r**2+d**2)) / (2*d**2)
    tanvec = Rotation(c1.p-c2.p, pi/2)
    return crosspoint_lc(Line(mid_p, mid_p+tanvec), c1)



def tangent_cp(c, p):
    return crosspoint_cc(c, Circle(p, (abs(p-c.p)**2 - c.r**2)**0.5))





import sys
input = sys.stdin.readline

def verify_1A():
    p1x, p1y, p2x, p2y = map(int, input().split())
    l = Line(Point(p1x, p1y), Point(p2x, p2y))
    Q = int(input())
    Query = [list(map(int, input().split())) for _ in range(Q)]
    for px, py in Query:
        p = Point(px, py)
        print(projection(l, p))

def verify_1B():
    p1x, p1y, p2x, p2y = map(int, input().split())
    l = Line(Point(p1x, p1y), Point(p2x, p2y))
    Q = int(input())
    Query = [list(map(int, input().split())) for _ in range(Q)]
    for px, py in Query:
        p = Point(px, py)
        print(reflection(l, p))

def verify_1C():
    p1x, p1y, p2x, p2y = map(int, input().split())
    p1 = Point(p1x, p1y); p2 = Point(p2x, p2y)
    Q = int(input())
    Query = [list(map(int, input().split())) for _ in range(Q)]
    for px, py in Query:
        p = Point(px, py)
        result = ccw(p1, p2, p)
        if result == 1:
            print("COUNTER_CLOCKWISE")
        elif result == -1:
            print("CLOCKWISE")
        elif result == 2:
            print("ONLINE_BACK")
        elif result == -2:
            print("ONLINE_FRONT")
        else:
            print("ON_SEGMENT")

verify_1C()

Solution (Python):
def dot(a,b):
    return a.real*b.real+a.imag*b.imag

def cross(a,b):
    return a.real*b.imag-a.imag*b.real

x0,y0,x1,y1=map(int,input().split())
q=int(input())
p0=x0+y0*1j
p1=x1+y1*1j
a=p1-p0

for x2, y2 in (map(int, input().split()) for _ in [0]*q):
    p2=x2+y2*1j
    b=p2-p0
    S=cross(a,b)
    if S>0: 
        print("COUNTER_CLOCKWISE")
    elif S<0: 
        print("CLOCKWISE")
    else:               
        if dot(a,b)>=0:
            if dot(a,a)<dot(b,b):
                print("ONLINE_FRONT") 
            else:
                print("ON_SEGMENT") 
        else:
            print("ONLINE_BACK")