Under construction

Still being built. Things may change

Elementary Math

Time limit10sMemory limit256 MB

Summary
Assign +, -, or * to each of n given pairs so all results differ, choosing the lexicographically smallest valid assignment.
Level

Medium7 of 10

Topics
Graph, Greedy
Solved
No attempts yet

Problem

Ellen teaches elementary math and the final exam is coming up. The exam has nn questions. In each question a student adds (+), subtracts (-), or multiplies (*) a pair of integers.

Ellen has already picked the nn pairs. What is left is deciding which operation goes with each pair. So the students do not get bored, all nn results must be different.

Help Ellen prepare the exam.

Input

The first line contains the number of pairs nn (1≤n≤25001 \le n \le 2500).

Each of the next nn lines contains the two integers aa and bb of one pair, separated by a space (−106≤a,b≤106-10^6 \le a, b \le 10^6).

Output

If an assignment exists, print nn lines in the same order as the input. Line ii has the form a op b = c, where op is one of +, -, * and c is the result of that operation. Separate the parts with single spaces. The nn results must all be different.

Several assignments can satisfy this, so print exactly one of them. Read the chosen operators in input order as a string and print the assignment whose string is smallest in the order +, -, *. Equivalently, go pair by pair from the first one and use + whenever the remaining pairs can still be given distinct results, otherwise -, otherwise *.

If no assignment makes the nn results different, print impossible.

Examples3

  1. Example 1

    Input
    4
    1 5
    3 3
    4 5
    -1 -6
    
    Expected output
    1 + 5 = 6
    3 - 3 = 0
    4 + 5 = 9
    -1 + -6 = -7
    
  2. Example 2

    Input
    4
    -4 2
    -4 2
    -4 2
    -4 2
    
    Expected output
    impossible
    
  3. Example 3

    Input
    3
    2 2
    2 2
    3 3
    
    Expected output
    2 + 2 = 4
    2 - 2 = 0
    3 + 3 = 6