n, m = list(map(int,input().split()))

par = [-1 for i in range(n + 1)]

par[0] = 0

def find(x):

    if (par[x] < 0):

        return x

    else:

        x = par[x]

        return find(x)

def unit(x, y):

    if (find(x) == find(y)):

        pass

    else:

        x = find(x)

        y = find(y)

        if (x > y):

            x, y = y, x

        s = par[y]

        par[y] = x

        par[x] = par[x] + s



for i in range(m):

    a, b = list(map(int,input().split()))

    unit(a, b)



par.sort()

print((-par[0]))

n, m = list(map(int,input().split()))

lst = [-1 for i in range(n + 1)]

lst[0] = 0

def find(x):

    if(lst[x] < 0):

        return(x)

    else:

        return(find(lst[x]))

def unit(x, y):

    xr = find(x)

    yr = find(y)

    if (xr == yr):

        pass

    else:

        if (xr > yr):

            x, y = y, x

            xr, yr = yr, xr

        lst[xr] = lst[xr] + lst[yr]

        lst[yr] = xr



for i in range(m):

    a, b = list(map(int,input().split()))

    unit(a, b)



print((-(min(lst))))

    

n, m = list(map(int, input().split()))
par = [-1 for i in range(n + 1)]
par[0] = 0


def find(x):
    if par[x] < 0:
        return x
    else:
        x = par[x]
        return find(x)


def unit(x, y):
    if find(x) == find(y):
        pass
    else:
        x = find(x)
        y = find(y)
        if x > y:
            x, y = y, x
        s = par[y]
        par[y] = x
        par[x] = par[x] + s


for i in range(m):
    a, b = list(map(int, input().split()))
    unit(a, b)
par.sort()
print((-par[0]))

n, m = list(map(int, input().split()))
lst = [-1 for i in range(n + 1)]
lst[0] = 0


def find(x):
    if lst[x] < 0:
        return x
    else:
        return find(lst[x])


def unit(x, y):
    xr = find(x)
    yr = find(y)
    if xr == yr:
        pass
    else:
        if xr > yr:
            x, y = y, x
            xr, yr = yr, xr
        lst[xr] = lst[xr] + lst[yr]
        lst[yr] = xr


for i in range(m):
    a, b = list(map(int, input().split()))
    unit(a, b)
print((-(min(lst))))

-par = [-1 for i in range(n + 1)] -par[0] = 0 +lst = [-1 for i in range(n + 1)] +lst[0] = 0 -    if par[x] < 0: +    if lst[x] < 0: -        x = par[x] -        return find(x) +        return find(lst[x]) -    if find(x) == find(y): +    xr = find(x) +    yr = find(y) +    if xr == yr: -        x = find(x) -        y = find(y) -        if x > y: +        if xr > yr: -        s = par[y] -        par[y] = x -        par[x] = par[x] + s +            xr, yr = yr, xr +        lst[xr] = lst[xr] + lst[yr] +        lst[yr] = xr -par.sort() -print((-par[0])) +print((-(min(lst))))