Czech ACM Student Chapter

Czech Technical University in Prague

Charles University in Prague

Technical University of Ostrava

ˇ a

Slovak University of Technology

Pavol Jozef Saf´rik University in Koˇice

s

ˇ

University of Zilina

Masaryk University

Matej Bel University in Bansk´ Bystrica

a

University of West Bohemia

CTU Open Contest 2016

Colorful Tribune

tribune.c, tribune.cpp, tribune.c11, Tribune.java, tribune.py

You are visiting your friends on a summer holiday sports camp. When you arrive there is a

volleyball tournament going on. Various clubs from the villages in the camp neighborhood are

taking part in the tournament. Each club is recognized by a color which is different from the

colors of all other clubs and also the fans of each particular club are wearing t-shirts with the

color of their club.

Amazingly, the tribune on which the fans are sitting is suited very well for the tournament: The

number of seat rows and also the number of seat columns (perpendicular to the seat rows) is

equal to the number of the clubs participating in the tournament. Moreover, quite unbelievably,

the number of fans of each club is also equal to the number of clubs.

The last game of the tournament is to begin shortly. To make the display on the tribune more

attractive, the fans decided to arrange themselves in such way that each fan will occupy exactly

one seat and each row and each column will be occupied by fans of all clubs. After some scramble,

they manage to achieve this configuration and the game is about to start. Suddenly, someone

in the crowd around you points to the tribune and shouts "Hey, John is not wearing his club's

color!". You do not know who John is and therefore you do not know where is he sitting or

what color he should be wearing. Nevertheless, if John is the only person on the tribune who

failed to be dressed in proper color then it is possible, just by careful observation of the tribune,

to find him and determine the color of his club.

Input Specification

In this problem, we denote the colors of the clubs by capital letters "A", "B", ..., "Z". There are

more test cases. Each case starts with a line containing one integer N (3 ≤ N ≤ 26) which is the

number of teams taking part in the tournament. Next, there are N lines describing the colors

worn by the fans on the tribune. Each line corresponds to one row of sets and it contains one

string of length N . Each character in the string represents the color which the corresponding

fan is wearing. The order of seats on the tribune is the same as the order of characters in the

input.

Output Specification

For each test case, print a single line with two integers R, C , and a character V . The values

of R and C specify the row and the column on the tribune where John is sitting and the letter

V specifies the color of his club. Rows and columns are numbered 1, 2, . . . , N . The successive

values on the output line should be separated by one space.

Sample Input

6

OEYCDK

EYOKCD

KDCEOY

CKHOYE

YOEDKC

DCKYEO

3

IWL

GIW

WLI

Output for Sample Input

43D

21L