Problem A. Tetris alphabet

Author:Far-Eastern Subregional
Input file: input.txt   Time limit:1 sec
Output file: output.txt   Memory limit:8 Mb

Statement

The game of Tetris is played with four-connected blocks falling down the well having N rows and 20 columns. Each figure is marked with a unique English letter from 'A' to 'Z'.

Your program must, given the state of the well, determine the order in which the blocks fell down.

Input file format

The first line of input file contains integer N - number of rows. Following N lines contain 20 characters each, with characters that are either a letter from 'A' to 'Z' or the dot character (ASCII 46), representing an empty cell.

Output file format

Output file must contain a string of letters indicating the order in which figures fell down. If there is more than one order, lexicographically smallest one must be printed. Input data will guarantee that at least one nonempty order exists.

Constraints

0 ≤ N ≤ 50

Sample tests

No. Input file (input.txt) Output file (output.txt)
1
6
...........XX.......
..........MMMM......
..........K.........
........KKK.........
.....ZAAA.FFF.......
.....ZZZA..F.B......
BFZAKMX

Problem B. Bipartite graph

Author:StdAlg (adapted by T. Chistyakov, A. Klenin)
Input file: input.txt   Time limit:2 sec
Output file: output.txt   Memory limit:64 Mb

Statement

For a given undirected graph with N vertices and M edges you need to figure out whether the graph is bipartite or no.

NOTE. A graph is called bipartite if it's possible to split its vertices into two non-empty sets so that there is no edges between any two vertices from the same set.

Input file format

Input file contains integers N, M, then M pairs of integers ai bi describing the edges of the graph.

Output file format

Output BIPARTITE if the graph is bipartite or NO if it is not.

Constraints

1 ≤ N ≤ 100000 0 ≤ M ≤ 1000000

Sample tests

No. Input file (input.txt) Output file (output.txt)
1
3 2
1 2  1 3
BIPARTITE
2
4 6
1 2  2 3  3 4  4 1  1 3  2 4
NO

0.024s 0.005s 9