#include <bits/stdc++.h>
using namespace std;

int main(){
	int M,T,P,R;
	while(cin>>M>>T>>P>>R,M){
		pair<int, int> team[60];
		int wa[60][20] = {};
		for(int i = 0;i < T;i++){
			team[i].first = team[i].second = 0;
		}
		for(int r = 0;r < R;r++){
			int m,t,p,j;
			cin>>m>>t>>p>>j;
			t--;
			if(j == 0){
				team[t].first++;
				team[t].second -= m + wa[t][p] * 20;
			}
			else{
				wa[t][p]++;
			}
		}
		int idx[60];
		for(int i = 0;i < 60;i++)idx[i] = i;

		for(int i = 0;i < T;i++){
			for(int j = i+1;j < T;j++){
				if(team[i] == team[j] ? idx[i] < idx[j] : team[i] < team[j]){
					swap(team[i],team[j]);
					swap(idx[i],idx[j]);
				}
			}
		}
		cout<<idx[0]+1;
		for(int i = 1;i < T;i++){
			if(team[i] == team[i-1]){
				cout<<"=";
			}
			else cout<<",";
			cout<<idx[i]+1;
		}
		cout<<endl;
	}

}