Hide

Problem H
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 $g_ i$ Goombas, which Mario can control using his trusty hat, Cappy. Each room also has a button, marked with $b_ i$, 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 $1 \leq N \leq 100\, 000$. The following $N$ lines consist $2$ space-separated integers, $g_ i$ $(1 \leq g_ i \leq 1\, 000)$ and $b_ i$ $(1 \leq b_ i \leq 100\, 000\, 000)$, 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

Please log in to submit a solution to this problem

Log in