inf = open("bank.in", "r")
ouf = open("bank.out", "w")

n = int(inf.readline())

s = []
for i in range(0, n):
	s.append(inf.readline().strip())

p = inf.readline().strip()
m = len(p)

ans = []
if not all(map(lambda i: any(map(lambda s: s[i] == p[i], s)), range(0, m))):
	ouf.write("-1")
else:
	sum = lambda s: reduce(lambda x, y: x + y, map(lambda i: s[i] == p[i], range(0, m)))
	best = max(map(sum, s))
	i = filter(lambda t: sum(t[1]) == best, enumerate(s))[0][0]
	for k in range(0, m):
		if s[i][k] != p[k]:
			j = filter(lambda t: t[1][k] == p[k], enumerate(s))[0][0]
			ans.append(str(i + 1) + " " + str(j + 1) + " " + str(k + 1))
	ouf.write(str(len(ans)) + "\n")
	for x in ans:
		ouf.write(x + "\n")

inf.close()
ouf.close()