# 2015 German Collegiate Programming Contest (GCPC)

# A Journey to Greece

For a long time Tim wanted to visit Greece. He has already purchased his flight to and from Athens. Tim has a list of historical sites he wants to visit, e.g., Olympia and Delphi. However, due to recent political events in Greece, the public transport has gotten a little complicated. To make the Greek happy and content with their new government, many short-range bus and train lines have been created. They shall take the citizens around in their neighborhoods, to work or to their doctor. At the same time, long-range trains that are perfect for tourists have been closed down as they are too expensive. This is bad for people like Tim, who really likes to travel by train. Moreover, he has already purchased the Greece' Card for Public Conveyance (GCPC) making all trains and buses free for him.

Visual representation of the Sample Input: Tim's tour has length **18**.

Despite his preferred railway lines being closed down, he still wants to make his travel trough Greece. But taking all these local bus and train connections is slower than expected, so he wants to know whether he can still visit all his favorite sites in the timeframe given by his flights. He knows his schedule will be tight, but he has some emergency money to buy a single ticket for a special Greek taxi service. It promises to bring you from any point in Greece to any other in a certain amount of time.

For simplicity we assume, that Tim does never have to wait for the next bus or train at a station. Tell Tim, whether he can still visit all sites and if so, whether he needs to use this taxi ticket.

#### Input

The first line contains five integers **n**, **p**, **m**, **g** and **t**, where **n** denotes the number of places in Greece, **p** the number of sites Tim wants to visit, **m** the number of connections, **g** the total amount of time Tim can spend in Greece, and **t** the time the taxi ride takes (**1** ≤ **n** ≤ **2** * `10`

, ^{4}**1** ≤ **p** ≤ **15**, **1** ≤ **m**, **g** ≤ `10`

, ^{5}**1** ≤ **t** ≤ **500**).

Then follow **p** lines, each with two integers `p`

and _{i}`t`

, specifying the places Tim wants to visit and the time Tim spends at each site (_{i}**0** ≤ `p`

< _{i}**n**, **1** ≤ `t`

≤ _{i}**500**). The sites `p`

are distinct from each other._{i}

Then follow **m** lines, each describing one connection by three integers `s`

, _{i}`d`

and _{i}`t`

, where _{i}`s`

and _{i}`d`

specify the start and destination of the connection and _{i}`t`

the amount of time it takes (_{i}**0** ≤ `s`

, _{i}`d`

< _{i}**n**, **1** ≤ `t`

≤ _{i}**500**).

All connections are bi-directional. Tim’s journey starts and ends in Athens, which is always the place **0**.

#### Output

Print either **"impossible"**, if Tim cannot visit all sites in time, **"possible without taxi"**, if he can visit all sites without his taxi ticket, or **"possible with taxi"**, if he needs the taxi ticket.

6 3 10 18 5 1 2 4 2 5 2 0 1 2 1 2 3 2 4 3 1 3 10 2 3 6 0 3 2 3 4 2 4 5 1 3 5 2 0 5 5

possible with taxi