import bisect

N = int(eval(input()))

A = [int(eval(input())) for _ in range(N)]

L = [A[0]]

for a in A[1:]:

    if L[-1] < a:

        L.append(a)

    else:

        L[bisect.bisect_left(L, a)] = a

print((len(L)))

import bisect

a = int(eval(input()))

b = [int(eval(input())) for d in range(a)]

c = [b[0]]

for i in b[1:]:

    if c[-1] < i:

        c.append(i)

    else:

        c[bisect.bisect_left(c,i)] = i

        

print((len(c)))

import bisect

N = int(eval(input()))
A = [int(eval(input())) for _ in range(N)]
L = [A[0]]
for a in A[1:]:
    if L[-1] < a:
        L.append(a)
    else:
        L[bisect.bisect_left(L, a)] = a
print((len(L)))

import bisect

a = int(eval(input()))
b = [int(eval(input())) for d in range(a)]
c = [b[0]]
for i in b[1:]:
    if c[-1] < i:
        c.append(i)
    else:
        c[bisect.bisect_left(c, i)] = i
print((len(c)))

-N = int(eval(input())) -A = [int(eval(input())) for _ in range(N)] -L = [A[0]] -for a in A[1:]: -    if L[-1] < a: -        L.append(a) +a = int(eval(input())) +b = [int(eval(input())) for d in range(a)] +c = [b[0]] +for i in b[1:]: +    if c[-1] < i: +        c.append(i) -        L[bisect.bisect_left(L, a)] = a -print((len(L))) +        c[bisect.bisect_left(c, i)] = i +print((len(c)))