#D9354. Website Tour

    ID: 7774 Type: Default 8000ms 536MiB

Website Tour

Website Tour

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 pip_i point(s) by watching this advertisement in tit_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 kik_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 p1p_1 t1t_1 k1k_1 : : pNp_N tNt_N kNk_N a1a_1 b1b_1 : : aMa_M bMb_M

The first line of each dataset contains three integers NN (1N1001 \le N \le 100), MM (0M1,0000 \le M \le 1{,}000) and TT (1T10,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 pip_i (1pi10,0001 \le p_i \le 10{,}000), tit_i (1ti10,0001 \le t_i \le 10{,}000) and kik_i (1ki10,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 aia_i and bib_i (1ai,biN1 \le a_i,b_i \le N), which mean that we can move from website aia_i to website bib_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

15 2014 0 25 40 390

Example

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

15 2014 0 25 40 390

inputFormat

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 p1p_1 t1t_1 k1k_1 : : pNp_N tNt_N kNk_N a1a_1 b1b_1 : : aMa_M bMb_M

The first line of each dataset contains three integers NN (1N1001 \le N \le 100), MM (0M1,0000 \le M \le 1{,}000) and TT (1T10,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 pip_i (1pi10,0001 \le p_i \le 10{,}000), tit_i (1ti10,0001 \le t_i \le 10{,}000) and kik_i (1ki10,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 aia_i and bib_i (1ai,biN1 \le a_i,b_i \le N), which mean that we can move from website aia_i to website bib_i using a link.

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

outputFormat

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

15 2014 0 25 40 390

Example

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

15 2014 0 25 40 390

样例

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
15

2014 0 25 40 390

</p>