Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

func main() {
	io := NewIo()
	defer io.Flush()
	for {
		M, T, P, R := io.NextInt(), io.NextInt(), io.NextInt(), io.NextInt()
		if M == 0 {
			break
		}
		score := make([]struct{ num, time, index int }, T)
		submit := make([][]int, T)
		for i := 0; i < T; i++ {
			score[i].index = i + 1
			submit[i] = make([]int, P)
		}

		for i := 0; i < R; i++ {
			m, t, p, j := io.NextInt(), io.NextInt()-1, io.NextInt()-1, io.NextInt()
			if j == 0 {
				score[t].num++
				score[t].time += submit[t][p]*20 + m
			} else {
				submit[t][p]++
			}
		}
		sort.SliceStable(score, func(i, j int) bool {
			return score[i].num < score[j].num || score[i].num == score[j].num && score[i].time > score[j].time
		})

		for i := T - 1; i > 0; i-- {
			io.Printf("%d", score[i].index)
			if score[i].num == score[i-1].num && score[i].time == score[i-1].time {
				io.Printf("=")
			} else {
				io.Printf(",")
			}
		}
		io.Println(score[0].index)
	}
}

// I/O template
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buff []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buff = append(buff, line...)
		if !isPrefix {
			break
		}
	}
	return string(buff)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	s := io.tokens[io.nextToken]
	io.nextToken++
	return s
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntSlice(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func (io *Io) PrintStringSlice(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func Log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}

func ExampleIo() {
	io := NewIo()
	defer io.Flush()
	a := make([]int, 0, 3)
	a[0], a[1], a[2] = io.NextInt(), io.NextInt(), io.NextInt()
	io.Println(a)
	io.PrintIntSlice(a)
	Log("io", a)
}

C++: #include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;
#define ll long long
#define pb push_back

int main()
{
    int m, t, p, r;
    vector<string> x;
    while (1)
    {
        cin >> m >> t >> p >> r;
        if (m == 0)
        {
            break;
        }
        vector<pair<pair<int, int>, int> >team(t); // 得点：時間: チーム番号: <ペナルティ番号,ペナルティ数>
        vector<vector<int> > wrong(t,vector<int>(p,0)); // チーム番号：間違えた問題番号
        int m1, t1, p1, j1;
        //チーム番号を入れていく
        for (int i = 0; i < team.size(); i++)
        {
            team[i].second = i + 1;
        }

        for (int k = 0; k < r; k++)
        { // 提出回数だけ繰り返す
            cin >> m1 >> t1 >> p1 >> j1;
            if (j1 == 0)
            {
                team[t1 - 1].first.second = team[t1 - 1].first.second - m1 - wrong[t1-1][p1-1] * 20; // 時間を代入
                team[t1 - 1].first.first += 100;
            }
            else
            { //　不正解だった場合
                wrong[t1-1][p1-1]++;
            }
        }
        sort(team.begin(), team.end());
        string x_chi = "";
        char numStr[512];
        string formatStr;
        //debugよう
        for (int i = team.size() - 1; i > 0; i--)
        {
            if (team[i].first.first == team[i - 1].first.first)
            {
                if (team[i].first.second == team[i - 1].first.second)
                {
                    sprintf(numStr, "%d=", team[i].second);
                }
                else
                {
                    sprintf(numStr, "%d,", team[i].second);
                }
            }
            else
            {
                sprintf(numStr, "%d,", team[i].second);
            }
            formatStr += numStr;
            // cout << team[i].second << ": " << team[i].first.first << " " << team[i].first.second << endl; // 0に得点：i+1番のペナルティ
        }
        // 最後の一つを追加
        // cout << team[0].second << ": " << team[0].first.first << " " << team[0].first.second << endl; // 0に得点：i+1番のペナルティ
        sprintf(numStr, "%d", team[0].second);
        formatStr += numStr;
        x.push_back(formatStr);
    }
    for (int i = 0; i < x.size(); i++)
    {
        cout << x[i] << endl;
    }
}

C++: #include<iostream>
#include<strstream>
#include<stack>
#include<utility>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cmath>
#include<climits>
#include<map>
#include<string>
#include<sstream>

using namespace std;

#define mp make_pair
#define rep(i,n) for( int i = 0; i < n; i++ )
typedef long long int ll;

int main()
{
	int n;
	while( cin >> n, n )
	{
		vector<int> v(n);
		rep(i,n)
		{
			cin >> v[i];
		}
		string s;
		cin >> s;

		int v_i = 0;
		for( int i = 0; i < s.size(); i++)
		{
			if( v_i > n-1 ){
				v_i = 0;
			}
			rep(j,v[v_i])
			{
				s[i]--;
				if( s[i] == 64 ){
					s[i] = 'z';
				}
				if( s[i] == 96 ){
					s[i] = 'Z';
				}
			}
			v_i++;
		}
		cout << s << endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1 ; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1 ; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9+100;
const bool debug = 0;
/***************************************/

int M, T, P, R; // M:コンテスト時間, T:チーム数, P:問題数, R:提出数

int main() {
	while (cin >> M >> T >> P >> R, M || T || P || R) {
		
		int wacnt[50][2000] = {};
		int score[50] = {};
		REP(i, R) {
			// m:経過時間, t:チーム番号, p:問題番号, j:ジャッジ結果(0:AC,otherwise:WA)
			int m, t, p, jud;
			scanf("%d %d %d %d", &m, &t, &p, &jud);
			t--; p--;
			
			if (jud == 0) {
				score[t] -= m + wacnt[t][p] * 20;
				score[t] += 100000000;
			}
			else wacnt[t][p]++;
		}
		
		vector<pii> ans;
		REP(i, T) ans.push_back(pii(score[i], i));
		sort(ALL(ans), greater<pii>());
		
		if (debug) putchar('@');
		
		REP(i, ans.size()) {
			if (i > 0 && ans[i - 1].fi == ans[i].fi) putchar('=');
			else if (i > 0) putchar(',');
			printf("%d", ans[i].se + 1);
		}
			
		puts("");
	}
	
	return 0;
}