Chef and Time Machine

All submissions for this problem are available.
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
Chef spent N days working really hard! He planned loads of tasks: as many as A_{i} tasks to do on the i_{th} day! Chef's work was brutal, so he only managed to finish B_{i} tasks on the i_{th} day.
The good news is that Chef has a Time Machine!
The Time Machine has K white buttons and M black buttons. Each button has a positive integer printed on it. Now Chef goes through all N days consequently and presses buttons. Each day Chef can only press one button (either white or black). After using a button once, it becomes inactive.
Pressing a white button with integer x printed on it reduces the number of planned tasks on the day it was pressed by exactly x. Note that this white button can only be pressed if number of planned tasks on the day are greater than or equal to x.
Pressing a black button with integer x printed on it increases the number of completed tasks on the day it was pressed by exactly x. Note that this black button can only be pressed if after pressing it, number of completed tasks don't exceed the number of tasks.
Chef is interested in finding the minimum possible amount of total uncompleted tasks he will still be left with after N days using the Machine in the best way?
Be careful! Time is sensitive! Chef cannot make a day when he completed more tasks then planned, as this may result in a moreworkthanplanned paradox, killing all lazy people on the planet!
Input
 The first line of input contains a single integer T, denoting the number of test cases. Description of T test cases follows.
 The first line of each test case contains three integers — N, K, M — denoting the number of days, white and black buttons appropriately.
 The second line contains N spaceseparated integers A_{1}, A_{2}, … , A_{N}, denoting the number of planned tasks.
 The third line contains N spaceseparated integers B_{1}, B_{2}, … , B_{N}, denoting the number of completed tasks.
 The fourth line contains K spaceseparated integers C_{1}, C_{2}, … , C_{K}, denoting the integers on white buttons.
 The fifth and last line contains M spaceseparated integers D_{1}, D_{2}, … , D_{M}, denoting the integers on black buttons.
Output
 In a single line, output an integer — the minimum possible amount of uncompleted tasks.
Constraints
 1 ≤ T ≤ 4
 1 ≤ N, K, M ≤ 10^5
 1 ≤ B_{i} ≤ A_{i} ≤ 10^5
 1 ≤ C_{i}, D_{i} ≤ 10^5
Subtasks
 Subtask N ≤ 10, K, M ≤ 5. Points: 30
 Subtask Original constraints. Points: 70
Example
Input: 1 4 2 2 5 7 6 1 3 3 1 1 6 3 1 4 Output: 3
Explanation
Example case 1. In this example Chef goes through the following steps: Use black button 1 on the first day. Use black button 4 on the second day. Use white button 3 on the third day. The arrays A and B are now effectively changed to: 5 7 3 1 4 7 1 1 So he will have 3 uncompleted tasks.
Author:  berezin 
Tester:  antoniuk1 
Editorial  http://discuss.codechef.com/problems/CHEFTMA 
Tags  berezin, greedy, jan16, simple, stl 
Date Added:  8122015 
Time Limit:  2 sec 
Source Limit:  50000 Bytes 
Languages:  C, CPP14, JAVA, PYTH, PYTH 3.5, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, CLOJ, FS 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions
HELP
If you are still having problems, see a sample solution here. 