#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
using namespace std;
int maxn = 0x1f1f1f1f;
int minn = 0;
int item[1200];
int fa[1200];
int a[1200];
int b[1200];
int get(char s[])
{
int num = 0;
int len = strlen(s);
for (int i=0; i<len; ++i)
{
num = num * 10 + s[i] - ‘0‘;
}
return num;
}
int main()
{
int t, p;
int ci;
char temp, time[500];
while(~scanf("%d%d", &t, &p))
{
maxn = 0x1f1f1f1f;
minn = 1;
if (t == 0 && p == 0)
break;
memset(item, 0, sizeof(item));
memset(a, 0, sizeof(a));
memset(b, 0, sizeof(b));
memset(fa, 0, sizeof(fa));
for (int i=0; i<t; ++i)
{
for (int j=0; j<p; ++j)
{
scanf("%d", &ci);
getchar();
scanf("%s", time);
if (time[0] == ‘-‘)
continue;
else
{
item[i] += 1;
int sco = get(time);
fa[i] += (sco + (ci - 1) * 20);
a[i] += (ci-1);
b[i] += sco;
}
}
}
for (int i=0; i<t; ++i)
{
if (item[i] == 0) continue;
for (int j=0; j<t; ++j)
{
if (item[j] == 0) continue;
if (item[i] != item[j]) continue;
if (a[i] == a[j]) continue;
double t = (b[i] - b[j]) * 1.0 / (a[j] - a[i]);
int rs, rb;
if (fa[i] > fa[j])
{
rs = j;
rb = i;
}
else if (fa[i] < fa[j])
{
rs = i;
rb = j;
}
else if (fa[i] == fa[j])
{
minn = maxn = 20;
continue;
}
if (a[rs] > a[rb])
{
if (t<maxn)
{
if (t == int(t))
maxn = t - 1;
else maxn = int(t);
}
}
else if (a[rs] < a[rb])
{
minn = int (t + 1);
}
}
}
printf("%d ", minn);
if (maxn == 0x1f1f1f1f)
{
printf("*\n");
}
else printf("%d\n", maxn);
}
return 0;
}