// Deze method checkt rooster conflicten (Dubbele roosteringen van studenten)
  public int computeStudentConflicts() {
    ArrayList<Student> checkedStudentsList = new ArrayList<Student>();
    int studentConflictCounter = 0;
    boolean conflictFound = false;

    for (int i = 0; i < timeslots; i++) {
      for (int j = 0; j < rooms.size() - 1; j++) {
        Activity activity = rooms.get(j).timetable.get(i);
        if (activity != null) {
          for (Student student : activity.studentGroup) {
            if (!checkedStudentsList.contains(student)) {
              for (int k = j + 1; k < rooms.size(); k++) {
                Room otherRoom = rooms.get(k);
                Activity otherActivity = otherRoom.timetable.get(i);
                if (otherActivity != null) {
                  if (otherActivity.studentGroup.contains(student)) {
                    studentConflictCounter++;
                    conflictFound = true;
                  }
                }
              }
            }
            if (conflictFound) {
              checkedStudentsList.add(student);
              conflictFound = false;
            }
          }
        }
      }
      checkedStudentsList.clear();
    }
    return studentConflictCounter;
  }
  public static void main(String[] args) {

    Locale.setDefault(Locale.ROOT);

    Scanner scanner = new Scanner(System.in);
    TreeMap<String, Map<String, ArrayList<Integer>>> map = new TreeMap<>();
    int n = Integer.parseInt(scanner.nextLine());
    for (int i = 0; i < n; i++) {
      String[] line = scanner.nextLine().split("\\s+");
      String fullName = line[0] + " " + line[1];
      String subject = line[2];
      int score = Integer.parseInt(line[3]);

      if (map.containsKey(fullName)) {
        if (map.get(fullName).containsKey(subject)) {
          map.get(fullName).get(subject).add(score);
        } else {
          ArrayList<Integer> list = new ArrayList<>();
          list.add(score);
          map.get(fullName).put(subject, list);
        }
      } else {
        ArrayList<Integer> list = new ArrayList<>();
        list.add(score);
        Map<String, ArrayList<Integer>> innerMap = new TreeMap<>();
        innerMap.put(subject, list);
        map.put(fullName, innerMap);
      }
    }

    for (String name : map.keySet()) {
      String print = name + ": [";
      for (Map.Entry<String, ArrayList<Integer>> innerMap : map.get(name).entrySet()) {
        double average = getAverage(innerMap.getValue());
        print += String.format("%s - %.2f, ", innerMap.getKey(), average);
      }
      String finalPrint = "";
      for (int i = 0; i < print.length() - 2; i++) {
        finalPrint += print.charAt(i);
      }
      finalPrint += "]";
      System.out.println(finalPrint);
    }
  }