# Given a file containing a point set and a k-edge-coloring of the 
# induced straight-line drawing of K_n, this script counts the total number of crossings
# and the number of monochromatic crossings

import sys

# Returns whether vertices with indices i j k in this order form a counterclockwise triangle
def ccw(i,j,k):
    [ix,iy] = coordinates[i]
    [jx,jy] = coordinates[j]
    [kx, ky] = coordinates[k]
    alpha = (ky-iy) * (jx-ix) - (jy-iy) * (kx-ix)
    if alpha == 0:
        print("Collinear points", i, j, k)
        sys.exit()
    return alpha > 0

# Check if edge between points with indices i and j crosses edge between points with indices k and l
def is_crossing(i,j,k,l):
    return ccw(i,k,l) != ccw(j,k,l) and ccw(i,j,k) != ccw(i,j,l)

# Returns the index of the edge between points with indices i and j 
def edge_to_index(i,j):
    if i == j:
        print("There are no loops in K_n")
        sys.exit()
    a = min(i,j)
    b = max(i,j)
    return (N*(N-1) - (N-a-1)*(N-a)) // 2 + b - a - 1


## BEGINNING OF LOGIC
if len(sys.argv) < 2:
    print("Requires file path of a drawing")
    sys.exit()

# Read input file
with open(sys.argv[1], "r") as input:
    file_extension = sys.argv[1].split(".")[-1]
    N = int(input.readline().split(" ")[0])
    M = (N * (N -1)) // 2

    assert file_extension.startswith("co"), "File does not contain coordinates of point set"

    K = int(file_extension[2:])
    coordinates = [list(map(int, input.readline().split(" "))) for i in range(N)]
    coloring = input.readline()

counter_mon = 0
counter_all = 0
for i in range(N):
    for j in range(i+1,N):
        for k in range(i+1, N):
            if k == j: continue
            for l in range(k+1,N):
                if l == j: continue
                if is_crossing(i,j,k,l):
                    if coloring[edge_to_index(i,j)] == coloring[edge_to_index(k,l)]:
                        counter_mon += 1
                    counter_all += 1

print("All crossings: ", counter_all)
print("Monochromatic crossings: ", counter_mon)