import itertools H, W, K, P = map(int, input().split()) coordinates = dict() name = [''] * K for i in range(K): x, y, n = input().split() coordinates[(int(y), int(x))] = i name[i] = n ans = 0 indices = () for t in itertools.combinations(range(K), P): table = [[0] * (H + 2) for _ in range(W + 2)] table[1][1] = 1 it = itertools.product(range(W + 1), range(H + 1)) next(it) for w, h in it: if (w, h) not in coordinates or coordinates[(w, h)] in t: table[w + 1][h + 1] = table[w][h + 1] + table[w + 1][h] if ans < table[W + 1][H + 1]: indices = t ans = table[W + 1][H + 1] print(ans) for i in indices: print(name[i])