#C1883. Maximum Unique Rows and Columns

    ID: 45137 Type: Default 1000ms 256MiB

Maximum Unique Rows and Columns

Maximum Unique Rows and Columns

You are given a binary grid of size ( n \times m ) containing only characters '0' and '1'. Your task is to determine the maximum number of unique rows and unique columns that can be obtained by replicating the given rows and columns (i.e. no modifications are allowed). More formally, if ( R ) is the set of distinct rows and ( C ) is the set of distinct columns, then you need to output (|R|) and (|C|) respectively.

For example, consider the grid below:

101
010
100

The distinct rows are "101", "010", and "100" (3 in total), and the distinct columns (when read top to bottom) are "110", "001", and "100" (3 in total). Thus, the output should be: 3 3.

Note: The input is provided via standard input (stdin) and the output should be printed to standard output (stdout).

inputFormat

The first line contains two integers ( n ) and ( m ) separated by a space. The next ( n ) lines each contain a string of length ( m ) consisting only of characters '0' and '1'.

outputFormat

Output two integers separated by a space: the number of unique rows and the number of unique columns.## sample

3 3
101
010
100
3 3