{"scoring":null,"notes":"","legend":"Alice and Bob are playing the next game. Both have same matrix $N \\times M$ filled with\r\ndigits from 0 to 9.\r\n\r\nAlice cuts the matrix vertically, choose order of the columns, then links all the columns to each other to have the cyclic sequence of $N \\times M$ digits. Note that she cannot rotate the columns, i.e. end of some column must be linked to beginning of the other column. Then she cuts a sequence and reads the decimal representation of integer $A$ upside down.\r\n\r\nBob cuts the matrix horizontally, choose order of the rows, then link all the rows to each other to have the cyclic sequence of $N \\times M$ digits. Note that he cannot rotate the rows, i.e. end of some row must be linked to beginning of the other row. Then he cuts a sequence and reads the decimal representation of integer $B$ from left to right.\r\n\r\nPlayer who obtained the biggest integer wins. If both integers are are equal, then game is tied. You are given the matrix, find the number obtained by winner (or by both players in case of tie), if both Alice and Bob are playing optimally.\r\n","authorLogin":"sergm55","language":"english","timeLimit":2000,"output":"Print answer to the problem. Note that number must be printed without leading zeroes. ","inputFile":"stdin","outputFile":"stdout","input":"First line contains integers $N$ and $M$ ($1 \\le M, N \\le 100$). \r\n\r\nEach of next $N$ lines contains string of $M$ digits (without the spaces or other\r\ndelimiters inside) --- the given matrix. You may assuma that atleast one digit in the matrix is not equal to 0.\r\n","authorName":"Mikhaylin Sergey","sampleTests":[{"output":"8722\r\n","input":"2 2\r\n28\r\n27\r\n","inputFile":"example.01","outputFile":"example.01.a"}],"name":"","interaction":null,"memoryLimit":268435456,"tutorial":""}