/* * 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. */ package tribune; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import static java.lang.System.in; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; /** * * @author cteam075 */ public class Tribune { public static BufferedReader in; /** * @param args the command line arguments */ public static void main(String[] args) throws IOException { in = new BufferedReader(new InputStreamReader(System.in)); int mapSize = 0; String row; List tribune = new ArrayList<>(); Map tribuneCounts = new HashMap<>(); while ((row = in.readLine()) != null) { mapSize = Integer.parseInt(row); for(int i = 0; i < mapSize; i++) { tribune.add(in.readLine()); } for(String str: tribune) { for(int j = 0; j < str.length(); j++) { if(!tribuneCounts.containsKey(str.substring(j, j+1))) { tribuneCounts.put(str.substring(j, j+1), 1); } else { tribuneCounts.put(str.substring(j, j+1), tribuneCounts.get(str.substring(j, j+1)) + 1); } } } String character = null; for(Map.Entry entry : tribuneCounts.entrySet()) { if(entry.getValue() == mapSize - 1) { character = entry.getKey(); break; } } int resRow = 0; for(int i = 0; i < tribune.size(); i++) { if(!tribune.get(i).contains("" + character.charAt(0))) { resRow = i+1; break; } } int resColumn = 0; for(int i = 0; i < mapSize; i++){ boolean flag = false; for(int j = 0; j < mapSize; j++){ char c = tribune.get(i).charAt(j); if(String.valueOf(c).compareTo(character)==0){ flag = true; } } if(flag == false){ resColumn = i; break; } } System.out.println(resRow + " " + resColumn + " " + character); tribune.clear(); tribuneCounts.clear(); } } }