#include <iostream>
#include <string>
#include <cmath>
using namespace std;

#define in cin
#define out cout
//#include <fstream>
//ifstream in("3935.txt");
//ofstream out("3935_.txt");

struct equipo {
    int resueltos, pje, tiempo, faltas;
};

void quicksort(equipo a[], int izq, int der) {
    int i=izq, j=der;
    equipo x=a[(izq+der)/2], h;

    while (i<=j) {
        while (a[i].resueltos < x.resueltos || a[i].resueltos == x.resueltos && a[i].pje > x.pje) i++;
        while (a[j].resueltos > x.resueltos || a[j].resueltos == x.resueltos && a[j].pje < x.pje) j--;
        if (i<=j) {
            h=a[i]; a[i]=a[j]; a[j]=h;
            i++; j--;
        }
    }

    if (izq<j) quicksort(a, izq, j);
    if (i<der) quicksort(a, i, der);
}

inline void comparar(equipo equipos[], int i, double& min, double& max) {
    double difFaltas = equipos[i].faltas - equipos[i+1].faltas;
    if (difFaltas != 0)
        if (equipos[i].pje == equipos[i+1].pje) {
            if (equipos[i].tiempo != equipos[i+1].tiempo)
                max = min = 20;
        } else {
            double valor = (equipos[i+1].tiempo - equipos[i].tiempo) / difFaltas;
            if (difFaltas < 0) {
                if (max > ceil(fabs(valor)) - 1)
                    max = ceil(fabs(valor)) - 1;
            } else if (valor > 0) {
                if (min < floor(valor) + 1)
                    min = floor(valor) + 1;
            }
        }
}

inline void resolver(equipo equipos[], int E) {
    double min = 1, max = 999999;
    quicksort(equipos, 0, E-1);
    for (int i = 0; i < E-1 && min < max; i++)
        if (equipos[i].resueltos > 0 && equipos[i].resueltos == equipos[i+1].resueltos)
            comparar(equipos, i, min, max);
    if (max == 999999)
        out << min << " *" << endl;
    else
        out << min << " " << max << endl;
}

int main() {
    int E, P;
    equipo eq;

    int intentos, tiempo;
    char barra;
    string tiemp;

    while (in >> E >> P && E != 0) {
        equipo equipos[E];
        for (int i = 0; i < E; i++) {
            eq.resueltos = eq.pje = eq.tiempo = eq.faltas = 0;
            for (int j = 0; j < P; j++) {
                in >> intentos >> barra >> tiemp;
                if (tiemp != "-") {
                    tiempo = atoi(tiemp.c_str());
                    eq.resueltos++;
                    eq.pje += tiempo + (intentos-1) * 20;
                    eq.tiempo += tiempo;
                    eq.faltas += intentos-1;
                }
            }
            equipos[i] = eq;
        }
        resolver(equipos, E);
    }
    return 0;
}

