시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 254 33 28 14.286%

문제

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
W3sicHJvYmxlbV9pZCI6IjMwMzEiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWI5YWNcdWFkZjgiLCJkZXNjcmlwdGlvbiI6IjxwPktcdWI5YWNcdWFkZjhcdWI5N2MgXHVjODhiXHVjNTQ0XHVkN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