시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 133 22 19 16.667%

문제

K리그를 좋아하는 상근이는 요즘 들떠있다. 바로 K리그 클래식과 챌린지를 TV에서 중계해주기 때문이다. 어느날 전반전이 끝나고 TV광고를 보는 동안 순위표를 이용한 수학 게임을 생각했다.

순위표는 각 팀의 정보 다섯 개를 가지고 있다. 팀의 정보는 팀의 경기 수, 이기고 지고 비긴 경기의 수, 얻은 승점으로 총 다섯 가지이다. 경기에서 이겼을 경우에는 승점 3점을 가져가고, 비겼을 경우에는 1점을 가져간다.

상근이는 순위표의 일부 숫자가 없다고 하더라도, 다른 정보를 통해서 유추할 수 있다는 사실을 알아냈다.

일부 숫자가 지워진 순위표가 주어졌을 때, 지워진 숫자를 알아내는 프로그램을 작성하시오.

각 팀의 정보는 서로 연관이 없다. 예를 들어, 실제 경기에서는 일어나지 않겠지만, 모든 팀이 모든 게임을 이겼을 수도 있다.

각 팀은 최대 100경기를 소화했다.

입력

첫째 줄에 팀의 수 N이 주어진다. (1 ≤ N ≤ 1000)

다음 N개 줄에는 각 팀의 정보 다섯 개가 공백으로 구분되어져서 주어진다. 정보는 정수 또는 물음표이며, 물음표인 경우에는 그 정보의 값을 알 수 없는 경우이다.

항상 빈 칸을 채우는 방법의 수가 유일한 경우만 입력으로 주어진다.

출력

지워진 칸을 채운 순위표를 출력한다.

예제 입력 1

5
27 21 3 3 66
27 18 6 3 ?
? 15 5 7 50
? 14 7 5 ?
? 14 ? 8 47

예제 출력 1

27 21 3 3 66
27 18 6 3 60
27 15 5 7 50
26 14 7 5 49
27 14 5 8 47
W3sicHJvYmxlbV9pZCI6IjMwMzEiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWI5YWNcdWFkZjgiLCJkZXNjcmlwdGlvbiI6IjxwPktcdWI5YWNcdWFkZjhcdWI5N2MgXHVjODhiXHVjNTQ0XHVkNTU4XHViMjk0IFx1YzBjMVx1YWRmY1x1Yzc3NFx1YjI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