def score2(elems): count = sum(elems) total = 0 allowed = count-(count//4) for i in range(100, -1, -1): if allowed > elems[i]: total += i*elems[i] allowed -= elems[i] else: total += i*allowed return total return total def main(): ct = int(input()) for _ in range(ct): input() me_ = [int(i) for i in input().split()] other_ = [int(i) for i in input().split()] me = [0 for i in range(101)] other = [0 for i in range(101)] for i in range(len(me_)): me[me_[i]] += 1 other[other_[i]] += 1 i=0 while score2(me) < score2(other): me[100] += 1 other[0] += 1 i+=1 print(i) main()