Under construction

Still being built. Things may change

Fair Play

Interview

Time limit2sMemory limit1024 MB

Summary
Given n people each with billiards and pool skill values, decide whether they can be split into pairs so every pair has identical total skill in both categories.
Level

Medium5 of 10

Topics
Hash map, Sorting, Array, Math
Solved
No attempts yet

Problem

Together with your coworker Larry, you are organizing the Billiards and Pool Competition for your coworkers at your small company. You and Larry usually agree, and he will surely approve of your latest idea. You even bought a nice prize for your coworkers to win, and you hope they are as excited as you are. You want to maximize the fun.

So it would be good to avoid complete walkovers: those are no fun for either player. After some thought, you decide it is a good idea to suggest to Larry that the players be divided into teams of two. That way, you can compensate for a player's strength by pairing them with a weaker player. In fact, it would be perfect if every team had exactly the same strength! Before telling Larry your plans, you decide to first figure out whether this is possible.

In your model, synergy plays a negligible role in determining team strength, and the strength of a team is determined only by the strength of its individual members. Every coworker has a certain skill level in both billiards and pool, given by two integers. When two coworkers team up, their total skill is the sum of their individual skills. Can you divide all coworkers into teams of two such that every team has exactly the same skill in both billiards and pool?

Input

The input consists of:

  • A line with an integer nn (2≤n≤1052\leq n\leq 10^5), the number of coworkers.
  • Then nn lines follow, each containing two integers bb and pp (−106≤b,p≤106-10^6 \leq b, p \leq 10^6), the skill in billiards and pool, respectively, of each coworker.

Output

Output possible if all coworkers can be divided into teams of two with equal skill. Output impossible otherwise.

Examples2

  1. Example 1

    Input
    6
    2 1
    3 0
    3 0
    4 2
    4 2
    5 1
    
    Expected output
    possible
    
  2. Example 2

    Input
    4
    1 0
    0 1
    -2 0
    0 -2
    
    Expected output
    impossible