import java.io.*;

/**
 * @author Roman V Satyukov
 */
public class bank_rs implements Runnable {
	private final String problemID = getClass().getName().split("_")[0].toLowerCase();
	private BufferedReader in;
	private PrintWriter out;
	
	private void check(boolean expr, String message) {
		if (!expr) {
			throw new AssertionError(message);
		}
	}
	
	private void solve() throws IOException {
		int n = Integer.parseInt(in.readLine());
		check((2 <= n) && (n <= 100), "n is not in [2..100]");
		String[] str = new String[n + 1];
		for (int i = 0; i <= n; i++) {
			str[i] = in.readLine();
			for (int j = 0; j < str[i].length(); j++) {
				check(('a' <= str[i].charAt(j)) && (str[i].charAt(j) <= 'z'), "One of strings contains non-english characters");
			}
		}
		for (int i = 1; i <= n; i++) {
			check(str[0].length() == str[i].length(), "Not all lengths are equal");
		}
		check((2 <= str[0].length()) && (str[0].length() <= 100), "String lengths are not in [2..100]");
		
		int m = str[0].length();
		int min = Integer.MAX_VALUE;
		int mini = -1;
		for (int i = 0; i < n; i++) {
			int diff = 0;
			for (int j = 0; j < m; j++) {
				if (str[i].charAt(j) != str[n].charAt(j)) {
					diff++;
				}
			}
			if (diff < min) {
				min = diff;
				mini = i;
			}
		}
		for (int j = 0; j < m; j++) {
			boolean ok = false;
			for (int i = 0; i < n; i++) {
				if (str[i].charAt(j) == str[n].charAt(j)) {
					ok = true;
					break;
				}
			}
			if (!ok) {
				out.println(-1);
				return;
			}
		}
		out.println(min);
		for (int j = 0; j < m; j++) {
			if (str[mini].charAt(j) == str[n].charAt(j)) {
				continue;
			}
			int w = -1;
			for (int i = 0; i < n; i++) {
				if (str[i].charAt(j) == str[n].charAt(j)) {
					w = i;
					break;
				}
			}
			out.println((mini + 1) + " " + (w + 1) + " " + (j + 1));
		}
	}
	
	public static void main(String[] args) {
		new Thread(new bank_rs()).start();
	}

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