import java.util.ArrayList; import java.util.Comparator; import java.util.Scanner; /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /** * * @author mahansky */ public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); while (scanner.hasNextLine()) { int rowCount = Integer.parseInt(scanner.nextLine()); ArrayList rows = new ArrayList(); ArrayList orig = new ArrayList(); for (int i = 0; i < rowCount; i++) { ArrayList row = new ArrayList(); String in = scanner.nextLine(); orig.add(in); String[] chars = in.split(""); for (int j = 0; j < chars.length; j++) { row.add(chars[j]); } row.sort(new Comparator() { @Override public int compare(String o1, String o2) { return o1.compareTo(o2); } }); String rrr = ""; for (int j = 0; j < row.size(); j++) { rrr += row.get(j); } rows.add(rrr); } String good = ""; int rowIndex = 0; int colIndex = 0; if (rows.get(0).equals(rows.get(1))) { for (int i =2; i < rows.size(); i++) { if (!rows.get(i).equals(rows.get(0))) { rowIndex = i + 1; good = rows.get(0); break; } } } else if (rows.get(0).equals(rows.get(2))) { rowIndex = 2; good = rows.get(0); } else { rowIndex = 1; good = rows.get(1); } String pismeno = ""; for (int i =0; i < good.length(); i++) { if(!rows.get(rowIndex - 1).contains(good.charAt(i) + "")){ pismeno = good.charAt(i) + ""; break; } } for (int i =0; i < good.length(); i++) { if(!good.contains(orig.get(rowIndex - 1).charAt(i) +"")){ colIndex = i + 1; break; } else { good = good.replace("" + orig.get(rowIndex - 1).charAt(i), ""); } } System.out.println(rowIndex + " " + colIndex + " " + pismeno); } } }