import java.io.BufferedReader;
import java.io.InputStreamReader;

public class ColorfulTribune {
	static public char[][] pole;
	static public boolean[][] positionIsTakenByShirt;
	static public int failedPerson = -1;
	static public int failedPosition = -1;
	static public int commonMask;
	
	public static void main(String [] arguments) throws Exception {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		String line;
		while ((line = reader.readLine()) != null) {
			int n = Integer.parseInt(line);
			pole = new char[n][];
			positionIsTakenByShirt = new boolean[n][30];
			failedPerson = -1;
			failedPosition = -1;
			for (int i=0; i<n; i++) {
				pole[i] = reader.readLine().toCharArray();
				for (int j=0; j<n; j++) {
					if (positionIsTakenByShirt[j][pole[i][j]-'A']) {
						failedPerson = i;
						failedPosition = j;
					}
					positionIsTakenByShirt[j][pole[i][j]-'A'] = true;
				}
			}
			commonMask = commonMask();
			for (int i=0; i<n; i++) {
				if (failedPerson == -1 && mask(pole[i]) != commonMask) {
					failedPerson = i;
					failedPosition = whichCharIndexIsWrong(pole[i]);
				}
			}
			
			System.out.println((failedPerson+1)+" "+(failedPosition+1)+" "+figureOutMissingChar());
		}
	}
	
	public static int mask(char[] line) {
		int mask = 0;
		for (char c : line) {
			mask |= (1 << (c-'A'));
		}
		return mask;
	}
	
	public static int commonMask() {
		if (pole.length == 3) {
			int a = mask(pole[0]);
			int b = mask(pole[1]);
			int c = mask(pole[2]);
			if (a == b) return a;
			if (b == c) return c;
			if (a == c) return a;
		}
		
		int previous = 0;
		for (char [] line : pole) {
			int current = mask(line);
			if (current == previous) {
				return previous;
			}
			previous = current;
		}
		throw new RuntimeException("WTF");
	}
	
	public static int whichCharIndexIsWrong(char[] line) {
		int currentCounted = 0;
		for (int i=0; i<line.length; i++) {
			int mask = (1 << (line[i]-'A'));
			if ((currentCounted & mask) != 0) {
				return i;
			}
			currentCounted |= mask;
			if ((commonMask & mask) == 0) {
				return i;
			}
		}
		throw new RuntimeException("WTF2");
	}
	
	public static char figureOutMissingChar() {
		for (char c = 'A'; c <= 'Z'; c++) {
			pole[failedPerson][failedPosition] = c;
			if (mask(pole[failedPerson]) == commonMask) {
				return c;
			}
		}
		throw new RuntimeException("WTF3");
	}
}
