occw = {1:"COUNTER_CLOCKWISE",-1:"CLOCKWISE",2:"ONLINE_BACK",-2:"ONLINE_FRONT",0:"ON_SEGMENT"}
def ccw(p0, p1, p2):
    a = p1 - p0
    b = p2 - p0
    # print(a,b,np.cross(a,b))
    if (np.cross(a,b) > np.finfo(np.float).eps):
        return 1 #COUNTER_CLOCKWISE
    if (np.cross(a,b) < - np.finfo(np.float).eps):
        return -1 # CLOCKWISE
    if (np.dot(a,b) < - np.finfo(np.float).eps):
        return 2 # ONLINE_BACK
    if (np.linalg.norm(a) < np.linalg.norm(b)):
        return -2 # ONLINE_FRONT
    return 0 # ON_SEGMENT

a = []
a.append(map(int, raw_input().split()))
for aa in a:
    t = np.array(aa).reshape(2,2)
    p0 = t[0] #[::-1]
    p1 = t[1] #[::-1]

# print(p0,p1)
n = input()
for i in range(n):
    a = []
    a.append(map(int, raw_input().split()))
    for aa in a:
        hn = np.array(aa).reshape(1,2)
        hn = hn[0] #[::-1]
        # print(hn)
        print(occw[ccw(p0,p1,hn)])

Refs.

Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account log in.