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

public class bank_aa implements Runnable {

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

	BufferedReader br;

	StringTokenizer st;

	PrintWriter out;

	boolean eof = false;

	Random rand = new Random(this.hashCode());

	public void run() {
		Locale.setDefault(Locale.US);
		try {
			br = new BufferedReader(new FileReader(FNAME + ".in"));
			out = new PrintWriter(FNAME + ".out");
			solve();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			System.exit(566);
		}
	}

	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				eof = true;
				return "0";
			}
		}
		return st.nextToken();
	}

	int nextInt() {
		return Integer.parseInt(nextToken());
	}

	String FNAME = "bank";

	private void solve() throws IOException {
		int n = nextInt();
		char[][] a = new char[n][];
		for (int i = 0; i < a.length; i++) {
			a[i] = nextToken().toCharArray();
		}
		char[] p = nextToken().toCharArray();
		int max = 0;
		int maxi = 0;
		for (int i = 0; i < a.length; i++) {
			int m = 0;
			for (int j = 0; j < p.length; j++) {
				if (p[j] == a[i][j]) {
					m++;
				}
			}
			if (m > max) {
				max = m;
				maxi = i;
			}
		}
		ArrayList<String> ans = new ArrayList<String>();
		for (int i = 0; i < p.length; i++) {
			if (a[maxi][i] != p[i]) {
				boolean good = false;
				for (int j = 0; j < a.length; j++) {
					if (a[j][i] == p[i]) {
						ans.add((maxi + 1) + " " + (j + 1) + " " + (i + 1));
						good = true;
						break;
					}
				}
				if (!good) {
					out.println("-1");
					return;
				}
			}
		}
		out.println(ans.size());
		for (String s : ans) {
			out.println(s);
		}
	}
}
