import java.io.*;
import java.util.*;

public class bank_md implements Runnable {
	private static Scanner in;
	private static PrintWriter out;

	@Override
	public void run() {
		int n = in.nextInt();
		String[] s = new String[n];
		for (int i = 0; i < n; i++) {
			s[i] = in.next();
		}
		String p = in.next();
		int len = s[0].length();
		int[] common = new int[n];
		int[] where = new int[len];
		Arrays.fill(where, -1);
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < len; j++) {
				if (s[i].charAt(j) == p.charAt(j)) {
					common[i]++;
					where[j] = i;
				}
			}
		}
		for (int j = 0; j < len; j++) {
			if (where[j] == -1) {
				out.println(-1);
				return;
			}
		}
		int best = 0;
		for (int i = 1; i < n; i++) {
			if (common[i] > common[best])
				best = i;
		}
		out.println(len - common[best]);
		for (int j = 0; j < len; j++) {
			if (s[best].charAt(j) != p.charAt(j)) {
				out.println((where[j] + 1) + " " + (best + 1) + " " + (j + 1));
			}
		}
	}

	public static void main(String[] args) throws IOException, InterruptedException {
		Locale.setDefault(Locale.US);
		in = new Scanner(new File("bank.in"));
		out = new PrintWriter("bank.out");
		Thread thread = new Thread(new bank_md());
		thread.start();
		thread.join();
		in.close();
		out.close();
	}
}
