import java.util.*; public final class tribune { public final static void main(String args[]) { try { Scanner s = new Scanner(System.in); while (true) { int lines = s.nextInt(); List fans = new ArrayList<>(); for (int i = 0; i < lines; ++i) { while (!s.hasNext("[a-zA-Z]*")) s.next(); String str = s.next("[a-zA-Z]*"); for (Character c : str.toCharArray()) fans.add(c); } Set row = new HashSet<>(); for (int y = 0; y < lines; ++y) { char c = fans.get(y*lines+0); row.add(c); } boolean found = false; for (int x = 0; x < lines; ++x) { for (int y = 0; y < lines; ++y) { for (int y22 = 0; y22 < lines; ++y22) { if (fans.get(y*lines+x) == fans.get(y22*lines+x) ) { for (y22 = 0; y22 < lines; ++y22) { char c2 = fans.get(y22*lines+x); row.remove(c2); } char expected = row.iterator().next(); System.out.println((y+1) + " " + (x+1) + ' ' + expected ); found = true; break; } } if (!row.contains(fans.get(y*lines+x))) { for (int y2 = 0; y2 < lines; ++y2) { char c2 = fans.get(y2*lines+x); row.remove(c2); } int gotX = x; int gotY = y; char expected = row.iterator().next(); char got = fans.get(y*lines+x); if (x == 1) { row.clear(); for (int yThird = 0; yThird < lines; ++yThird) { row.add(fans.get(yThird*lines+2)); } if (!row.contains(expected)) { for (int yFirst = 0; yFirst < lines; ++yFirst) { if (fans.get(yFirst*lines) == expected) { gotY = yFirst; } } expected = got; gotX = 0; } } System.out.println((gotY+1) + " " + (gotX+1) + ' ' + expected ); found = true; break; } } if (found) break; } } } catch (NoSuchElementException e) { //e.printStackTrace(); return; } catch (Exception e) { //e.printStackTrace(); return; } } }