Hide

Problem I
Goomba Stacks

/problems/goombastacks/file/statement/en/img-0001.jpeg

While exploring a cave, Mario finds that the entrance behind has been closed, leaving him no escape except going forward. Luckily, he has Cappy to help him escape. In front of Mario are a series of N rooms, which he must traverse in order. In the i-th room, Mario will find gi Goombas, which Mario can control using his trusty hat, Cappy. Each room also has a button, marked with bi, which indicates the number of Goombas needed to traverse from the i-th room to the i+1-th room. Using Cappy, Mario can stack goombas in order to reach the threshold of Goombas needed for the button. Additionally, he can bring any previous Goombas to subsequent rooms. Mario can escape the cave if he escapes the N-th room. Can you determine if Mario can escape?

Input

The first line of input is a integer 1N100000. The following N lines consist 2 space-separated integers, gi (1gi1000) and bi (1bi100000000), representing the number of goombas in the i-th room and the number of goombas needed to escape the i-th room respectively.

Output

If Mario can escape, print “possible”. If Mario cannot escape, print “impossible”.

Sample Input 1 Sample Output 1
3
4 3
2 5
1 7
possible
Sample Input 2 Sample Output 2
3
4 3
2 5
1 8
impossible
Hide

Please log in to submit a solution to this problem

Log in