Exposing corruption

Bribe members to switch parties within a budget while keeping rivals in different parties, and report the largest achievable DSP and PPP sizes.

Medium7Dynamic programmingGraphDFSNo attempts yetTime limit3sMemory limit256 MB

Problem

The Central Committee of Nlogonia is made up of many congress members. The political system has exactly two parties, so every member belongs to one of them: the Deadly Serious Party (DSP) or the Party! Party! Party (PPP).

Edward is an investigative journalist. He found out that every congress member is corrupt and switches parties when offered a certain amount of Nlogmoney. The amount differs from member to member, but no member is without a price.

As usual in politics, some pairs of congress members are rivals. Two rivals never accept belonging to the same party. Edward wants to spend part or all of his budget to make some members switch parties and so collect solid evidence for his investigation. He has to respect the rivalries: after everyone who took the money has switched, two rivals must still belong to different parties.

Edward wants the largest possible impact. Find the maximum number of congress members that can belong to DSP when he spends at most his whole budget, and, under the same condition, the maximum number that can belong to PPP.

Input

The first line contains four integers DD, PP, RR and BB: the number of congress members who start in DSP (1D1001 \le D \le 100), the number who start in PPP (1P1001 \le P \le 100), the number of rivalries (1R20001 \le R \le 2000), and Edward's budget in Nlogmoney (1B1041 \le B \le 10^4). Members of DSP get distinct numbers from 11 to DD, and members of PPP get distinct numbers from 11 to PP.

The second line contains DD integers S1,S2,,SDS_1, S_2, \dots, S_D. Member ii of DSP switches parties when offered SiS_i Nlogmoney (1Si1001 \le S_i \le 100).

The third line contains PP integers T1,T2,,TPT_1, T_2, \dots, T_P. Member jj of PPP switches parties when offered TjT_j Nlogmoney (1Tj1001 \le T_j \le 100).

Each of the next RR lines contains two integers XX and YY, meaning that member XX of DSP and member YY of PPP are rivals (1XD1 \le X \le D, 1YP1 \le Y \le P). The same pair can appear more than once.

Output

Print one line with two integers: the maximum number of congress members that can belong to DSP within the budget, and the maximum number that can belong to PPP within the budget. The two values are independent, so each one is computed with the whole budget available.