#icpc2014autumnj. [icpc2014autumn_j]Website Tour

[icpc2014autumn_j]Website Tour

MathJax.Hub.Config({ tex2jax: { inlineMath: [["","",""], ["\\(","\\)"]], processEscapes: true }}); blockquote { font-family: Menlo, Monaco, "Courier New", monospace; color: #333333; display: block; padding: 8.5px; margin: 0 0 9px; font-size: 12px; line-height: 18px; background-color: #f5f5f5; border: 1px solid #ccc; border: 1px solid rgba(0, 0, 0, 0.15); -webkit-border-radius: 4px; -moz-border-radius: 4px; border-radius: 4px; white-space: pre; white-space: pre-wrap; word-break: break-all; word-wrap: break-word; }

Problem Statement

You want to compete in ICPC (Internet Contest of Point Collection). In this contest, we move around in NN websites, numbered 11 through NN, within a time limit and collect points as many as possible. We can start and end on any website.

There are MM links between the websites, and we can move between websites using these links. You can assume that it doesn't take time to move between websites. These links are directed and websites may have links to themselves.

In each website ii, there is an advertisement and we can get p_ip\_i point(s) by watching this advertisement in t_it\_i seconds. When we start on or move into a website, we can decide whether to watch the advertisement or not. But we cannot watch the same advertisement more than once before using any link in the website, while we can watch it again if we have moved among websites and returned to the website using one or more links, including ones connecting a website to itself. Also we cannot watch the advertisement in website ii more than k_ik\_i times.

You want to win this contest by collecting as many points as you can. So you decided to compute the maximum points that you can collect within TT seconds.


Input

The input consists of multiple datasets. The number of dataset is no more than 6060.

Each dataset is formatted as follows.

NN MM TT
p_1p\_1 t_1t\_1 k_1k\_1
:
:
p_Np\_N t_Nt\_N k_Nk\_N
a_1a\_1 b_1b\_1
:
:
a_Ma\_M b_Mb\_M

The first line of each dataset contains three integers NN (1leNle1001 \\le N \\le 100), MM (0leMle1,0000 \\le M \\le 1{,}000) and TT (1leTle10,0001 \\le T \\le 10{,}000), which denote the number of websites, the number of links, and the time limit, respectively. All the time given in the input is expressed in seconds.

The following NN lines describe the information of advertisements. The ii-th of them contains three integers p_ip\_i (1lep_ile10,0001 \\le p\_i \\le 10{,}000), t_it\_i (1let_ile10,0001 \\le t\_i \\le 10{,}000) and k_ik\_i (1lek_ile10,0001 \\le k\_i \\le 10{,}000), which denote the points of the advertisement, the time required to watch the advertisement, and the maximum number of times you can watch the advertisement in website ii, respectively.

The following MM lines describe the information of links. Each line contains two integers a_ia\_i and b_ib\_i (1lea_i,b_ileN1 \\le a\_i,b\_i \\le N), which mean that we can move from website a_ia\_i to website b_ib\_i using a link.

The end of input is indicated by a line containing three zeros.

Output

For each dataset, output the maximum points that you can collect within TT seconds.


Sample Input

5 4 10
4 3 1
6 4 3
3 2 4
2 2 1
8 5 3
1 2
2 3
3 4
4 5
3 3 1000
1000 1 100
1 7 100
10 9 100
1 2
2 3
3 2
1 0 5
25 25 2
1 0 25
25 25 2
5 5 100
1 1 20
1 1 20
10 1 1
10 1 1
10 1 1
1 2
2 1
3 4
4 5
5 3
3 3 100
70 20 10
50 15 20
90 10 10
1 2
2 2
2 3
0 0 0```

### Output for the Sample Input

```plain
15
2014
0
25
40
390```

* * *

### Source Name

JAG Practice Contest for ACM-ICPC Asia Regional 2014

* * *