loop do
  m, t, pr, r = gets.split.map(&:to_i)
  break if m == 0

  durations = [0] * t
  scores = [0] * t
  penalties = [[]] * t
  r.times do
    inp = gets.split.map(&:to_i)
    te = inp[1] - 1
    pb = inp[2] - 1
    if inp[3] == 0 # ??£?§£
      scores[te] += 1
      durations[te] += inp[0]
      durations[te] += penalties[te][pb] * 20 if penalties[te][pb]
    else # ?????£?§£
      penalties[te][pb] ||= 0
      penalties[te][pb] += 1
    end
  end

  arr = scores.zip(durations).map.with_index { |a, i| [*a, i] }
  sorted = arr.sort do |a, b|
    if b[0] == a[0]
      if b[1] == a[1]
        b[2] - a[2]
      else
        a[1] - b[1]
      end
    else
      b[0] - a[0]
    end
  end

  sorted.each_with_index do |v, i|
    print v[2] + 1
    break if i == sorted.size - 1
    if sorted[i+1][0..1] == v[0..1]
      print "="
    else
      print ","
    end
  end

  print "\n"
end