#!/bin/python3

import math
import os
import random
import re
import sys
from itertools import combinations

# Complete the acmTeam function below.
def acmTeam(topics):
    n = len(topics)
    m = len(topics[0])    
    score = []    
    for i in range(0, n):
        topic = topics[i]
        ans = []
        for j in range(m):
            if topic[j] == '1':
                ans.append(j)
        score.append(ans)
    ans = []
    for perm in combinations(range(n), 2):
        i = perm[0]
        j = perm[1]
        a = set(score[i])
        b = set(score[j])

        ans.append(len(a.union(b)))
    m = max(ans)
    print(ans)
    c = 0
    for i in ans:
        if i == m:
            c += 1
    return [m, c]

if __name__ == '__main__':
    fptr = open(os.environ['OUTPUT_PATH'], 'w')

    nm = input().split()

    n = int(nm[0])

    m = int(nm[1])

    topic = []

    for _ in range(n):
        topic_item = input()
        topic.append(topic_item)

    result = acmTeam(topic)

    fptr.write('\n'.join(map(str, result)))
    fptr.write('\n')

    fptr.close()
