#include<iostream> #include<cstdio> using namespace std; int main() { int n, m, number, min_num; int rank[4]; while (scanf("%d %d\n", &n, &m) != EOF) { float countries_inf[3][n]; for (int i = 0; i < n; ++i) { scanf("%d %d %d\n", &countries_inf[0][i], &countries_inf[1][i], &countries_inf[2][i]); } float rank_inf[4][m]; for (int i = 0; i < m; ++i) { scanf("%d ", &number); rank_inf[0][i] = countries_inf[0][number]; rank_inf[1][i] = countries_inf[1][number]; rank_inf[2][i] = countries_inf[0][number] ? countries_inf[0][number] / countries_inf[2][number] : 0; rank_inf[3][i] = countries_inf[1][number] ? countries_inf[1][number] / countries_inf[2][number] : 0; } for (int i = 0; i < m; ++i) { for (int i = 0; i < 4; ++i) { rank[i] = 1; } for (int j = 0; j < 4; ++j) { for (int k = 0; k < m; ++k) { if (rank_inf[j][i] < rank_inf[j][k]) { ++rank[j]; } } } min_num = 0; for (int i = 1; i < 4; ++i) { if (rank[i] < rank[min_num]) { min_num = i; } } cout << rank[min_num] << ":" << min_num + 1 << endl; } cout << endl; } return 0; }