h, w, k, p = map(int, input().split()) P = [] N = [] for _ in range(k): x, y, name = input().split() P.append((int(x), int(y))) N.append(name) Directions = [(1, 0), (0, 1)] ans = 0 ans_bit = -1 for bit in range(1 << k): DP = [[0 for _ in range(w + 1)] for _ in range(h + 1)] DP[0][0] = 1 cnt = 0 for i in range(k): if (bit >> i) & 1: cnt += 1 else: x, y = P[i] DP[x][y] = -1 if cnt > p: continue for i in range(h + 1): for j in range(w + 1): if DP[i][j] > 0: for di, dj in Directions: ni, nj = i + di, j + dj if ni <= h and nj <= w and DP[ni][nj] != -1: DP[ni][nj] += DP[i][j] if DP[h][w] > ans: ans = DP[h][w] ans_bit = bit mod = 10**9 + 7 print(ans % mod) if ans > 0: for i in range(k): if (ans_bit >> i) & 1: print(N[i])