{-# LANGUAGE GeneralizedNewtypeDeriving #-}

import           Control.Applicative
import           Control.Monad
import qualified Data.ByteString.Char8 as B
import           Text.Printf

readi :: B.ByteString -> Int
readi b | Just (n, _) <- B.readInt b = n

--

newtype VDouble =
    VDouble Double
    deriving (Show, Read, Num, Floating, Fractional)

instance Eq VDouble where
    VDouble a == VDouble b = abs (a - b) < 1e-10

instance Ord VDouble where
    VDouble a `compare` VDouble b
        | VDouble a == VDouble b = EQ
        | a <  b                 = LT
        | otherwise              = GT

--

newtype V2 =
    V2 (VDouble, VDouble)
    deriving (Show)

(|+|) :: V2 -> V2 -> V2
V2 (a, b) |+| V2 (c, d) = V2 (a + c, b + d)

(|-|) :: V2 -> V2 -> V2
V2 (a, b) |-| V2 (c, d) = V2 (a - c, b - d)

(*|) :: VDouble -> V2 -> V2
k *| V2 (c, d) = V2 (k * c, k * d)

norm :: V2 -> VDouble
norm (V2 (a, b)) = a * a + b * b

abs' :: V2 -> VDouble
abs' = sqrt . norm

dot :: V2 -> V2 -> VDouble
V2 (a, b) `dot` V2 (c, d) = a * c + b * d

cross :: V2 -> V2 -> VDouble
V2 (a, b) `cross` V2 (c, d) = a * d - b * c

--

data Wise
    = COUNTER_CLOCKWISE
    | CLOCKWISE
    | ONLINE_BACK
    | ONLINE_FRONT
    | ON_SEGMENT
    deriving (Show)

ccw :: V2 -> V2 -> V2 -> Wise
ccw p0 p1 p2
    | cross a b > 0   = COUNTER_CLOCKWISE
    | cross a b < 0   = CLOCKWISE
    | dot a b < 0     = ONLINE_BACK
    | norm a < norm b = ONLINE_FRONT
    | otherwise       = ON_SEGMENT
  where
    a = p1 |-| p0
    b = p2 |-| p0

main :: IO ()
main = do
    [x0, y0, x1, y1] <- fmap (fromIntegral . readi) . B.words <$> B.getLine
    let p0 = V2 (x0, y0)
    let p1 = V2 (x1, y1)
    q <- readLn
    replicateM_ q $ do
        [a, b] <- fmap (fromIntegral . readi) . B.words <$> B.getLine
        let p2 = V2 (a, b)
        print $ ccw p0 p1 p2

