grading = {
# A, AB, B, BC, C, CD, D
"A":10,
"AB":9,
"B":8,
"BC":7,
"C":6,
"CD":5,
"D":4
}
courses_arr = []
grades_arr = []
students = { }
std_avg = {
}
inpt = input().split("~")
if inpt == ["Courses"]:
while True:
inpt = input().split("~")
if inpt == ["Students"]:
break
course = { }
course["Course Code"] = inpt[0]
course["Course Name"] = inpt[1]
course["Semester"] = inpt[2]
course["Year"] = inpt[3]
course["Instructor"] = inpt[4]
courses_arr.append(course)
if inpt == ["Students"]:
while True:
inpt = input().split("~")
if inpt == ["Grades"]:
break
students[inpt[0]] = inpt[1]
if inpt == ["Grades"]:
# Course Code~Semester~Year~Roll Number~Grade
while True:
inpt = input().split("~")
if inpt == ["EndOfInput"]:
break
grades = { }
inpt = input().split("~")
grades["Course Code"] = inpt[0]
grades["Semester"] = inpt[1]
grades["Year"] = inpt[2]
grades["Roll Number"] = inpt[3]
grades["Grade"] = grading[inpt[4]]
grades_arr.append(grades)
for i in grades_arr:
roll = i["Roll Number"]
grade = i["Grade"]
if roll in std_avg:
std_avg[roll][1] += grade
std_avg[roll][2] += 1
else:
std_avg[roll] = [students[roll],grade,1]
arr = []
for i,k in std_avg.items():
arr.append([i,k[0],round(k[1]/k[2],2)])
arr.sort()
for i in arr:
print(i[0]+"~"+i[1]+"~"+str(i[2]))