This page is still under construction.

Parts of this page are still being built. What you see may change.

Alpha Puzzle

Interview

Time limit2sMemory limit512 MB

Summary
Assign numbers 1 to 26 to letters by scanning the grid and numbering each letter at its first appearance.
Level

Easy2 of 10

Topics
Simulation, String, Implementation
Solved
No attempts yet

Problem

An alpha puzzle is a crossword variant in which every letter square (that is, every square that is not black) holds a number instead of a letter. The same letter is always represented by the same number across the whole puzzle, and all 26 letters of the alphabet are used, so the numbers run from 1 to 26.

You are given a solved alpha puzzle and have to work out which number belongs to which letter. Some alpha puzzles assign the numbers at random, but the one printed every day in the New Zealand Herald uses a fixed method, and that method is the one to implement here.

Read the answer grid left to right, top to bottom, and skip the spaces that stand for black squares. The first letter you meet is assigned the number 1, the next letter that has not appeared yet is assigned 2, and so on. Only the first occurrence of a letter is processed, so exactly 26 numbers are handed out.

Input

The first line contains one integer SS, the size of the puzzle, which is both the number of rows and the number of columns (10≤S≤2010 \le S \le 20).

Each of the next SS lines holds one row of the grid and consists of upper case letters and spaces. Trailing spaces in a row may have been removed, so a line can be shorter than SS characters or even empty. Every letter of the alphabet appears at least once in the grid.

Output

Print the 26 letters of the alphabet on one line, in the order of the numbers assigned to them. The first letter printed is the one assigned 1 and the last is the one assigned 26.

Examples3

  1. Example 1

    Input
    13
    CITADEL POPPY
    H O O U A L I
    ARROW MASSAGE
    S S N B S C L
    SHOULDER BARD
    I   O R T T
    SQUEAL FRIEZE
      N D A O   X
    FILE CLAPTRAP
    E U J T I A L
    VACCINE CARGO
    E K V R A E D
    RHYME SPLURGE
    
    Expected output
    CITADELPOYHURWMSGNBQFZXJVK
    
  2. Example 2

    Input
    10
     A  ABB AB
     CD DACCE
    F  GH    D
     H G E  I
     C   CD  C
    J   A JK L
    MD JBN OP
     Q J RS T
    UALEPVEFJT
      WR XYPNZ
    
    Expected output
    ABCDEFGHIJKLMNOPQRSTUVWXYZ
    
  3. Example 3

    Input
    10
    ABCDEFGHIJ
    KLMNOPQRST
    
    UVWXYZ
    
    AAAA BBBB
    ZZZZZZZZZZ
    MNOP QRST
    
    XYZ
    
    Expected output
    ABCDEFGHIJKLMNOPQRSTUVWXYZ