I. Item Crafting
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
Examples
Input
2 6
2 3 4
3 4 5 6
0 1
0 1
0 1
0 1
Output
1
Input
2 6
2 3 4
3 4 5 6
0 1
0 2
0 1
0 1
Output
2
Input
1 5
2 2 3
2 3 4
2 4 5
0 3
0 2
Output
1
Input
1 4
3 2 3 4
0 2
1 4
0 1
Output
0