Check the Check

Read dish names and price-quantity pairs until the line TOTAL, then print PAY if the waiter's total is at most the sum of price times quantity, else PROTEST.

Easy2ImplementationStringMathInterviewNo attempts yetTime limit2sMemory limit512 MB

Problem

As a tourist in Paris, you are told to always check the itemized bill (also called the check) that arrives at the end of a meal, the one listing what you ordered and the total price. Such bills are often handwritten, and the waiter adds the total up by hand. You do not want to pay more than your meal costs, so you protest whenever a mistake favors the restaurant. If the restaurant charges you less than it should, you pay without a word.

Write a program that decides whether to pay the total printed on the check or to protest about it.

Input

The input consists of 2n+22n + 2 lines.

  • For every kk with 0kn10 \le k \le n - 1, line 2k+12k + 1 holds the name dkd_k of an ordered dish.
  • For every kk with 0kn10 \le k \le n - 1, line 2k+22k + 2 holds the integer price pkp_k of dkd_k in euros and the number of orders ckc_k of dkd_k, separated by one space.
  • Line 2n+12n + 1 holds the word TOTAL.
  • Line 2n+22n + 2 holds the integer total TT in euros computed by the waiter.

The value of nn is not given in the input. Read dish entries until you reach the line equal to TOTAL.

Limits

  • For every kk with 0kn10 \le k \le n - 1:
    • dkd_k has at most 1000 characters, and is never equal to TOTAL;
    • 0pk10000 \le p_k \le 1000;
    • 0ck100 \le c_k \le 10;
  • 0n1000000 \le n \le 100\,000;
  • T2000000000T \le 2\,000\,000\,000.

Output

Print one line. Print PAY if the total TT on the check is less than or equal to the real total k=0n1pkck\sum_{k=0}^{n-1} p_k c_k, and PROTEST if it is larger.