package main
import (
"bufio"
"fmt"
"os"
"strconv"
)
func main() {
scanner := bufio.NewScanner(os.Stdin)
scanner.Split(bufio.ScanWords)
nextInt := func() int {
scanner.Scan()
res, _ := strconv.Atoi(scanner.Text())
return res
}
if !scanner.Scan() {
return
}
t, _ := strconv.Atoi(scanner.Text())
out := bufio.NewWriter(os.Stdout)
defer out.Flush()
for i := 0; i < t; i++ {
n := nextInt()
m := nextInt()
nextInt()
nextInt()
for j := 0; j < n+m; j++ {
nextInt()
}
fmt.Fprintln(out, n+m)
}
}