1024 : The Smallest Floor Tile

时间限制Time Limit 1 Sec 内存限制Memory Limit 128 MB 提交次数Submitted 1 Times 通过次数Solved 1 Times 标准评测Standard Judge

题目描述Description

Xiao Ming saw a wide variety of patterns in a floor shop.

He wants to know how every floor can be paved with the smallest floor tiles.

输入格式Input

There are no more than 20 test cases.

The first line of each case contains two integer numbers n and m, indicating the length and width of the floor.

Then n lines, each line contains exactly m letters indicating the patterns.

1 <= n <= 500, 1 <= m <= 500, all the patterns are uppercase letters as A~Z.

输出格式Output

For each case, output two integer numbers indicating the size of the smallest tile that could make up this floor.

样例Sample

提示Hint

For example

ABABAB
CDCDCD
ABABAB
CDCDCD

The smallest tile is

AB
CD

出题Author

CSGrandeur