#include <iostream>
#include <vector>
#include<algorithm>
#include<cmath>
using namespace std;
struct country {
int id;
float gold, medal;
float goldhum_por, medalhum_por;
float scores[5];
};
int c;
bool comparen(country& a, country& b) {
return a.scores[c] > b.scores[c];
}
int main() {
int n, m;
while (cin >> n >> m) {
vector<country>countrys(n);
vector<vector<int>>countrys_ranks(n);
for (int i = 0; i < n; i++) {
float gold, medal, nums;
cin >> gold >> medal >> nums;
countrys[i].scores[1] = gold;
countrys[i].scores[2] = medal;
countrys[i].scores[3] = gold / nums;
countrys[i].scores[4] = medal / nums;
countrys[i].id = i;
}
for (c = 1; c < 5; c++) {
sort(countrys.begin(), countrys.end(), comparen);
int j = 1;
float temp = countrys[0].scores[c];;
for (int i = 0; i < n; i++) {
if (countrys[i].scores[c] == temp) {
countrys_ranks[countrys[i].id].push_back(j);
} else {
countrys_ranks[countrys[i].id].push_back(i + 1);
j = i + 1;
temp = countrys[i].scores[c];
}
}
}
vector<int>participant(n, 0);
while (m--) {
int p;
cin >> p;
participant[p] = 1;
}
int j = 0;
for (auto& it : countrys_ranks) {
int ix = 99, mind = 99;
for (int i = 0; i < 4; i++) {
if (it[i] < mind) {
ix = i;
mind = it[i];
}
}
if (participant[j]) {
cout << mind << ":" << ix + 1 << endl;
}
j++;
}
cout << endl;
}
}