아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Basic Math

시간 제한5초메모리 제한1024 MB

요약
주어진 n개의 수 쌍마다 덧셈, 뺄셈, 곱셈 중 하나를 골라 n개의 결과값이 모두 서로 다르게 만들거나 불가능함을 판정한다.
난이도

보통10점 중 7점

유형
그래프, DFS, 백트래킹, 해시맵
정답자
아직 제출이 없습니다

문제

Example exam by Ellen.

Ellen is teaching elementary math to her students and the time for the final exam has come. The exam consists of nn questions. In each question, the students have to add ('+'), subtract ('-') or multiply ('*') a pair of numbers.

Ellen has already chosen the nn pairs of numbers. All that remains is to decide for each pair which of the three possible operations the students should perform. To avoid students getting bored, Ellen wants to make sure that the nn correct answers to her exam are all different.

Please help Ellen finish constructing the exam by automating this task.

입력

The input consists of:

  • One line with an integer nn (1≤n≤2,5001\leq n \leq 2\\,500), the number of pairs of numbers.
  • nn lines with two integers aa and bb (∣a∣,∣b∣≤106\left|a\right|, \left|b\right| \leq 10^6), a pair of numbers used.

출력

If there is no way to construct the exam such that the nn correct answers are all different, output "impossible".

Else, for each pair of numbers (a,b)(a,b) in the same order as in the input, output a valid equation. Each equation should consist of five parts: aa, one of the three operators, bb, an equals sign ('='), and the result of the expression. All the nn expression results must be different.

If there are multiple valid solutions, you may output any one of them.

예제2

  1. 예제 1

    입력
    4
    1 5
    3 3
    4 5
    -1 -6
    
    예상 출력
    1 + 5 = 6
    3 * 3 = 9
    4 - 5 = -1
    -1 - -6 = 5
    
  2. 예제 2

    입력
    4
    -4 2
    -4 2
    -4 2
    -4 2
    
    예상 출력
    impossible