import java.util.Comparator;
import java.util.LinkedList;
import java.util.Scanner;

/*
思路:
定义一个Country类:
	其中的部分成员变量:
		二维数组sort[4][2]用于记录排名和排序方式
		两个整数 ,为bestRank,bestSortWay,来记录最佳排名 以及 对应的最佳排名方式
		
步骤:
	1.对sort[4][2]初始化,给第一列排名都初始化为1,并给第二列(即排序方式)分别初始化为1,2,3,4
	2.计算sort[][],例如:对于国家1,遍历其它国家,如果有一个国家的金牌数大于国家1的金牌数目,则国家对应金牌数目的排名+1
	3.通过sort,得到bestRank,bestSortWay,并输出

注意:
	输入数据中,有人口数为0,奖牌数为0的情况,要考虑此这些情况下的金牌人口比例与奖牌人口比例

 */
public class Main {
	public static void main(String[] args) {
		LinkedList<Country> list=new LinkedList<>();
		Scanner sc=new Scanner(System.in);
		while(sc.hasNext()) {
			int n=sc.nextInt();
			int m=sc.nextInt();
			for(int i=0;i<n;i++) {
				Country country=new Country(sc.nextInt(),sc.nextInt(),sc.nextInt());
				list.add(country);
			}
			
			int[] printId=new int[m];
			for(int i=0;i<m;i++) {
				printId[i]=sc.nextInt();
			}
			//将每一组输入结果传入resolution
			resolution(list,printId);
			list.clear();


	}
		sc.close();
}
	
private static void resolution(LinkedList<Country> list, int[] printId) {
	//给国家的sort[][]二维数组初始化,sort的第一列是排名,均初始化为1,第二列是排序方式,初始化为1,2,3,4
	for(Country e:list) {
		initializeSort(e);
	}
	
	//计算sort[][]数组第一列,即计算不同排序方式下的最佳排名
	list=rank(list);
	
	//获得最佳结果,放入country的成员变量bestRank,bestSortWay中,并输出
	for(int j=0;j<printId.length;j++) {
		int index=printId[j];
		Country current=list.get(index);
		getBestRank(current);//获得最佳结果
		System.out.println(current.bestRank+":"+current.bestSortWay);
	}
	System.out.println();
	
}

private static void getBestRank(Country current) {
	int[][] A=current.sort;
	int indexRank=100;
	int indexSort=100;
	for(int i=0;i<4;i++) {
		if(A[i][0]<indexRank) {
			indexRank=A[i][0];
			indexSort=A[i][1];	
		}	
	}
	current.bestRank=indexRank;
	current.bestSortWay=indexSort;
}

private static LinkedList<Country> rank(LinkedList<Country> list) {
	int n=list.size();
	
	for(int i=0;i<n;i++) {
		Country current=list.get(i);
		for(Country e:list) {
			if(e.gold>current.gold) {
				current.sort[0][0]++;
			}
			if(e.total>current.total) {
				current.sort[1][0]++;
			}
			if(e.gp>current.gp) {
				current.sort[2][0]++;
			}
			if(e.tp>current.tp) {
				current.sort[3][0]++;
			}
		}
	}
	return list;
}

private static void initializeSort(Country country) {
	country.sort=new int[4][2];
		for(int i=0;i<4;i++) {
			country.sort[i][0]=1;
			country.sort[i][1]=i+1;
		}
		
	}

static class Country{
		int gold;
		int total;
		double population;
		double tp;// 奖牌人口比例
		double gp;// 金牌人口比例
		int bestRank;
		int bestSortWay;
		int[][] sort;
		
		public Country( int gold, int total, int population) {	
			this.gold = gold;
			this.total = total;
			this.population = population;
			//在建立对象时,顺便给tp,gp赋值,要考虑人口为0,奖牌数目为0的情况
			if(population==0) {
				tp=Double.MAX_VALUE;
				gp=Double.MAX_VALUE;
			}else {
				tp=(double)total/(double)population;
				gp=(double)gold/(double)population;
			}
			
			if(gold==0) {
				gp=0;
			}
			if(total==0) {
				tp=0;
			}
			
		}

		
	}


}