Type: Default 1000ms 256MiB

搭配购买

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

Description

Joe觉得云朵很美,决定去山上的商店买一些云朵。商店里有$n$朵云,云朵被编号为$1,2,…,n$,并且每朵云都有一个价值。但是商店老板跟他说,一些云朵要搭配来买才好,所以买一朵云则与这朵云有搭配的云都要买。

但是Joe的钱有限,所以他希望买的价值越多越好。

Input Format

第1行$n,m,w$,表示$n$朵云,$m$个搭配,Joe有$w$的钱。

第2~n+1行,每行$c_i$,$d_i$表示$i$朵云的价钱和价值。

第n+2~n+1+m行,每行$u_i$,$v_i$,表示买$u_i$就必须买$v_i$,同理,如果买$v_i$就必须买$u_i$。

Output Format

一行,表示可以获得的最大价值。

5 3 10
3 10
3 10
3 10
5 100
10 1
1 3
3 2
4 2
1

Hint

【数据范围】

30%的数据保证:$n\le 100$;

50%的数据保证:$n\le 1,000;m\le100;w\le1,000$;

100%的数据保证:$n\le 10,000;0\le m\le 5000;w\le 10,000$。