#include<bits/stdc++.h>
using namespace std;
const int MAXN=100100;
struct Node{
int id;
int score[6];
int total;
int rank;
int cnt;
Node(){
id=0;
fill(score,score+6,-2);
rank=0;
total=0;
cnt=0;
}
}node[MAXN];
bool cmp(Node a,Node b){
if(a.total!=b.total) return a.total>b.total;
else if(a.cnt!=b.cnt) return a.cnt>b.cnt;
else if(a.id!=b.id) return a.id<b.id;
}
int main()
{
#ifndef ONLINE_JUDGE
freopen("in.txt","r",stdin);
#endif
int n,k,m;
cin>>n>>k>>m;
int mark[6]={};
for(int i=1;i<=k;i++){
cin>>mark[i];
}
for(int i=0;i<m;i++){
int idd,proid,scoree;
cin>>idd>>proid>>scoree;
node[idd].id=idd;
if(node[idd].score[proid]<scoree){
node[idd].score[proid]=scoree;
}
}
for(int i=1;i<=n;i++){
int cnt=0;
for(int j=1;j<=k;j++){
if(node[i].score[j]>=0&&node[i].score[j]<=mark[j]){
node[i].total+=node[i].score[j];
}
if(node[i].score[j]==mark[j]){
cnt++;
}
}
node[i].cnt=cnt;
}
sort(node+1,node+n+1,cmp);
node[1].rank=1;
for(int i=2;i<=n;i++){
if(node[i].total==node[i-1].total){
node[i].rank=node[i-1].rank;
}else{
node[i].rank=i;
}
}
for(int i=1;i<=n;i++){
if(node[i].total>0){
printf("%d %05d %d",node[i].rank,node[i].id,node[i].total);
for(int j=1;j<=k;j++){
if(node[i].score[j]==-2){
cout<<" -";
}else if(node[i].score[j]==-1){
cout<<' '<<0;
}else{
cout<<' '<<node[i].score[j];
}
}
cout<<endl;
}
}
return 0;
}
19分飘过,唉,两个测试点找不出来,待解决