import java.util.Scanner;

public class Section053 {
	static class member {
		String ban;
		int bunho, wgt;
	}
	public static void main(String[] args) {
		Scanner scanf = new Scanner(System.in);
		member data[] = new member[100]; 
		for (int i = 0; i < data.length; i++)
			data[i] = new member();
		int flag, a = 0, b = 0, i, k;
		String c = "0반";
		System.out.printf("반 번호 무게를 입력하세요.\n모두 입력하셨으면 '0 0 0'을 입력하세요\n");
		flag = 0;
		i = k = -1;
		do {
			k++;
			data[k].ban = scanf.next();
			data[k].bunho = scanf.nextInt();
			data[k].wgt = scanf.nextInt();
		} while (data[k].bunho != 0);
		System.out.printf("반\t번호\t체중\n");
		while (i < k - 1)
		{
			i++;
			if (flag == 0)
			{
				flag = 1;
				a = data[i].wgt;
				b = data[i].wgt;
			}
			else if (a > data[i].wgt)
				a = data[i].wgt;
			else if (b < data[i].wgt)
				b = data[i].wgt;
			if (c.equals(data[i].ban))
			{
				System.out.printf(" \t%d\t%d\n", data[i].bunho, data[i].wgt);
				continue;
			}
			c = data[i].ban;
			System.out.printf("%s\t%d\t%d\n", data[i].ban, data[i].bunho, data[i].wgt);
		}
		System.out.printf("최소 체중:%d\n", a);
		System.out.printf("최대 체중:%d", b);
		scanf.close();
	}
}
