import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;

public class bank_sm extends Thread {

	void solve() throws NumberFormatException, IOException {
		int n = Integer.parseInt(in.readLine());
		String[] s = new String[n];
		for (int i = 0; i < s.length; i++) {
			s[i] = in.readLine();
		}
		String p = in.readLine();
		boolean can = true;
		for (int i = 0; i < p.length(); i++) {
			boolean cani = false;
			for (int j = 0; j < s.length; j++) {
				if (s[j].charAt(i) == p.charAt(i)) {
					cani = true;
					break;
				}
			}
			if (!cani) {
				can = false;
				break;
			}
		}
		if (!can) {
			out.println("-1");
			return;
		}
		int best = Integer.MAX_VALUE;
		int besti = -1;
		for (int i = 0; i < s.length; i++) {
			int ans = 0;
			for (int j = 0; j < s[i].length(); j++) {
				if (s[i].charAt(j) == p.charAt(j))
					continue;
				ans++;
			}
			if (ans < best) {
				best = ans;
				besti = i;
			}
		}
		out.println(best);
		for (int j = 0; j < s[besti].length(); j++) {
			if (s[besti].charAt(j) == p.charAt(j))
				continue;
			for (int i = 0; i < s.length; i++) {
				if (s[i].charAt(j) == p.charAt(j)) {
					out.println((besti + 1) + " " + (i + 1) + " " + (j + 1));
					break;
				}
			}
		}

	}

	void myAssert(boolean b) {
		if (!b)
			throw new AssertionError();
	}

	BufferedReader in;
	PrintWriter out;

	public void run() {
		try {
			in = new BufferedReader(new FileReader("bank.in"));
			out = new PrintWriter(new File("bank.out"));
			solve();
			out.flush();
			out.close();
			// new FilePrinter("bank.out",System.out);
		} catch (IOException e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	public static void main(String[] args) {
		new bank_sm().start();
	}

}
