import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.HashMap; import java.util.Map; public class Tribune { public static BufferedReader in; static char missing; static char more; static int x,y; public static void main(String[] args) { in = new BufferedReader(new InputStreamReader(System.in)); String line; try { while ((line = in.readLine()) != null) { int count = Integer.parseInt(line); Map map = new HashMap<>(); char[] chars = new char[count * count]; for(int i = 0; i< count; i++) { line = in.readLine(); for(int j = 0; j < line.length(); j++) { char ch = line.charAt(j); chars[i * count + j] = ch; map.put(ch, map.containsKey(ch) ? map.get(ch) + 1: 1); } } map.entrySet().forEach(me -> { if(me.getValue() == count - 1) missing = me.getKey(); if(me.getValue() == count + 1 || me.getValue() == 1) more = me.getKey(); }); for(int i = 0; i< count; i++) { // row int moreCount = 0; for(int j = 0; j < line.length(); j++) { if(chars[i * count + j] == more) moreCount++; } if((!(map.get(more) == 1) && moreCount == 2) || (map.get(more) == 1 && moreCount == 1)) x = i; // column moreCount = 0; for(int j = 0; j < line.length(); j++) { if(chars[j * count + i] == more) moreCount++; } if((!(map.get(more) == 1) && moreCount == 2) || (map.get(more) == 1 && moreCount == 1)) y = i; //if(moreCount == 2) } System.out.println((x + 1) + " " + (y + 1) + " " + missing); } } catch (IOException e) { e.printStackTrace(); } } }