import sys

def tanya(a,b,m,n):
    print('%d %d %s %s' % (m,n,' '.join(a),' '.join(b)))
    sys.stdout.flush()
    s = int(input())
    if s == -1:
        return -1
        sys.exit()
    return s
t = int(input())
for _ in range(t):
    n = int(input())
    s = [str(i) for i in range(2,n+1)]
    d_1 = tanya(['1'],s,1,n-1)
    while len(s) > 1:
        k = len(s)//2
        s = s[:k] if tanya(['1'],s[:k],1,k) == d_1 else s[k:]
    t = [str(i) for i in range(1,n+1) if str(i) != s[0]]
    ans = tanya([s[0]],t,1,n-1)
    print('-1 %d' % ans)


t=int(input())
while (t):
	n=int(input())
	print (1,n-1,1,end=" ")
	for i in range(2,n+1):
		print (i,end=" ")
	print()
	max1=int(input())
	high=n
	low=2
	while(low<high):
		mid=(low+high)//2
		print (1,mid-low+1,1,end=" ")
		for i in range(low,mid+1):
			print (i,end=" ")
		print ()
		c=int(input())
		if (c==max1):
			high=mid
		else:
			low=mid+1
	ans=high
	print (1,n-1,ans,end=" ")
	for i in range(1,ans):
		print (i,end=" ")
	for i in range(ans+1,n+1):
		print (i,end=" ")
	print ()
	c1=int(input())
	print (-1,c1)
	t=t-1


t=int(input())
while (t):
	n=int(input())
	print (1,n-1,1,end=" ")
	for i in range(2,n+1):
		print (i,end=" ")
	print()
	max1=int(input())
	high=n
	low=2
	while(low<high):
		mid=(low+high)//2
		print (1,mid-low+1,1,end=" ")
		for i in range(low,mid+1):
			print (i,end=" ")
		print ()
		c=int(input())
		if (c==max1):
			high=mid-1
		else:
			low=mid+1
	ans=min(n,high+1)
	print (1,n-1,ans,end=" ")
	for i in range(1,ans):
		print (i,end=" ")
	for i in range(ans+1,n+1):
		print (i,end=" ")
	print ()
	c1=int(input())
	print (-1,c1)
	t=t-1


def furthest(d, s, n):
    print(s, n)
    if n - s == 0:
        return s
    print(1, (n - s)//2 + 1, 1, *tuple(range(s, (n+s)//2 + 1)))
    g = int(input())
    if g < d: return furthest(d, (n+s)//2 + 1, n)
    else: return furthest(d, s, (n + s)//2)

t = int(input())
for i in range(t):
    n = int(input())
    print(1, n - 1, 1, *tuple(range(2, n + 1)))
    d = int(input())
    c = furthest(d, 2, n)
    print(1, n - 1, c, *tuple(i for i in range(1, n + 1) if i != c))
    r = int(input())
    print('-1', r)


def furthest(d, s, n):
    if n - s == 0:
        return s
    print(1, (n - s)//2 + 1, 1, *tuple(range(s, (n+s)//2 + 1)))
    g = int(input())
    if g < d: return furthest(d, (n+s)//2 + 1, n)
    else: return furthest(d, s, (n + s)//2)

t = int(input())
for i in range(t):
    n = int(input())
    print(1, n - 1, 1, *tuple(range(2, n + 1)))
    d = int(input())
    c = furthest(d, 2, n)
    print(1, n - 1, c, *tuple(i for i in range(1, n + 1) if i != c))
    r = int(input())
    print('-1', r)


import sys

T=int(input())
a=0
while T :
    T-=1
    n=int(input())
    ans=0
    for i in range(0,10):
        if (1<<i)>n:
            break
        a=[]
        b=[]
        for j in range (1,n+1):
            if (j&(1<<i)>0):
                sys.stdout.flush
                a.append(j)
            else:
                b.append(j)
        print(len(a),end=" ")
        print(len(b),end=" ")
        for i in a:
            print(i,end=" ")
        for i in b:
            print(i,end=" ")
        print();
        sys.stdout.flush()
        dis=int(input())
        ans=max(dis,ans)
    print(-1,ans)


t = int(input())
for i in range(t):
    n = int(input())
    ans = 0
    number = ["{:07b}".format(k) for k in range(n)]
    for j in range(7):
        p = []
        q = []
        for k in range(len(number)):
            if number[k][-1-j] == "0":
                p.append(k+1)
            else:
                q.append(k+1)
        query = [len(p), len(q)] + p + q
        print(" ".join(map(str, query)))
        anstemp = int(input())
        ans = max(ans, anstemp)
    print(-1, ans)


t = int(input())
for i in range(t):
    n = int(input())
    ans = 0
    number = ["{:07b}".format(k) for k in range(n)]
    for j in range(7):
        p = []
        q = []
        for k in range(len(number)):
            if number[k][-1-j] == "0":
                p.append(k+1)
            else:
                q.append(k+1)
        if len(p) >= 1 and len(q) >= 1:
            query = [len(p), len(q)] + p + q
            print(" ".join(map(str, query)))
            anstemp = int(input())
            ans = max(ans, anstemp)
    print(-1, ans)


from sys import stdout
t = int(input())
for __ in range(t):
    n = int(input())
    max1, q = -1, 1
    while q < n:
        vertexes = {_ for _ in range(1, n+1)}
        ans = set()
        for q1 in range(0, n, 2*q):
            for q2 in range(q):
                ans.add(q1+q2+1)
        vertexes -= ans
        print(len(ans), len(vertexes), *ans, *vertexes)
        stdout.flush()
        x = int(input())
        if x == -1:
            exit(0)
        max1 = max(max1, x)
        q *= 2
    print(-1, max1)
    stdout.flush()


from sys import stdout
t = int(input())
for __ in range(t):
    n = int(input())
    max1, q = -1, 1
    while q < n:
        vertexes = {_ for _ in range(1, n+1)}
        ans = set()
        for q1 in range(0, n, 2*q):
            for q2 in range(q):
                ans.add(q1+q2+1)
        vertexes -= ans
        print(len(ans), len(vertexes), *ans, *vertexes)
        stdout.flush()
        x = int(input())
        if x == -1:
            exit(0)
        max1 = max(max1, x)
        q *= 2
    print(-1, max1)


from sys import stdout
t = int(input())
for __ in range(t):
    n = int(input())
    max1, q = -1, 1
    while q < n:
        vertexes = {_ for _ in range(1, n+1)}
        ans = set()
        for q1 in range(0, n, 2*q):
            for q2 in range(q):
                if q1+q2+1 > n:
                    break
                ans.add(q1+q2+1)
        vertexes -= ans
        print(len(ans), len(vertexes), *ans, *vertexes)
        stdout.flush()
        x = int(input())
        if x == -1:
            exit(0)
        max1 = max(max1, x)
        q *= 2
    print(-1, max1)
    stdout.flush()


from sys import stdout
t = int(input())
for __ in range(t):
    n = int(input())
    max1, q = -1, 1
    while q < n:
        vertexes = {_ for _ in range(1, n+1)}
        ans = set()
        for q1 in range(0, n, 2*q):
            for q2 in range(q):
                ans.add(q1+q2+1)
        vertexes -= ans
        print(len(ans), len(vertexes), *ans, *vertexes)
        stdout.flush()
        x = int(input())
        if x == -1:
            exit(0)
        max1 = max(max1, x)
        q *= 2
    print(max1)


from sys import stdout

m = [([], []) for i in range(9)]

for c in range(110):
	w = c
	for i in range(9):
		m[i][w % 2].append(c + 1)
		w //= 2

# print(m)

def ask(i, n):
	a = [str(c) for c in m[i][0] if c <= n]
	b = [str(c) for c in m[i][1] if c <= n]

	if len(a) == 0 or len(b) == 0:
		return 0
	else:
		print(len(a), len(b), ' '.join(a), ' '.join(b))
		stdout.flush()
		return int(input())

def solve(n):
	res = 0
	for i in range(9):
		res = max(res, ask(i, n))
	return res

t = int(input())
for _ in range(t):
	n = int(input())
	ans = solve(n)
	print(-1, ans)
	stdout.flush()


from sys import stdout

m = [([], []) for i in range(9)]

for c in range(16):
	w = c
	for i in range(9):
		m[i][w % 2].append(c + 1)
		w //= 2

# print(m)

def ask(i, n):
	a = [str(c) for c in m[i][0] if c <= n]
	b = [str(c) for c in m[i][1] if c <= n]

	if len(a) == 0 or len(b) == 0:
		return 0
	else:
		print(len(a), len(b), ' '.join(a), ' '.join(b))
		stdout.flush()
		return int(input())

def solve(n):
	res = 0
	for i in range(9):
		res = max(res, ask(i, n))
	return res

t = int(input())
for _ in range(t):
	n = int(input())
	ans = solve(n)
	print(-1, ans)
	stdout.flush()


from sys import stdout
t = int(input())
for testcase in range(t):
    m = 0
    n = int(input())
    for _ in range(0,7):
        temp1 = []
        temp2 = []
        p = 2**_
        for i in range(1,n+1):
            if (i%(2*p))<=p and (i%(2*p))!=0:
                temp1.append(i)
            else:
                temp2.append(i)
        if len(temp1)>0 and len(temp2)>0:
            print(len(temp1), end=' ')
            print(len(temp2), end=' ')
            for num in temp1:
                print(num, end=' ')
            for num in temp2:
                print(num, end=' ')
            stdout.flush()
            m = max(m, int(input()))
    print("-1", end=' ')
    print(m)
    stdout.flush()


import sys

def spot(num,k):
	m = num // (2**k)
	return m % 2

def setquery(k, maxval):
	set1 = []
	set2 = []
	for i in range(1,maxval+1):
		if spot(i-1,k) == 0:
			set1.append(i)
		else:
			set2.append(i)
	return '{} {} {} {}'.format(len(set1),len(set2),' '.join([str(x) for x in set1]),' '.join([str(x) for x in set2]))

t = int(input())
for _ in range(t):
	maxval = int(input())
	bestdist = 0
	k = 0
	while 2**k < maxval:
		print(setquery(k,maxval))
		sys.stdout.flush()
		x = int(input())
		if x == -1:
			exit()
		else:
			bestdist = max(bestdist,x)
		k += 1
	print('-1 {}'.format(bestdist))


t = int(input())
for i in range(t):
    n = int(input())
    root = 1
    rest = list(range(2, n + 1))
    other = []
    max_for_root = None
    known_rest = rest[:]
    while len(known_rest) > 1:
        print(1, len(rest), *([root] + rest))
        new_max_for_root = int(input())
        if max_for_root is None or max_for_root == new_max_for_root:
            known_rest, rest, other = rest[:], rest[:len(rest)//2], rest[len(rest)//2:]
            max_for_root = new_max_for_root
        else:
            known_rest, rest, other = other[:], other[:len(other)//2], other[len(other)//2:]
    new_root = known_rest[0]
    new_rest = [x for x in range(1, n + 1) if x != new_root]
    print(1, len(new_rest), *([new_root] + new_rest))
    ans = int(input())
    print('-1 {}'.format(ans))


#  =========     /\       /|    |====/|
#      |        /  \       |    |   / |
#      |       /____\      |    |  /  |
#      |      /      \     |    | /   |
#  ========= /        \  =====  |/====|
#  code

from sys import stdout as std
if __name__ == "__main__":
    t = int(input())
    for _ in range(t):
        n = int(input())
        l,u = 2,n
        std.flush()
        print(n-1,1,end=" ")
        for i in range(2,n+1):
            print(i,end=" ")
        print(1)
        ans = int(input())
        if ans == -1:
            print(-1,0)
            break
        while l < u:
            std.flush()
            mid = (l+u)//2
            print(mid-l+1,1,end=" ")
            for i in range(l,mid+1):
                print(i,end=" ")
            print(1)
            ans2 = int(input())
            if ans2 == ans:
                u = mid
            else:
                l = mid+1
        std.flush()
        print(n-1 , 1,end = " ")
        for i in range(1,n+1):
            if i == l:
                continue
            else:
                print(i,end=" ")
        print(l)
        ans = int(input())
        std.flush()
        print(-1,ans)


#  =========     /\       /|    |====/|
#      |        /  \       |    |   / |
#      |       /____\      |    |  /  |
#      |      /      \     |    | /   |
#  ========= /        \  =====  |/====|
#  code

from sys import stdout as std
if __name__ == "__main__":
    t = int(input())
    for _ in range(t):
        n = int(input())
        l,u = 2,n
        std.flush()
        print(n-1,1,end=" ")
        for i in range(2,n+1):
            print(i,end=" ")
        print(1)
        ans = int(input())
        if ans == -1:
            exit()
        while l < u:
            std.flush()
            m = (l+u)//2
            print(mid-l+1,1,end=" ")
            for i in range(2,mid+1):
                print(i,end=" ")
            print(1)
            ans2 = int(input())
            if ans2 == ans:
                u = mid
            else:
                l = mid+1
        std.flush()
        print(n-1 , 1,end = " ")
        for i in range(1,n+1):
            if i == l:
                continue
            else:
                print(i,end=" ")
        print(l)
        ans = int(input())
        std.flush()
        print(-1,ans)


#  =========     /\       /|    |====/|
#      |        /  \       |    |   / |
#      |       /____\      |    |  /  |
#      |      /      \     |    | /   |
#  ========= /        \  =====  |/====|
#  code

from sys import stdout as std
if __name__ == "__main__":
    t = int(input())
    for _ in range(t):
        n = int(input())
        l,u = 2,n
        std.flush()
        print(n-1,1,end=" ")
        for i in range(2,n+1):
            print(i,end=" ")
        print(1)
        ans = int(input())
        if ans == -1:
            print(-1,0)
            break
        while l < u:
            std.flush()
            m = (l+u)//2
            print(mid-l+1,1,end=" ")
            for i in range(2,mid+1):
                print(i,end=" ")
            print(1)
            ans2 = int(input())
            if ans2 == ans:
                u = mid
            else:
                l = mid+1
        std.flush()
        print(n-1 , 1,end = " ")
        for i in range(1,n+1):
            if i == l:
                continue
            else:
                print(i,end=" ")
        print(l)
        ans = int(input())
        std.flush()
        print(-1,ans)


import math

tests = int(input())
for test in range(tests):
    n = int(input())
    a = list(range(1, n + 1))
    d = 0
    for i in range(math.ceil(math.log2(n))):
        a1 = list(filter(lambda x: (x >> i) % 2 == 0, a))
        a2 = list(filter(lambda x: (x >> i) % 2 != 0, a))
        print(len(a1), len(a2), *a1, *a2)
        resp = int(input())
        if resp == -1:
            break
        d = max(d, resp)
    print(-1, d)


t = int(input())

for _ in range(t):
    n = int(input())
    def query(S, T):
        print(len(S), len(T), *S, *T, flush=True)
        return int(input())

    mx = query([1], range(2,n+1))

    l = 2
    r = n+2
    while r-l > 1:
        m = (r+l)//2
        dst = query([1],range(l,m))
        if dst == mx:
            l = l
            r = m
        else:
            l = m
            r = r

    ans = query([l], set(range(1,n+1))-{l})

    print(-1, ans, flush=True)


import sys

nums = [3, 5, 7]
gr = [[[0, 1], [0, 2]],
      [[0, 1], [0, 2], [0, 3]],
      [[0, 1, 2], [0, 1, 3], [0, 3, 4], [0, 3, 5]]]

t = int(input())

for t_i in range(t):
    n = int(input())
    ans = 0
    for i in range(3):
        for j in range(len(gr[i])):
            g1 = []
            g2 = []
            for k in range(1, n + 1):
                if k % nums[i] in gr[i][j]:
                    g1.append(k)
                else:
                    g2.append(k)
            if min(len(g1), len(g2)) == 0:
                continue
            print(str(len(g1)) + " " + str(len(g2)) + " ", end = '')
            for k in g1:
                print(str(k) + " ", end='')
            for k in g2:
                print(str(k) + " ", end='')
            print()
            sys.stdout.flush()

            resp = int(input())
            if resp == -1:
                sys.exit(0)
            ans = max(ans, resp)
    print("-1 " + str(ans))


Q = int(input())
def calc(L, R):
    print(1, R-L, 1, *[j for j in range(L, R)])
    return int(input())
def calc2(i, n):
    print(1, n-1, i, *[j+1 for j in range(n) if j+1 != i])
    return int(input())

for _ in range(Q):
    N = int(input())
    d0 = calc(2, N+1)
    L=2
    R=N+1
    while R > L + 1:
        M=(L+R)//2
        d = calc(L, M)
        if d == d0:
            R = M
        else:
            L = M
    print(-1, calc2(L, N))


import sys

def req(a, b):
    if a == [] or b == []:
        return -1
    print(len(a), len(b),*a,*b)
    sys.stdout.flush()
    return int(input())

def main(n):
    m = 0
    for i in range(1, 10):
        k = n//2**i
        if k == 0:
            return m
        a = [j for j in range(1, n + 1) if ((j+1)//k)%2]
        b = [j for j in range(1, n + 1) if not ((j+1)//k)%2]
        if a == [] or b == []:
            continue
        r = req(a, b)
        if r == -1:
            return -1
        m = max(m, r)
    return m

t = int(input())
for i in range(t):
    u = int(input())
    if u == -1:
        break
    k = main(u)
    if k == -1:
        break
    print(-1, k)
    sys.stdout.flush()


import sys

def req(a, b):
    if a == [] or b == []:
        return -1
    print(len(a), len(b),*a,*b)
    sys.stdout.flush()
    return int(input())

def br(r, l, d):
    if d == 1:
        return list(range(r, (r + l)//2)), list(range((r+l)//2, l))
    a, b, c, d = *br(r, (r + l)//2, d-1), *br((r+l)//2, l, d-1)
    return a + c, b + d

def main(n):
    m = 0
    for i in range(1, 10):
        a, b = br(1, n+1,i)
        if a == [] or b == []:
            continue
        r = req(a, b)
        if r == -1:
            return -1
        m = max(m, r)
    return m

try:
    t = int(input())
    for i in range(t):
        u = int(input())
        if u == -1:
            break
        k = main(u)
        if k == -1:
            break
        print(-1, k)
        sys.stdout.flush()
except:
    pass


n, q = map(int, input().split())
a = input().split()
for i in range(q):
    m = input()
    for i in range(n):
        el = a[i]
        if eval(el + m):
            a[i] = '-'+el if el[0] != '-' else el[1:]
print(' '.join(map(lambda x: str(int(x)), a)))


from sys import stdout

t = int(input())
for i in range(0, t) :
    n = int(input())
    curr = 1
    res = 0
    for j in range(0, 7) :
        p = []
        q = []
        for k in range(1, n + 1) :
            if(k & curr) :
                p.append(k)
            else :
                q.append(k)
        if(len(p) and len(q)) :
            print(len(p), len(q), *p, *q)
            stdout.flush()
            resp = int(input())
            if(resp > res) : res = resp
        curr = curr << 1
    print(-1, res)
    stdout.flush()


import sys

t = int(input())

for i in range(0, t) :
    n = int(input())
    curr = 1
    res = 0
    for j in range(0, 7) :
        p = []
        q = []
        for k in range(1, n + 1) :
            if(k & curr) :
                p.append(k)
            else :
                q.append(k)
        if(len(p) and len(q)) :
            print(len(p), len(q), *p, *q)
            sys.stdout.flush()
        curr = curr << 1
        resp = int(input())
        if(resp > res) : res = resp
    print(-1, res)
    sys.stdout.flush()


import sys

T=int(input())
a=0
while T :
    T-=1
    n=int(input())
    ans=0
    for i in range(0,10):
        if (1<<i)>n:
            break
        a=[]
        b=[]
        for j in range (1,n+1):
            if (j&(1<<i)>0):
                sys.stdout.flush
                a.append(j)
            else:
                b.append(j)
        print(len(a),end=" ")
        print(len(b),end=" ")
        for i in a:
            print(i,end=" ")
        for i in b:
            print(i,end=" ")
        print();
        sys.stdout.flush()
        dis=int(input())
        ans=max(dis,ans)
    print(-1,ans)


"""
NTC here
"""
from sys import setcheckinterval,setrecursionlimit,stdout
setcheckinterval(1000)
setrecursionlimit(10**6)

iin=lambda :int(input())
lin=lambda :list(map(int,input().split()))
for _ in range(iin()):
    ans=0
    ch1=0
    ch2=0
    n=iin()
    if n==1:print(ans)
    nn=n
    ans1=range(1,n+1)
    ch=0
    while n>1:
        if ch==9:break
        h=n//2
        if ch2==1 or ch1<ans:
            h=nn-h
            if ch2==0:n=nn
            ch2=1
        print(h,nn-h,*ans1,flush=True)
        stdout.flush()
        x=iin()
        ch1=x
        if x==-1:exit()
        ans=max(ans,x)
        n//=2
        ch+=1

    print(-1,ans)


"""
NTC here
"""
from sys import setcheckinterval,setrecursionlimit,stdout
setcheckinterval(1000)
setrecursionlimit(10**6)

iin=lambda :int(input())
lin=lambda :list(map(int,input().split()))
for _ in range(iin()):
    n=iin()
    ans=0
    for i in range(9):
        l=[]
        r=[]
        for j in range(1,n+1):
            if j>>i&1:l.append(j)
            else:r.append(j)
        if l==[] or r==[]:continue
        print(len(l),len(r),*l,*r,flush=True)
        stdout.flush()
        ans=max(ans,iin())
    print(-1,ans)


"""
NTC here
"""
from sys import setcheckinterval,stdin,setrecursionlimit,stdout
setcheckinterval(1000)
setrecursionlimit(10**6)

iin=lambda :int(stdin.readline())
lin=lambda :list(map(int,stdin.readline().split()))
for _ in range(iin()):
    ans=0
    n=iin()
    if n==1:print(ans)
    nn=n
    ans1=range(1,n+1)
    ch=0
    while n>1:
        if ch==8:break
        h=n//2
        print(h,nn-h,*ans1,flush=True)
        stdout.flush()
        x=iin()
        if x==-1:exit()
        ans=max(ans,x)
        n//=2
        ch+=1

    print(-1,ans)


"""
NTC here
"""
from sys import setcheckinterval,setrecursionlimit,stdout
setcheckinterval(1000)
setrecursionlimit(10**6)

iin=lambda :int(input())
lin=lambda :list(map(int,input().split()))
for _ in range(iin()):
    n=iin()
    if n==1:print(ans)
    ans1=range(1,n+1)
    ch=4
    nn=n
    print(n//2,n-n//2,*ans1,flush=True)
    ans=iin()
    ans1=range(1,nn+1)
    s1,s2=0,0
    if n>3:
        h=n//4
        ans2=0
        for i in range(4):
            l=range(i*h+1,i*h+h+1)
            if i==3:
                l=range(i*h+1,n+1)
            r=[j for j in range(1,n+1) if j not in l ]
            print(len(l),len(r),*l,*r,flush=True)
            stdout.flush()
            x=iin()
            if x>ans2:
                s1=i*h+1
                s2=i*h+h+1
            ans2=max(x,ans2)
        ans=max(ans2,ans)
        while s2-s1>1:
            if ch==9:break
            l=s2-s1+1
            h1=range(s1,l//2+1)
            h2=range(l//2+1,s2+1)
            a1=[j for j in range(1,n+1) if j not in h1 ]
            a2=[j for j in range(1,n+1) if j not in h2 ]
            print(len(h1),len(a1),*h1,*a1,flush=True)
            stdout.flush()
            x1=iin()
            print(len(h2),len(a2),*h2,*a2,flush=True)
            stdout.flush()
            x2=iin()
            if x1>x2:
                s1,s2=s1,l//2
            else:
                s1,s2=l//2+1,s2
            ch+=2
    else:
        for i in range(1,n+1):
            l=[i]
            r=[j for j in range(1,n+1) if j not in l]
            print(len(l),len(r),*l,*r,flush=True)
            stdout.flush()
            x=iin()
            ans=max(ans,x)

    print(-1,ans)


"""
NTC here
"""
from sys import setcheckinterval,setrecursionlimit,stdout
setcheckinterval(1000)
setrecursionlimit(10**6)

iin=lambda :int(input())
lin=lambda :list(map(int,input().split()))
for _ in range(iin()):
    n=iin()
    if n==1:print(ans)
    ans1=range(1,n+1)
    ch=4
    nn=n
    print(n//2,n-n//2,*ans1,flush=True)
    ans=iin()
    ans1=range(1,nn+1)
    s1,s2=0,0
    if n>3:
        h=n//4
        ans2=0
        for i in range(4):
            l=range(i*h+1,i*h+h+1)
            if i==3:
                l=range(i*h+1,n+1)
            r=[j for j in range(1,n+1) if j not in l ]
            print(len(l),len(r),*l,*r,flush=True)
            stdout.flush()
            x=iin()
            if x>ans2:
                s1=i*h+1
                s2=i*h+h+1
            ans2=max(x,ans2)
        ans=max(ans2)
        while s2-s1>1:
            if ch==9:break
            l=s2-s1+1
            h1=range(s1,l//2+1)
            h2=range(l//2+1,s2+1)
            a1=[j for j in range(1,n+1) if j not in h1 ]
            a2=[j for j in range(1,n+1) if j not in h2 ]
            print(len(h1),len(a1),*h1,*a1,flush=True)
            stdout.flush()
            x1=iin()
            print(len(h2),len(a2),*h2,*a2,flush=True)
            stdout.flush()
            x2=iin()
            if x1>x2:
                s1,s2=s1,l//2
            else:
                s1,s2=l//2+1,s2
            ch+=2
    else:
        for i in range(1,n+1):
            l=[i]
            r=[j for j in range(1,n+1) if j not in l]
            print(len(l),len(r),*l,*r,flush=True)
            stdout.flush()
            x=iin()
            ans=max(ans,x)

    print(-1,ans)


"""
NTC here
"""
from sys import setcheckinterval,setrecursionlimit,stdout
setcheckinterval(1000)
setrecursionlimit(10**6)

from random import shuffle
iin=lambda :int(input())
lin=lambda :list(map(int,input().split()))
for _ in range(iin()):
    n=iin()
    ans=0
    rr=list(range(1,n+1))
    for i in range(9):
        shuffle(rr)
        print(1,n-1,*rr,flush=True)
        stdout.flush()
        ans=max(ans,iin())
    print(-1,ans)


"""
NTC here
"""
from sys import setcheckinterval,setrecursionlimit,stdout
setcheckinterval(1000)
setrecursionlimit(10**6)

iin=lambda :int(input())
lin=lambda :list(map(int,input().split()))
for _ in range(iin()):
    n=iin()
    if n==1:print(ans)
    ans1=range(1,n+1)
    ch1=0
    ch=0
    nn=n
    print(n//2,n-n//2,*ans1,flush=True)
    n//=2
    ans=iin()
    ans1=range(1,nn+1)
    while n>1:
        if ch==4:break
        h=n//2
        print(h,nn-h,*ans1,flush=True)
        stdout.flush()
        x=iin()
        if x==-1:exit()
        ans=max(ans,x)
        n//=2
        ch+=1
    ch=0
    n=nn
    while n>1:
        if ch==4:break
        h=nn-n//2
        print(h,nn-h,*ans1,flush=True)
        stdout.flush()
        x=iin()
        if x==-1:exit()
        ans=max(ans,x)
        n//=2
        ch+=1

    print(-1,ans)


"""
NTC here
"""
from sys import setcheckinterval,stdin,setrecursionlimit
setcheckinterval(1000)
setrecursionlimit(10**6)

iin=lambda :int(stdin.readline())
lin=lambda :list(map(int,stdin.readline().split()))
for _ in range(iin()):
    ans=0
    n=iin()
    if n==1:print(ans)
    nn=n
    ans1=range(1,n+1)
    while n>1:
        h=n//2
        print(h,nn-h,*ans1,flush=True)
        ans=max(ans,iin())
        n//=2
    print(-1,ans)


"""
NTC here
"""
from sys import setcheckinterval,setrecursionlimit,stdout
setcheckinterval(1000)
setrecursionlimit(10**6)

iin=lambda :int(input())
lin=lambda :list(map(int,input().split()))
for _ in range(iin()):
    n=iin()
    if n==1:print(ans)
    ans1=range(1,n+1)
    ch=4
    nn=n
    print(n//2,n-n//2,*ans1,flush=True)
    ans=iin()
    ans1=range(1,nn+1)
    s1,s2=0,0
    if n>3:
        h=n//4
        ans2=0
        for i in range(4):
            l=range(i*h+1,i*h+h+1)
            if i==3:
                l=range(i*h+1,n+1)
            r=[j for j in range(1,n+1) if j not in l ]
            print(len(l),len(r),*l,*r,flush=True)
            stdout.flush()
            x=iin()
            if x>ans2:
                s1=i*h+1
                s2=i*h+h+1
            ans2=max(x,ans2)
    while s2-s1>1:
        if ch==9:break
        l=s2-s1+1
        h1=range(s1,l//2+1)
        h2=range(l//2+1,s2+1)
        a1=[j for j in range(1,n+1) if j not in h1 ]
        a2=[j for j in range(1,n+1) if j not in h2 ]
        print(len(h1),len(a1),*h1,*a1,flush=True)
        stdout.flush()
        x1=iin()
        print(len(h2),len(a2),*h2,*a2,flush=True)
        stdout.flush()
        x2=iin()
        if x1>x2:
            s1,s2=s1,l//2
        else:
            s1,s2=l//2+1,s2
        ch+=2

    print(-1,ans)


"""
NTC here
"""
from sys import setcheckinterval,setrecursionlimit,stdout
setcheckinterval(1000)
setrecursionlimit(10**6)

iin=lambda :int(input())
lin=lambda :list(map(int,input().split()))
for _ in range(iin()):
    n=iin()
    if n==1:print(ans)
    ans1=range(1,n+1)
    ch=0
    nn=n
    ans=0
    s1,s2=1,n
    while s2-s1+1>3:
        h=(s2-s1+1)//4
        ans2=0
        ss1,ss2=0,0
        for i in range(4):
            if ch==9:break
            l=range(s1+i*h,s1+i*h+h)
            if i==3:
                l=range(s1+i*h,s2+1)
            r=[j for j in range(1,nn+1) if j not in l ]
            print(len(l),len(r),*l,*r,flush=True)
            stdout.flush()
            x=iin()
            if x>ans2:
                ss1=i*h+1
                ss2=i*h+h+1
            ans2=max(x,ans2)
            ch+=1
        ans=max(ans2,ans)
        n//=4
        s1,s2=ss1,ss2
    else:
        for i in range(s1,s2+1):
            if ch==9:break
            l=[i]
            r=[j for j in range(1,nn+1) if j not in l]
            print(len(l),len(r),*l,*r,flush=True)
            stdout.flush()
            x=iin()
            ans=max(ans,x)
            ch+=1

    print(-1,ans)


"""
NTC here
"""
from sys import setcheckinterval,stdin,setrecursionlimit
setcheckinterval(1000)
setrecursionlimit(10**6)

iin=lambda :int(stdin.readline())
lin=lambda :list(map(int,stdin.readline().split()))
for _ in range(iin()):
    ans=0
    n=iin()
    if n==1:print(ans)
    nn=n
    ans1=range(1,n+1)
    while n>1:
        h=n//2
        print(h,nn-h,*ans1,flush=True)
        ans=max(ans,iin())
        n//=2
    print(ans)


"""
NTC here
"""
from sys import setcheckinterval,setrecursionlimit,stdout
setcheckinterval(1000)
setrecursionlimit(10**6)

iin=lambda :int(input())
lin=lambda :list(map(int,input().split()))
for _ in range(iin()):
    ans=0
    n=iin()
    if n==1:print(ans)
    nn=n
    ans1=range(1,n+1)
    ch=0
    while n>1:
        if ch==8:break
        h=n//2
        print(h,nn-h,*ans1,flush=True)
        stdout.flush()
        x=iin()
        if x==-1:exit()
        ans=max(ans,x)
        n//=2
        ch+=1

    print(-1,ans)


from sys import stdout

t = int(input())
for i in range(t):
    dists = []
    n = int(input())
    for j in range(1, 9):
        k = 2 ** j
        cur_k1 = [i for i in range(1, n + 1) if i % k >= k // 2]
        cur_k2 = [i for i in range(1, n + 1) if i % k < k // 2]
        if not cur_k1:
            break
        print(len(cur_k1), len(cur_k2), *cur_k1, *cur_k2)
        stdout.flush()
        dists.append(int(input()))
    print(-1, max(dists))
    stdout.flush()


import math
t=int(input())
for u in range(t):
    n=int(input())
    query=math.ceil(math.log2(n))
    bins=[bin(i+1)[::-1]+"0000000000" for i in range(n)]
    maxi=0
    for i in range(query):
        first=[]
        sec=[]
        for j in range(n):
            if bins[j][i]=="1":
                first.append(str(j+1))
            else:
                sec.append(str(j+1))
        print(str(len(first))+" "+str(len(sec))+" "+" ".join(first)+" "+" ".join(sec))
        k=int(input())
        maxi=max(maxi,k)
    print("-1 "+str(maxi))


from sys import *

t = int(input())

for xxx in range(t):
	n = int(input())
	max1, q = -1, 1

	while q < n:
		ver = {i for i in range(1, n + 1)}
		ans = set()

		for q1 in range(0, n, 2 * q):

			for q2 in range(q):

				if q1 + q2 + 1 > n:
					break

				ans.add(q1 + q2 + 1)

		ver -= ans

		print(len(ans), len(ver), *ans, *ver)
		stdout.flush()

		x = int(input())

		if x == -1:
			exit(0)
		max1 = max(max1, x)

		q *= 2

	print(-1, max1)
	stdout.flush()


from sys import stdout

def solve():
	n = int(input())
	ans = 0
	for i in range(7):
		a1 = list()
		a2 = list()
		for k in range(n):
			if (k & (2 ** i)):
				a1 += [k + 1]
			else:
				a2 += [k + 1]
		if (len(a1) == 0 or len(a2) == 0):
			break
		print (len(a1), len(a2), ' '.join([str(i) for i in a1]), ' '.join([str(i) for i in a2]), sep = ' ')
		stdout.flush()
		ans = max(ans, int(input()))
	print ('-1', ans, sep = ' ')
	stdout.flush()

t = int(input())
for i in range(t):
	solve()


n = int(input())
answer = 0
for i in range(0, 8):
    a = set()
    b = set()
    mask = 1 << i
    for j in range(1, n + 1):
        if mask & j:
            a.add(j)
        else:
            b.add(j)
    print('{} {} {} {}'.format(len(a), len(b), ' '.join(a), ' '.join(b)))
    answer = max(answer, int(input()))
print('{} {}'.format(-1, answer))


n = int(input())
answer = 0
for i in range(0, 8):
    a = set()
    b = set()
    mask = 1 << i
    for j in range(1, n + 1):
        if mask & j:
            a.add(j)
        else:
            b.add(j)
    print('{} {} {} {}'.format(len(a), len(b), ' '.join(str(i) for i in a), ' '.join(str(i) for i in b)))
    answer = max(answer, int(input()))
print('{} {}'.format(-1, answer))


t = int(input())
for _ in range(t):
    n = int(input())
    answer = 0
    for i in range(0, 8):
        a = set()
        b = set()
        mask = 1 << i
        for j in range(1, n + 1):
            if mask & j:
                a.add(j)
            else:
                b.add(j)
        print('{} {} {} {}'.format(len(a), len(b), ' '.join(str(i) for i in a), ' '.join(str(i) for i in b)))
        raise ValueError("Cacat")
        answer = max(answer, int(input()))
    print('{} {}'.format(-1, answer))


t = int(input())
for _ in range(t):
    n = int(input())
    print('1 {} 1 {}'.format(n - 1, ' '.join(str(i) for i in range(2, n + 1))))
    aim = int(input())
    start = 2
    end = n
    while start != end:
        mid = (start + end) // 2
        a = [i for i in range(start, mid + 1)]
        print('1 {} 1 {}'.format(len(a), ' '.join(str(i) for i in a)))
        answer = int(input())
        if answer == aim:
            end = mid
        else:
            start = mid + 1

    a = [i for i in range(1, n + 1) if i != start]
    print('1 {} {} {}'.format(len(a), start, ' '.join(str(i) for i in a)))
    print('-1 {}'.format(input()))


t = int(input())
for _ in range(t):
    n = int(input())
    answer = 0
    power = 0
    while 1 << power < n:
        power += 1
    for i in range(0, power):
        a = set()
        b = set()
        mask = 1 << i
        for j in range(1, n + 1):
            if mask & j:
                a.add(j)
            else:
                b.add(j)
        print('{} {} {} {}'.format(len(a), len(b), ' '.join(str(i) for i in a), ' '.join(str(i) for i in b)))
        answer = max(answer, int(input()))
    print('{} {}'.format(-1, answer))


t = int(input())
for _ in range(t):
    n = int(input())
    answer = 0
    for i in range(0, 8):
        a = set()
        b = set()
        mask = 1 << i
        for j in range(1, n + 1):
            if mask & j:
                a.add(j)
            else:
                b.add(j)
        print('{} {} {} {}'.format(len(a), len(b), ' '.join(str(i) for i in a), ' '.join(str(i) for i in b)))
        if i == 1:
            raise ValueError
        answer = max(answer, int(input()))
    print('{} {}'.format(-1, answer))


t = int(input())
for _ in range(t):
    n = int(input())
    answer = 0
    for i in range(0, 8):
        a = set()
        b = set()
        mask = 1 << i
        for j in range(1, n + 1):
            if mask & j:
                a.add(j)
            else:
                b.add(j)
        print('{} {} {} {}'.format(len(a), len(b), ' '.join(str(i) for i in a), ' '.join(str(i) for i in b)))
        answer = max(answer, int(input()))
    print('{} {}'.format(-1, answer))


t = int(input())
for _ in range(t):
    n = int(input())
    print('1 {} 1 {}'.format(n - 1, ' '.join(str(i) for i in range(2, n + 1))))
    aim = int(input())
    start = 2
    end = n
    while start < end:
        mid = (start + end) // 2
        a = [i for i in range(start, mid)]
        b = [i for i in range(mid, end + 1)]
        print('1 {} 1 {}'.format(len(a), ' '.join(str(i) for i in a)))
        answer = int(input())
        if answer == aim:
            end = mid
        else:
            start = mid + 1

    a = [i for i in range(1, n) if i != start]
    print('1 {} {} {}'.format(len(a), start, ' '.join(str(i) for i in a)))
    print('-1 {}'.format(input()))


t = int(input())
for _ in range(t):
    n = int(input())
    answer = 0
    for i in range(0, 8):
        a = set()
        b = set()
        mask = 1 << i
        for j in range(1, n + 1):
            if mask & j:
                a.add(j)
            else:
                b.add(j)
        print('{} {} {} {}'.format(len(a), len(b), ' '.join(str(i) for i in a), ' '.join(str(i) for i in b)))
        if i == 4:
            raise ValueError
        answer = max(answer, int(input()))
    print('{} {}'.format(-1, answer))


t = int(input())
for _ in range(t):
    n = int(input())
    print('1 {} 1 {}'.format(n - 1, ' '.join(str(i) for i in range(2, n + 1))))
    aim = int(input())
    start = 2
    end = n
    while start != end:
        mid = (start + end + 1) // 2
        a = [i for i in range(start, mid)]
        b = [i for i in range(mid, end + 1)]
        print('1 {} 1 {}'.format(len(a), ' '.join(str(i) for i in a)))
        answer = int(input())
        if answer == aim:
            end = mid
        else:
            start = mid
    a = [i for i in range(1, n) if i != start]
    print('1 {} {} {}'.format(len(a), start, ' '.join(str(i) for i in a)))
    print('-1 {}'.format(input()))


#include <iostream>
#include<bits/stdc++.h>
using namespace std;

int main() {
	// your code goes here
	int n;
	cin>>n;
	vector<int>a(n),b(n),left(n,0),right(n,0);
	unordered_map<int,int>mil,mir;
	unordered_map<int,int>ml,mr;
	for(int i=0;i<n;i++){
		cin>>a[i];
		mil[a[i]-1]=(i);
	}
	for(int i=0;i<n;i++){
		cin>>b[i];
		mir[b[i]-1]=(i);
	}

	vector<pair<int,int>>arr;
	for(int i=0;i<n;i++){
		int x=mil[i],y=mir[i];
		arr.push_back(make_pair(x,y));
	}
	int ans1=0,ans2=0;
	//left shift->b[i] by 1
	for(int i=0;i<n;i++){
		int x=arr[i].first,y=arr[i].second;
		if(y==0){
			y=n-1;
			left[i]=x-y;
		}
		else{
			left[i]=x+1-y;
		}
		ml[left[i]]++;
		ans1=max(ans1,ml[left[i]]);
	}
	//right shift->b[i] by 1
	for(int i=0;i<n;i++){
		int x=arr[i].first,y=arr[i].second;
		if(y==n-1){
			right[i]=x;
		}
		else{
			right[i]=x-y-1;
		}
		mr[right[i]]++;
		ans2=max(ans2,mr[right[i]]);
	}
	cout<<max(ans1,ans2);
	return 0;
}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;

int main() {
	// your code goes here
	int n;
	cin>>n;
	vector<int>a(n),b(n),left(n,0),right(n,0);
	unordered_map<int,int>mil,mir;
	unordered_map<int,int>ml,mr;
	int ans=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		mil[a[i]-1]=(i);
	}
	for(int i=0;i<n;i++){
		cin>>b[i];
		if(a[i]==b[i]){
			ans++;
		}
		mir[b[i]-1]=(i);
	}

	vector<pair<int,int>>arr;
	for(int i=0;i<n;i++){
		int x=mil[i],y=mir[i];
		arr.push_back(make_pair(x,y));
	}
	int ans1=0,ans2=0;
	//left shift->b[i] by 1
	for(int i=0;i<n;i++){
		int x=arr[i].first,y=arr[i].second;
		if(y==0){
			y=n-1;
			left[i]=x-y;
		}
		else{
			left[i]=x+1-y;
		}
		ml[left[i]]++;
		ans1=max(ans1,ml[left[i]]);
	}
	//right shift->b[i] by 1
	for(int i=0;i<n;i++){
		int x=arr[i].first,y=arr[i].second;
		if(y==n-1){
			right[i]=x;
		}
		else{
			right[i]=x-y-1;
		}
		mr[right[i]]++;
		ans2=max(ans2,mr[right[i]]);
	}
	cout<<max(ans,max(ans1,ans2));
	return 0;
}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;

int main() {
	// your code goes here
	int n;
	cin>>n;
	vector<int>a(n),b(n),left(n,0),right(n,0);
	unordered_map<int,int>mil,mir;
	unordered_map<int,int>ml,mr;
	int ans=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		mil[a[i]-1]=(i);
	}
	for(int i=0;i<n;i++){
		cin>>b[i];
		if(a[i]==b[i]){
			ans++;
		}
		mir[b[i]-1]=(i);
	}

	vector<pair<int,int>>arr;
	for(int i=0;i<n;i++){
		int x=mil[i],y=mir[i];
		arr.push_back(make_pair(x,y));
	}
	int ans1=0,ans2=0;
	//left shift->b[i] by 1
	for(int i=0;i<n;i++){
		int x=arr[i].first,y=arr[i].second;
		if(y==0){
			y=n-1;
			left[i]=x-y;
		}
		else{
			left[i]=x+1-y;
		}
		if(left[i]<0){
			left[i]+=n;
		}
		ml[left[i]]++;
		ans1=max(ans1,ml[left[i]]);
	}
	//right shift->b[i] by 1
	for(int i=0;i<n;i++){
		int x=arr[i].first,y=arr[i].second;
		if(y==n-1){
			right[i]=x;
		}
		else{
			right[i]=x-y-1;
		}
		if(right[i]<0){
			right[i]+=n;
		}
		mr[right[i]]++;
		ans2=max(ans2,mr[right[i]]);
	}
	cout<<max(ans,max(ans1,ans2));
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long int
#define ld  long double
#define pb push_back
#define fi0(i,n) for(int i=0; i<n; i++)
#define fi1(i,n) for(int i=1; i<n; i++)
#define fll0(i,n) for(long long i=0; i<n; i++)
#define fll1(i,n) for(long long i=1; i<n; i++)
#define vll vector<long long>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvll vector<vector<long long>>
int main()
  {
     ll n;
     cin>>n;
     //ll x,y;
     vll a(n);
     vll b(n);
     fll0(i,n)   cin>>a[i];
     fll0(i,n)   cin>>b[i];
     vll v2;
     fll0(i,n)  v2.pb(b[i]);
     fll0(i,n)  v2.pb(b[i]);

     ll x=0;
     ll count=0, max=0;
     while(x<n)
       {
              fll0(i,n)
                {
                   if(a[i]==v2[i+x])  count++;
                }

             if(count>max)   max=count;
             x=x+1;
             count=0;
       }
      cout<<max<<endl;
  }


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long int
#define ld  long double
#define pb push_back
#define fi0(i,n) for(int i=0; i<n; i++)
#define fi1(i,n) for(int i=1; i<n; i++)
#define fll0(i,n) for(long long i=0; i<n; i++)
#define fll1(i,n) for(long long i=1; i<n; i++)
#define vll vector<long long>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvll vector<vector<long long>>
int main()
  {
     ll n;
     cin>>n;
     vll a(n), b(n);
     map<ll, ll> map1;
     fll0(i,n)
       {
            cin>>a[i];
            map1.insert(pair<ll, ll>(a[i], i));
       }
    vll v;
    fll0(i,n)
      {
           cin>>b[i];
           if(map1[b[i]]>i)  v.pb((n-1-map1[b[i]])+i+1);
           else v.pb(i-map1[b[i]]);
      }
    ll freq=1, count=1;
    sort(v.begin(), v.end());
    fll1(i,v.size())
      {
      	  if(i==v.size()-1)  {
      	  	if(v[i]==v[i-1])  count++;
      	  	if(count>freq)  freq=count;
      	  	count=1;
      	  }
      	 else {
          if(v[i]==v[i-1])  count++;
          else  {
                    if(count>freq)  freq=count;
                    count=1;
          }}
      }
    cout<<freq<<endl;
  }


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long int
#define ld  long double
#define pb push_back
#define fi0(i,n) for(int i=0; i<n; i++)
#define fi1(i,n) for(int i=1; i<n; i++)
#define fll0(i,n) for(long long i=0; i<n; i++)
#define fll1(i,n) for(long long i=1; i<n; i++)
#define vll vector<long long>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvll vector<vector<long long>>
int main()
  {
     ll n;
     cin>>n;
     ll x,y;
     vll a(n);
     vll b(n);
     fll0(i,n)   {cin>>a[i];
                  if(a[i]==1)  x=i;}
     fll0(i,n)   { cin>>b[i];
                   if(b[i]==1)  y=i;}
     vll v1, v2;
     fll0(i,n)  v1.pb(a[i]);
     fll0(i,n)  v1.pb(a[i]);
     fll0(i,n)  v2.pb(b[i]);
     fll0(i,n)  v2.pb(b[i]);
     vll v3, v4;
     for(ll i=x; i<x+n; i++)  v3.pb(v1[i]);
     for(ll i=y; i<y+n; i++)  v4.pb(v2[i]);
     ll count=0;
     fll0(i,n)
       {
                 if(v3[i]==v4[i])  count++;
       }
      cout<<count<<endl;
  }


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long int
#define ld  long double
#define pb push_back
#define fi0(i,n) for(int i=0; i<n; i++)
#define fi1(i,n) for(int i=1; i<n; i++)
#define fll0(i,n) for(long long i=0; i<n; i++)
#define fll1(i,n) for(long long i=1; i<n; i++)
#define vll vector<long long>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvll vector<vector<long long>>
int main()
  {
     ll n;
     cin>>n;
     vll a(n), b(n);
     map<ll, ll> map1;
     fll0(i,n)
       {
            cin>>a[i];
            map1.insert(pair<ll, ll>(a[i], i));
       }
    vll v;
    fll0(i,n)
      {
           cin>>b[i];
           if(map1[b[i]]>i)  v.pb((n-1-map1[b[i]])+i+1);
           else v.pb(i-map1[b[i]]);
      }
    ll freq=0, count=1;
    sort(v.begin(), v.end());
    fll1(i,v.size())
      {
      	  if(i==v.size()-1)  {
      	  	if(v[i]==v[i-1])  count++;
      	  	if(count>freq)  freq=count;
      	  	count=1;
      	  }
      	 else {
          if(v[i]==v[i-1])  count++;
          else  {
                    if(count>freq)  freq=count;
                    count=1;
          }}
      }
    cout<<freq<<endl;
  }


#include<bits/stdc++.h>
#define ls rt<<1
#define rs rt<<1|1
using namespace std;

typedef  long long ll;
typedef pair<int,int> pii;
const ll N=114514+10;
const ll p=1e9+7;
const ll inf=0x3f3f3f3f3f3f3f3f;
double pi=acos(-1);

int a[201000],b[201000];
int vis[201000];
int main()
{
//    int t;
//    scanf("%d",&t);
//    while(t--)
//    {
        int n;
        scanf("%d",&n);
        vis[0]=0;
        for(int i=1; i<=n; i++)
        {
            vis[i]=0;
            scanf("%d",&a[i]);
        }
        for(int i=1; i<=n; i++)
        {
            int x;
            scanf("%d",&x);
            a[x]=i;
//
        }
        int ans=0;
        for(int i=1;i<=n;i++)
        {
            vis[(b[i]-i+n)%n]++;
            ans=max(ans, vis[(b[i]-i+n)%n]);
        }
        cout<<ans<<endl;
//    }
}


#include<bits/stdc++.h>
#define ls rt<<1
#define rs rt<<1|1
using namespace std;

typedef  long long ll;
typedef pair<int,int> pii;
const ll N=114514+10;
const ll p=1e9+7;
const ll inf=0x3f3f3f3f3f3f3f3f;
double pi=acos(-1);

int a[201000],b[201000];
int vis[201000];
int main()
{
//    int t;
//    scanf("%d",&t);
//    while(t--)
//    {
        int n;
        scanf("%d",&n);
        vis[0]=0;
        for(int i=1; i<=n; i++)
        {
            vis[i]=0;
            scanf("%d",&a[i]);
        }
        for(int i=1; i<=n; i++)
        {
            int x;
            scanf("%d",&x);
            b[i]=a[x];
//            cout<<a[i]<<endl;
        }
        int ans=0;
        for(int i=1;i<=n;i++)
        {
            vis[(b[i]-i+n)%n]++;
            ans=max(ans, vis[(b[i]-i+n)%n]);
        }
        cout<<ans<<endl;
//    }
}


#include<bits/stdc++.h>
#define ls rt<<1
#define rs rt<<1|1
using namespace std;

typedef  long long ll;
typedef pair<int,int> pii;
const ll N=114514+10;
const ll p=1e9+7;
const ll inf=0x3f3f3f3f3f3f3f3f;
double pi=acos(-1);

int a[201000],b[201000];
int vis[201000];
int main()
{
//    int t;
//    scanf("%d",&t);
//    while(t--)
//    {
        int n;
        scanf("%d",&n);
        vis[0]=0;
        for(int i=1; i<=n; i++)
        {
            vis[i]=0;
            scanf("%d",&a[i]);
        }
        for(int i=1; i<=n; i++)
        {
            int x;
            scanf("%d",&x);
            b[i]=a[x];
        }
        int ans=0;
        for(int i=1;i<=n;i++)
        {
            vis[(a[i]-i+n)%n]++;
            ans=max(ans, vis[(a[i]-i+n)%n]);
        }
        cout<<ans<<endl;
//    }
}


#include<bits/stdc++.h>
#define ls rt<<1
#define rs rt<<1|1
using namespace std;

typedef  long long ll;
typedef pair<int,int> pii;
const ll N=114514+10;
const ll p=1e9+7;
const ll inf=0x3f3f3f3f3f3f3f3f;
double pi=acos(-1);

int a[201000],b[201000];
int vis[201000];
int rk[201000];
int main()
{
//    int t;
//    scanf("%d",&t);
//    while(t--)
//    {
        int n;
        scanf("%d",&n);
        vis[0]=0;
        for(int i=1; i<=n; i++)
        {
            vis[i]=0;
            scanf("%d",&a[i]);
            rk[a[i]]=i;
        }
        for(int i=1; i<=n; i++)
        {
            int x;
            scanf("%d",&x);
            a[rk[x]]=i;
//
        }
        int ans=0;
        for(int i=1;i<=n;i++)
        {
//            cout<<a[i]<<endl;
            vis[(a[i]-i+n)%n]++;
            ans=max(ans, vis[(a[i]-i+n)%n]);
        }
        cout<<ans<<endl;
//    }
}


#include<bits/stdc++.h>
#define ls rt<<1
#define rs rt<<1|1
using namespace std;

typedef  long long ll;
typedef pair<int,int> pii;
const ll N=114514+10;
const ll p=1e9+7;
const ll inf=0x3f3f3f3f3f3f3f3f;
double pi=acos(-1);

int a[201000],b[201000];
int vis[201000];
int main()
{
//    int t;
//    scanf("%d",&t);
//    while(t--)
//    {
        int n;
        scanf("%d",&n);
        vis[0]=0;
        for(int i=1; i<=n; i++)
        {
            vis[i]=0;
            scanf("%d",&a[i]);
        }
        for(int i=1; i<=n; i++)
        {
            int x;
            scanf("%d",&x);
            a[x]=i;
//
        }
        int ans=0;
        for(int i=1;i<=n;i++)
        {
            vis[(a[i]-i+n)%n]++;
            ans=max(ans, vis[(a[i]-i+n)%n]);
        }
        cout<<ans<<endl;
//    }
}


//
//  main.cpp
//  rotationMatching
//
//  Created by Mnet on 6/10/20.
//  Copyright © 2020 Mnet. All rights reserved.
//

#include <iostream>
using namespace std;

int main(int argc, const char * argv[]) {
    // insert code here...
    int size;
    cin>>size;
    int leftRotations[size];
    for(int i=0; i<size; i++){
        leftRotations[i] = 0;
    }

    int a[size];
    for(int i=0; i<size; i++){
        cin>>a[i];
    }

    int b[size];
    for(int i=0; i<size; i++){
        cin>>b[i];
    }

    for(int i=0; i<size; i++){
        for(int j=0; j<size; j++){
            if(a[i] == b[j]){
                if(i==j){
                    leftRotations[0]++;
                }
                if(i<j){
                    leftRotations[j-i]++;
                }
                if(j<i){
                    leftRotations[size-(i-j)]++;
                }
                break;
            }
        }
    }

    int maxPairs = 0;
    for(int i=0; i<size; i++){
        if(leftRotations[i] > maxPairs){
            maxPairs = leftRotations[i];
        }
    }

    cout<<maxPairs;

    return 0;
}


//
//  main.cpp
//  rotationMatching
//
//  Created by Mnet on 6/10/20.
//  Copyright © 2020 Mnet. All rights reserved.
//

#include <iostream>
using namespace std;

int main(int argc, const char * argv[]) {
    // insert code here...
    int size;
    cin>>size;
    int leftRotations[size];
    int rightRotations[size];
    for(int i=0; i<size; i++){
        leftRotations[i] = 0;
        rightRotations[i] = 0;
    }

    int a[size];
    for(int i=0; i<size; i++){
        cin>>a[i];
    }

    int b[size];
    for(int i=0; i<size; i++){
        cin>>b[i];
    }

    for(int i=0; i<size; i++){
        for(int j=0; j<size; j++){
            if(a[i] == b[j]){
                if(i==j){
                    leftRotations[0]++;
                }
                if(i<j){
                    leftRotations[j-i]++;
                }
                if(j<i){
                    leftRotations[size-(i-j)]++;
                }
//                leftRotations[j-i]++;
            }
        }
//        for(int j=i; j>=0; j--){
//            if(a[i] == b[j]){
//                rightRotations[i-j]++;
//            }
//        }
    }

    int maxPairs = 0;
    for(int i=0; i<size; i++){
        if(leftRotations[i] > maxPairs){
            maxPairs = leftRotations[i];
        }
        if(rightRotations[i] > maxPairs){
            maxPairs = rightRotations[i];
        }
    }

    cout<<maxPairs;

    return 0;
}


//
//  main.cpp
//  rotationMatching
//
//  Created by Mnet on 6/10/20.
//  Copyright © 2020 Mnet. All rights reserved.
//

#include <iostream>
using namespace std;

int main(int argc, const char * argv[]) {
    // insert code here...
    int size;
    cin>>size;
    int leftRotations[size];
    int elementsAIndex[size];
    int elementsBIndex[size];
    for(int i=0; i<size; i++){
        leftRotations[i] = 0;
        elementsAIndex[i] = 0;
        elementsBIndex[i] = 0;
    }

    int a[size];
    for(int i=0; i<size; i++){
        cin>>a[i];
    }

    int b[size];
    for(int i=0; i<size; i++){
        cin>>b[i];
    }

    for(int i=0; i<size; i++){
        elementsAIndex[a[i]-1] = i;
        elementsBIndex[b[i]-1] = i;
    }

//    for(int i=0; i<size; i++){
//        cout<<elementsAIndex[i]<<" ";
//    }
//    cout<<endl;
//    for(int i=0; i<size; i++){
//        cout<<elementsBIndex[i]<<" ";
//    }

    for(int i=0; i<size; i++){
        int a1 = elementsAIndex[i];
        int b1 = elementsBIndex[i];

        if(a1==b1){
            leftRotations[0]++;
        }
        if(a1<b1){
            leftRotations[b1-a1]++;
        }
        if(b1<a1){
            leftRotations[size-(a1-b1)]++;
        }
    }
//
//    for(int i=0; i<size; i++){
//        for(int j=0; j<size; j++){
//            if(a[i] == b[j]){
//                if(i==j){
//                    leftRotations[0]++;
//                }
//                if(i<j){
//                    leftRotations[j-i]++;
//                }
//                if(j<i){
//                    leftRotations[size-(i-j)]++;
//                }
//                break;
//            }
//        }
//    }

    int maxPairs = 0;
    for(int i=0; i<size; i++){
        if(leftRotations[i] > maxPairs){
            maxPairs = leftRotations[i];
        }
    }

    cout<<maxPairs;

    return 0;
}


//
//  main.cpp
//  swap
//
//  Created by Mnet on 6/10/20.
//  Copyright © 2020 Mnet. All rights reserved.
//

#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
    // insert code here...

    int totalTests;
    cin>>totalTests;
    for(int i=0; i<totalTests; i++){
        int size;
        cin>>size;
        int a[size];
        for(int j=0; j<size; j++){
            cin>>a[j];
        }
        int type;
        bool hasFirstType = false;
        bool hasSecondType = false;
        for(int j=0; j<size; j++){
            cin>>type;
            if(type == 0){
                hasFirstType = true;
            }else{
                hasSecondType = true;
            }
        }
        if(hasFirstType && hasSecondType){
            cout<<"Yes\n";
        }else{
            int previousValue = a[0];
            int currentValue;
            bool alreadySorted = true;
            for(int j=1; j<size; j++){
                currentValue = a[j];
                if(previousValue>currentValue){
                    alreadySorted = false;
                    cout<<"No\n";
                    break;
                }
            }
            if(alreadySorted){
                cout<<"Yes\n";
            }
        }

    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
int main() {
      ull n;
      cin >> n;
      vector <int> a(n);
      vector <int> b(n);
      int mina=0,minb=0;
      for(int i=0;i<n;i++){
        cin >> a[i];
      }
      for(int i=0;i<n-1;i++){
        a.push_back(a[i]);
      }
      for(int i=0;i<n;i++){
        cin >> b[i];
      }
      int max=0,c=0;
      for(int k=0;k<n;k++){
        c=0;
        for(int i=0;i<n;i++){
          if(a[i+k]==b[i])c++;
        }
        if(c>n/2){
          max=c;
          break;
        }
        if(max<c)max=c;
      }
      cout << max << "\n";

}


#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef pair <ull,ull> pos;
int main() {
      ull n;
      cin >> n;
      vector <pos> a(n);
      vector <pos> b(n);
      for(int i=1;i<n+1;i++){
        int aa;
        cin >> aa;
        a[i-1].first=aa;
        a[i-1].second=i;
      }
      for(int i=1;i<n+1;i++){
        int aa;
        cin >> aa;
        b[i-1].first=aa;
        b[i-1].second=i;
      }
sort(a.begin(),a.end());
sort(b.begin(),b.end());
vector <int> v(n);
for(int i=0;i<n;i++){
  if(b[i].second>a[i].second){
    v[i]=n - (b[i].second - a[i].second)%n;
  }
  else v[i]=(a[i].second - b[i].second)%n;
}

sort(v.begin(),v.end());
int c=1;int max=0;
for(int i=1;i<n;i++){
  if(v[i]!=v[i-1]){
    if(c>max)max=c;
    c=1;
  }
  c++;
}
if(max==0)max=c+1;
cout << max-1;
}


#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
int main() {
      ull n;
      cin >> n;
      vector <int> a(n);
      vector <int> b(n);
      int mina=0,minb=0;
      for(int i=0;i<n;i++){
        cin >> a[i];
      }
      for(int i=0;i<n-1;i++){
        a.push_back(a[i]);
      }
      for(auto x:a)cout << x << " ";
      for(int i=0;i<n;i++){
        cin >> b[i];
      }
      int max=0,c=0;
      for(int k=0;k<n;k++){
        c=0;
        for(int i=0;i<n;i++){
          if(a[i+k]==b[i])c++;
        }
        if(max<c)max=c;
      }
      cout << max << "\n";

}


#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef pair <ull,ull> pos;
int main() {
      ull n;
      cin >> n;
      vector <pos> a(n);
      vector <pos> b(n);
      for(int i=1;i<n+1;i++){
        int aa;
        cin >> aa;
        a[i-1].first=aa;
        a[i-1].second=i;
      }
      for(int i=1;i<n+1;i++){
        int aa;
        cin >> aa;
        b[i-1].first=aa;
        b[i-1].second=i;
      }
sort(a.begin(),a.end());
sort(b.begin(),b.end());
vector <int> v(n);
for(int i=0;i<n;i++){
  if(b[i].second>a[i].second){
    v[i]=n - (b[i].second - a[i].second)%n;
  }
  else v[i]=(a[i].second - b[i].second)%n;
}
//for(auto x:v)cout << x;
sort(v.begin(),v.end());
int c=1;int max=0;
for(int i=1;i<n;i++){
  if(v[i]!=v[i-1]){
    if(c>max)max=c;
    c=1;
  }
  c++;
}
if(max==0)max=c;
cout << max;
}


#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
int main() {
      ull n;
      cin >> n;
      vector <int> a(n);
      vector <int> b(n);
      int mina=0,minb=0;
      for(int i=0;i<n;i++){
        cin >> a[i];
      }
      for(int i=0;i<n-1;i++){
        a.push_back(a[i]);
      }
      for(int i=0;i<n;i++){
        cin >> b[i];
      }
      int max=0,c=0;
      for(int k=0;k<n;k++){
        c=0;
        for(int i=0;i<n;i++){
          if(a[i+k]==b[i])c++;
        }
        if(c==1){
          max=1;
          break;
        }
        if(c>=n/2){
          max=c;
          break;
        }
        if(max<c)max=c;
      }
      cout << max << "\n";

}


#include <bits/stdc++.h>

using namespace std;

typedef unsigned long long ull;

typedef pair <ull,ull> pos;

int main() {

ull n;

cin >> n;

vector <pos> a(n);

vector <pos> b(n);

for(int i=1;i<n+1;i++){

int aa;

cin >> aa;

a[i-1].first=aa;

a[i-1].second=i;

}

for(int i=1;i<n+1;i++){

int aa;

cin >> aa;

b[i-1].first=aa;

b[i-1].second=i;

}

sort(a.begin(),a.end());

sort(b.begin(),b.end());

vector <int> v(n);

for(int i=0;i<n;i++){

if(b[i].second>a[i].second){

v[i]=n - (b[i].second - a[i].second)%n;

}

else v[i]=(a[i].second - b[i].second)%n;

}

for(auto x:v)cout << x;

int c=1;int max=0;

for(int i=1;i<n;i++){

if(v[i]!=v[i-1]){

if(c>max)max=c;

c=1;

}

else c++;

}

if(max==0)max=c;

cout << max;

}


#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
int main() {
      ull n;
      cin >> n;
      vector <int> a(n);
      vector <int> b(n);
      int mina=0,minb=0;
      for(int i=0;i<n;i++){
        cin >> a[i];
      }
      for(int i=0;i<n-1;i++){
        a.push_back(a[i]);
      }
      for(int i=0;i<n;i++){
        cin >> b[i];
      }
      int max=0,c=0;
      for(int k=0;k<n;k++){
        c=0;
        for(int i=0;i<n;i++){
          if(a[i+k]==b[i])c++;
        }
        if(c==5){
          max=5;
          break;
        }
        if(max<c)max=c;
      }
      cout << max << "\n";

}


#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
int main() {
      ull n;
      cin >> n;
      vector <int> a(n);
      vector <int> b(n);
      int mina=0,minb=0;
      for(int i=0;i<n;i++){
        cin >> a[i];
      }
      for(int i=0;i<n-1;i++){
        a.push_back(a[i]);
      }
      for(int i=0;i<n;i++){
        cin >> b[i];
      }
      int max=0,c=0;
      for(int k=0;k<n;k++){
        c=0;
        for(int i=0;i<n;i++){
          if(a[i+k]==b[i])c++;
        }
        if(c==n){
          max=n;
          break;
        }
        if(max<c)max=c;
      }
      cout << max << "\n";

}


#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef pair <ull,ull> pos;
int main() {
      ull n;
      cin >> n;
      vector <pos> a(n);
      vector <pos> b(n);
      for(int i=1;i<n+1;i++){
        int aa;
        cin >> aa;
        a[i-1].first=aa;
        a[i-1].second=i;
      }
      for(int i=1;i<n+1;i++){
        int aa;
        cin >> aa;
        b[i-1].first=aa;
        b[i-1].second=i;
      }
sort(a.begin(),a.end());
sort(b.begin(),b.end());
vector <int> v(n);
for(int i=0;i<n;i++){
  if(b[i].second>a[i].second){
    v[i]=n - (b[i].second - a[i].second)%n;
  }
  else v[i]=(a[i].second - b[i].second)%n;
}
//for(auto x:v)cout << x;
sort(v.begin(),v.end());
int c=1;int max=0;
for(int i=1;i<n;i++){
  if(v[i]!=v[i-1]){
    if(c>max)max=c;
    c=1;
  }
  else c++;
}
if(max==0)max=c;
cout << max;
}


#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef pair <ull,ull> pos;
int main() {
      ull n;
      cin >> n;
      vector <pos> a(n);
      vector <pos> b(n);
      for(int i=1;i<n+1;i++){
        int aa;
        cin >> aa;
        a[i-1].first=aa;
        a[i-1].second=i;
      }
      for(int i=1;i<n+1;i++){
        int aa;
        cin >> aa;
        b[i-1].first=aa;
        b[i-1].second=i;
      }
sort(a.begin(),a.end());
sort(b.begin(),b.end());
vector <int> v(n);
for(int i=0;i<n;i++){
  if(b[i].second>a[i].second){
    v[i]=n - (b[i].second - a[i].second)%n;
  }
  else v[i]=(a[i].second - b[i].second)%n;
}

sort(v.begin(),v.end());
int c=1;int max=0;
for(int i=1;i<n;i++){
  if(v[i]!=v[i-1]){
    if(c>max)max=c;
    c=1;
  }
  c++;
}
if(max==0)max=c;
cout << max;
}


#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
int main() {
      ull n;
      cin >> n;
      vector <int> a(n);
      vector <int> b(n);
      int mina=0,minb=0;
      for(int i=0;i<n;i++){
        cin >> a[i];
        if(a[i]>a[mina])mina=i;
      }
      for(int i=0;i<n;i++){
        cin >> b[i];
        if(b[i]>b[minb])minb=i;
      }
      vector <int> aa(n);
      vector <int> bb(n);
      int u=0;
      for(int i=mina;i<n;i++){
        aa[u]=a[i];
        u++;
      }
      for(int i=0;i<mina;i++){
        aa[u]=a[i];
        u++;
      }
      u=0;
      for(int i=minb;i<n;i++){
        bb[u]=b[i];
        u++;
      }
      for(int i=0;i<minb;i++){
        bb[u]=b[i];
        u++;
      }
      int count=0;
      for(int i=0;i<n;i++){
        if(aa[i]==bb[i])count++;
      }
      cout << count << "\n";

}


#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
int main() {
      ull n;
      cin >> n;
      vector <int> a(n);
      vector <int> b(n);
      int mina=0,minb=0;
      for(int i=0;i<n;i++){
        cin >> a[i];
        if(a[i]<a[mina])mina=i;
      }
      for(int i=0;i<n;i++){
        cin >> b[i];
        if(b[i]<b[minb])minb=i;
      }
      vector <int> aa(n);
      vector <int> bb(n);
      int u=0;
      for(int i=mina;i<n;i++){
        aa[u]=a[i];
        u++;
      }
      for(int i=0;i<mina;i++){
        aa[u]=a[i];
        u++;
      }
      u=0;
      for(int i=minb;i<n;i++){
        bb[u]=b[i];
        u++;
      }
      for(int i=0;i<minb;i++){
        bb[u]=b[i];
        u++;
      }
      int count=0;
      for(int i=0;i<n;i++){
        if(aa[i]==bb[i])count++;
      }
      cout << count << "\n";

}


#include <bits/stdc++.h>

using namespace std;

typedef unsigned long long ull;

typedef pair <ull,ull> pos;

int main() {

ull n;

cin >> n;

vector <pos> a(n);

vector <pos> b(n);

for(int i=1;i<n+1;i++){

int aa;

cin >> aa;

a[i-1].first=aa;

a[i-1].second=i;

}

for(int i=1;i<n+1;i++){

int aa;

cin >> aa;

b[i-1].first=aa;

b[i-1].second=i;

}

sort(a.begin(),a.end());

sort(b.begin(),b.end());

vector <int> v(n);

for(int i=0;i<n;i++){

if(b[i].second>a[i].second){

v[i]=n - (b[i].second - a[i].second)%n;

}

else v[i]=(a[i].second - b[i].second)%n;

}

int c=1;int max=0;

for(int i=1;i<n;i++){

if(v[i]!=v[i-1]){

if(c>max)max=c;

c=1;

}

else c++;

}

if(max==0)max=c;

cout << max;

}


# include <bits/stdc++.h>

using namespace std;
const int N=2e5+10;
int a[2*N],b[N];
int main()
{
    int n,sum=0,mn=-1;
    cin >> n;
    for(int i=1;i<=n;++i)
    {
        cin >> a[i];
        a[i+n]=a[i];
    }
    for(int i=1;i<=n;++i)   cin >> b[i];
   for(int i=1;i<=n;++i)
   {
       for(int j=1;j<=n;++j)
       {
           if(a[i+j-1]==b[j])
           {
              ++sum;
           }
       }
       mn=max(sum,mn);
       sum=0;
   }
   printf("%d\n",mn);
}


# include <bits/stdc++.h>

using namespace std;
const int N=2e5+10;
int a[2*N],b[N];
int main()
{
    int n,sum=0,mn=1;
    cin >> n;
    for(int i=1;i<=n;++i)
    {
        cin >> a[i];
        a[i+n]=a[i];
    }
    for(int i=1;i<=n;++i)   cin >> b[i];
   for(int i=1;i<=n;++i)
   {
        if(a[i]==b[1])
        {
            ++sum;
            for(int j=2;j<=n;++j)
            {
                if(a[i+j-1]==b[j])
                {
                    sum++;
                }
            }
            mn=max(mn,sum);
            sum=0;
        }
   }
   printf("%d\n",mn);
}


# include <bits/stdc++.h>

using namespace std;
const int N=2e5+10;
int a[2*N],b[N];
int main()
{
    int n,sum=0,mn=-1;
    cin >> n;
    for(int i=1;i<=n;++i)
    {
        cin >> a[i];
        a[i+n]=a[i];
    }
    for(int i=1;i<=n;++i)   cin >> b[i];
   for(int i=1;i<=n;++i)
   {
        if(a[i]==b[1])
        {
            ++sum;
            for(int j=2;j<=n;++j)
            {
                if(a[i+j-1]==b[j])
                {
                    sum++;
                }
            }
            mn=max(mn,sum);
            sum=0;
        }
   }
   printf("%d\n",mn);
}


# include <bits/stdc++.h>

using namespace std;
const int N=2e5+10;
int a[N],b[N];
int vis[N];
int sum[N];
int main()
{
    int n,mn=-1;
    cin >> n;
    for(int i=1;i<=n;++i)
    {
        cin >> a[i];
        vis[a[i]]=i;
    }
    for(int i=1;i<=n;++i)
    {
        cin >> b[i];
        int p=vis[b[i]]-i;
        if(p>=0)
        {
            sum[p]++;
        }
        else
        {
            sum[p+n]++;
        }
    }
    for(int i=0;i<n;++i)
    {
        mn=max(sum[i],mn);
    }
   printf("%d\n",mn);
}


# include <bits/stdc++.h>

using namespace std;
const int N=2e5+10;
int a[2*N],b[N];
int main()
{
    int n,sum=0,mn;
    cin >> n;
    for(int i=1;i<=n;++i)
    {
        cin >> a[i];
        a[i+n]=a[i];
    }
    for(int i=1;i<=n;++i)   cin >> b[i];
   for(int i=1;i<=2*n;++i)
   {
       sum=0;
        if(a[i]==b[1])
        {
            ++sum;
            for(int j=2;j<=n;++j)
            {
                if(i+j-1>2*n)   break;
                if(a[i+j-1]==b[j])
                {
                    sum++;
                }
            }
            mn=max(mn,sum);
        }
   }
   printf("%d\n",mn);
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=50005;
int a,b[maxn],pos[maxn],num[maxn];
int main()
{
    ios::sync_with_stdio(false);
    int t,n;
        cin>>n;
        for(int i=1;i<=n;i++)
        {
            cin>>a;
            pos[a]=i;
        }
        for(int i=1;i<=n;i++)
        {
            cin>>b[i];
            if(pos[b[i]]>=i)
                num[pos[b[i]-i]]++;
            else
                num[n+pos[b[i]]-i]++;
        }
        int ans=-1;
        for(int i=1;i<=n;i++)
            ans=max(ans,num[i]);
        cout<<ans<<endl;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=50005;
int a,b[maxn],pos[maxn],num[maxn];
int main()
{
    ios::sync_with_stdio(false);
    int t,n;
        cin>>n;
        for(int i=1;i<=n;i++)
        {
            cin>>a;
            pos[a]=i;
        }
        for(int i=1;i<=n;i++)
        {
            cin>>b[i];
            if(pos[b[i]]>=i)
                num[pos[b[i]-i]]++;
            else
                num[n+pos[b[i]]-i]++;
        }
        int ans=-1;
        for(int i=0;i<=n;i++)
            ans=max(ans,num[i]);
        cout<<ans<<endl;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=50005;
int b[maxn],pos[maxn],num[maxn];
int main()
{
    ios::sync_with_stdio(false);
    int n;
        cin>>n;
        int a;
        for(int i=1;i<=n;i++)
        {
            cin>>a;
            pos[a]=i;
        }
        for(int i=1;i<=n;i++)
        {
            cin>>b[i];
            if(pos[b[i]]>=i)
                num[pos[b[i]]-i]++;
            else
                num[n+pos[b[i]]-i]++;
        }
        int ans=-1;
        for(int i=0;i<=n;i++)
            ans=max(ans,num[i]);
        cout<<ans<<endl;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=200005;
int b[maxn],pos[maxn],num[maxn];
int main()
{
    ios::sync_with_stdio(false);
    int n;
        cin>>n;
        int a;
        for(int i=1;i<=n;i++)
        {
            cin>>a;
            pos[a]=i;
        }
        for(int i=1;i<=n;i++)
        {
            cin>>b[i];
            if(pos[b[i]]>=i)
                num[pos[b[i]]-i]++;
            else
                num[n+pos[b[i]]-i]++;
        }
        int ans=-1;
        for(int i=0;i<=n;i++)
            ans=max(ans,num[i]);
        cout<<ans<<endl;
}


#include <iostream>
#include <algorithm>
#include <cmath>
#include <climits>
#include <vector>
#include <cstring>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <string.h>
#include <iomanip>
using namespace std;
#define int long long
#define ull unsigned long long
#define F first
#define S second
#define nl "\n"
#define ld long double
#define div 1000000007
#define pi 3.14159265358979323846
#define pb push_back

void solve()
{
    int n;cin>>n;
    int a[n],b[n];
    map<int,int> m1,m2;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        m1.insert({a[i],i+1});
    }
    for(int i=0;i<n;i++)
    {
        cin>>b[i];
        m2.insert({b[i],i+1});
    }
    map<int,int> d;
    for(auto it:m1)
    {
        int v1=m1[it.first];
        int v2=m2[it.first];
        d[v2-v1]++;
    }
    int ans=0;
    for(auto it:d)
    {
        int dis=it.first;int v=it.second;
        int temp=v;
        if(dis>=0)
        {
            temp+=d[n-dis];
        }
        else
        {
            temp+=d[n+dis];
        }
        ans=max(ans,temp);
    }
    cout<<ans<<nl;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);

    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


#include <iostream>
#include <algorithm>
#include <cmath>
#include <climits>
#include <vector>
#include <cstring>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <string.h>
#include <iomanip>
using namespace std;
#define int long long
#define ull unsigned long long
#define F first
#define S second
#define nl "\n"
#define ld long double
#define div 1000000007
#define pi 3.14159265358979323846
#define pb push_back

void solve()
{
    int n;cin>>n;
    int a[n],b[n];
    map<int,int> m1,m2;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        m1.insert({a[i],i+1});
    }
    for(int i=0;i<n;i++)
    {
        cin>>b[i];
        m2.insert({b[i],i+1});
    }
    map<int,int> d;
    for(auto it:m1)
        d[it.second-it.first]++;
    int ans=0;
    for(auto it:d)
    {
        int dis=it.first;int v=it.second;
        int temp=v;
        temp+=d[n-dis];
        ans=max(ans,temp);
    }
    cout<<ans<<nl;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);

    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


#include <iostream>
#include <algorithm>
#include <cmath>
#include <climits>
#include <vector>
#include <cstring>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <string.h>
#include <iomanip>
using namespace std;
#define int long long
#define ull unsigned long long
#define F first
#define S second
#define nl "\n"
#define ld long double
#define div 1000000007
#define pi 3.14159265358979323846
#define pb push_back

void solve()
{
    int n;cin>>n;
    int a[n],b[n];
    map<int,int> m1,m2;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        m1.insert({a[i],i+1});
    }
    for(int i=0;i<n;i++)
    {
        cin>>b[i];
        m2.insert({b[i],i+1});
    }
    map<int,int> d;
    for(auto it:m1)
    {
        int v1=m1[it.first];
        int v2=m2[it.first];
        d[v2-v1]++;
    }
    int ans=0;
    for(auto it:d)
    {
        int dis=it.first;int v=it.second;
        int temp=v;
        if(dis>=0)
        {
            temp+=d[dis-n];
        }
        else
        {
            temp+=d[n+dis];
        }
        ans=max(ans,temp);
    }
    cout<<ans<<nl;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);

    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


#include <iostream>
#include <algorithm>
#include <cmath>
#include <climits>
#include <vector>
#include <cstring>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <string.h>
#include <iomanip>
using namespace std;
#define int long long
#define ull unsigned long long
#define F first
#define S second
#define nl "\n"
#define ld long double
#define div 1000000007
#define pi 3.14159265358979323846
#define pb push_back
const int N=200001;
int c[N],pos[N];
void solve()
{
    int n;cin>>n;
    int a[n+1],b[n+1];
    for(int i=1;i<=n;i++)
        cin>>a[i];
    for(int i=1;i<=n;i++)
        cin>>b[i];
    for(int i=1;i<=n;i++)
        c[b[i]]=i;
    for(int i=1;i<=n;i++)
    {
        int v=c[a[i]];
        a[i]=v;pos[v]=i;
    }
    int ans=0;
    map<int,int> m;
    for(int i=1;i<=n;i++)
    {
        int d=(i-pos[i]+n)%n;
        m[d]++;
    }
    for(auto it:m)
    {
        ans=max(ans,it.S);
    }
    cout<<ans<<nl;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);

    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


#include <iostream>
#include <algorithm>
#include <cmath>
#include <climits>
#include <vector>
#include <cstring>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <string.h>
#include <iomanip>
using namespace std;
#define int long long
#define ull unsigned long long
#define F first
#define S second
#define nl "\n"
#define ld long double
#define div 1000000007
#define pi 3.14159265358979323846
#define pb push_back

void solve()
{
    int n;cin>>n;
    int a[n],b[n];
    map<int,int> m1,m2;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        m1.insert({a[i],i+1});
    }
    for(int i=0;i<n;i++)
    {
        cin>>b[i];
        m2.insert({b[i],i+1});
    }
    map<int,int> d;
    for(auto it:m1)
        d[it.second-it.first]++;
    int ans=0;
    for(auto it:d)
    {
        int dis=it.first;int v=it.second;
        int temp=0;
        for(auto it2:d)
        {
            int z=it2.first;
            if(z+dis>=n)
                z+=dis-n;
            else
                z+=dis;
            if(z==0)
                temp+=(it2.second);
        }
        ans=max(ans,temp);
    }
    cout<<ans<<nl;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);

    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


#include<cstdio>
using namespace std;
int abs(int x)
{
	if(x<0)return -x;
	return x;
}
int max(int x,int y)
{
	if(x>y)return x;
	return y;
}
int a[200005],b[200005],dis[200005],mp[200005];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&b[i]);
		mp[b[i]]=i;
	}
	for(int i=1;i<=n;i++)
	{
		dis[(n+a[i]-mp[i])%n]++;
	}
	int ans=0;
	for(int i=0;i<=n+1;i++)
	{
		ans=max(ans,dis[i]);
	}
	printf("%d\n",ans);
	return 0;
}


#include<cstdio>
using namespace std;
int abs(int x)
{
	if(x<0)return -x;
	return x;
}
int max(int x,int y)
{
	if(x>y)return x;
	return y;
}
int a[200005],b[200005],dis[200005],mp[200005];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&b[i]);
		mp[b[i]]=i;
	}
	for(int i=1;i<=n;i++)
	{
		dis[(n+a[i]-mp[i])%n]++;
	}
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		ans=max(ans,dis[i]);
	}
	if(n==1)printf("1\n");
	else
	printf("%d\n",ans);
	return 0;
}


#include<cstdio>
using namespace std;
int abs(int x)
{
	if(x<0)return -x;
	return x;
}
int max(int x,int y)
{
	if(x>y)return x;
	return y;
}
int a[200005],b[200005],dis[200005],mp0[200005],mp[200005];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		mp0[a[i]]=i;
	}
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&b[i]);
		mp[b[i]]=i;
	}
	for(int i=1;i<=n;i++)
	{
		dis[(n+mp0[i]-mp[i])%n]++;
	}
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		ans=max(ans,dis[i]);
	}
	if(n==1)printf("1\n");
	else
	printf("%d\n",ans);
	return 0;
}


#include<cstdio>
using namespace std;
int abs(int x)
{
	if(x<0)return -x;
	return x;
}
int max(int x,int y)
{
	if(x>y)return x;
	return y;
}
int a[200005],b[200005],dis[200005],mp[200005];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		mp[a[i]]=i;
	}
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&b[i]);
		mp[b[i]]=i;
	}
	for(int i=1;i<=n;i++)
	{
		dis[(n+a[i]-mp[i])%n]++;
	}
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		ans=max(ans,dis[i]);
	}
	if(n==1)printf("1\n");
	else
	printf("%d\n",ans);
	return 0;
}


#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int ara1[200001],ara2[200001],ara3[200001],ara4[200001];

int main()
{
    int n;
    cin >> n;
    int i,d,s = 0,c,st1,st2,l = 0, maximum = 0;
    for(i = 0; i < n; i++)
    {
        cin >> d;
        ara1[d] = i;
    }
    for(i = 0; i < n; i++)
    {
        cin >> d;
        ara2[d] = i;
    }
    st1 = ara1[1];
    st2 = ara2[1];
    for(i = 1;i <= n;i++)
    {
        if(ara1[i] >= st1)
        {
            ara1[i] -= st1;
        }
        else
        {
            ara1[i] = ara1[i] + n - st1;
        }
        if(ara2[i] >= st2)
        {
            ara2[i] -= st2;
        }
        else
        {
            ara2[i] = ara2[i] + n - st2;
        }
        if((ara1[i] - ara2[i]) < 0)
        {
            d = abs(ara1[i] - ara2[i]);
            ara4[d]++;
        }
        else
        {
            ara3[ara1[i] - ara2[i]]++;
        }
    }
    for(i = 0;i <= n;i++)
    {
        l = 0;
        if(ara4[i] > l)
        {
            l = ara4[i];
        }
        if(ara3[i] > l)
        {
            l = ara3[i];
        }
        if(l > maximum)
        {
            maximum = l;
        }
    }
    cout << maximum << endl;
    return 0;
}


#include<iostream>
#include<iomanip>
#include<algorithm>
using namespace std;
int ara1[200001],ara2[200001],ara3[200001],ara4[200001];

int main()
{
    int n;
    cin >> n;
    int i,d,s = 0,c,st1,st2,l = 0, maximum = 0;
    for(i = 0; i < n; i++)
    {
        cin >> d;
        ara1[d] = i;
    }
    for(i = 0; i < n; i++)
    {
        cin >> d;
        ara2[d] = i;
    }
    st1 = ara1[1];
    st2 = ara2[1];
    for(i = 1;i <= n;i++)
    {
        if(ara1[i] >= st1)
        {
            ara1[i] -= st1;
        }
        else
        {
            ara1[i] = ara1[i] + n - st1;
        }
        if(ara2[i] >= st2)
        {
            ara2[i] -= st2;
        }
        else
        {
            ara2[i] = ara2[i] + n - st2;
        }
        if((ara1[i] - ara2[i]) < 0)
        {
            ara4[abs(ara1[i] - ara2[i])]++;
        }
        else
        {
            ara3[ara1[i] - ara2[i]]++;
        }
    }
    for(i = 0;i <= n;i++)
    {
        l = 0;
        if(ara4[i] > l)
        {
            l = ara4[i];
        }
        if(ara3[i] > l)
        {
            l = ara3[i];
        }
        if(l > maximum)
        {
            maximum = l;
        }
    }
    cout << maximum << endl;
    return 0;
}


#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int ara1[200001],ara2[200001],ara3[200001],ara4[200001];

int main()
{
    int n;
    cin >> n;
    int i,d,s = 0,c,st1,st2,l = 0, maximum = 0;
    for(i = 0; i < n; i++)
    {
        cin >> d;
        ara1[d] = i;
    }
    for(i = 0; i < n; i++)
    {
        cin >> d;
        ara2[d] = i;
    }
    st1 = ara1[1];
    st2 = ara2[1];
    for(i = 1;i <= n;i++)
    {
        if(ara1[i] >= st1)
        {
            ara1[i] -= st1;
        }
        else
        {
            ara1[i] = ara1[i] + n - st1;
        }
        if(ara2[i] >= st2)
        {
            ara2[i] -= st2;
        }
        else
        {
            ara2[i] = ara2[i] + n - st2;
        }
        if((ara1[i] - ara2[i]) < 0)
        {
            ara4[abs(ara1[i] - ara2[i])]++;
        }
        else
        {
            ara3[ara1[i] - ara2[i]]++;
        }
    }
    for(i = 0;i <= n;i++)
    {
        l = 0;
        if(ara4[i] > l)
        {
            l = ara4[i];
        }
        if(ara3[i] > l)
        {
            l = ara3[i];
        }
        if(l > maximum)
        {
            maximum = l;
        }
    }
    cout << maximum << endl;
    return 0;
}


#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
long long int ara1[200001],ara2[200001],ara3[200001],ara4[200001];

int main()
{
    int n;
    cin >> n;
    long long int i,d,s = 0,c,st1,st2,l = 0, maximum = 0;
    for(i = 0; i < n; i++)
    {
        cin >> d;
        ara1[d] = i;
    }
    for(i = 0; i < n; i++)
    {
        cin >> d;
        ara2[d] = i;
    }
    st1 = ara1[1];
    st2 = ara2[1];
    for(i = 1;i <= n;i++)
    {
        if(ara1[i] >= st1)
        {
            ara1[i] -= st1;
        }
        else
        {
            ara1[i] = ara1[i] + n - st1;
        }
        if(ara2[i] >= st2)
        {
            ara2[i] -= st2;
        }
        else
        {
            ara2[i] = ara2[i] + n - st2;
        }
        if((ara1[i] - ara2[i]) < 0)
        {
            ara4[abs(ara1[i] - ara2[i])]++;
        }
        else
        {
            ara3[ara1[i] - ara2[i]]++;
        }
    }
    for(i = 0;i <= n;i++)
    {
        l = 0;
        if(ara4[i] > l)
        {
            l = ara4[i];
        }
        if(ara3[i] > l)
        {
            l = ara3[i];
        }
        if(l > maximum)
        {
            maximum = l;
        }
    }
    cout << maximum << endl;
    return 0;
}


#include<iostream>
using namespace std;
int ara1[200001],ara2[200001];

int main()
{
    int n;
    cin >> n;
    int i,d,s = 1,st1,st2;
    for(i = 0;i < n;i++)
    {
        cin >> d;
        ara1[d] = i;
    }
    for(i = 0;i < n;i++)
    {
        cin >> d;
        ara2[d] = i;
    }
    st1 = ara1[1];
    st2 = ara2[1];
    for(i = 2;i <= n;i++)
    {
        if(ara1[i] > st1)
        {
            ara1[i] -= st1;
        }
        else
        {
            ara1[i] = ara1[i] + n - st1;
        }
        if(ara2[i] > st2)
        {
            ara2[i] -= st2;
        }
        else
        {
            ara2[i] = ara2[i] + n - st2;
        }
        if(ara1[i] == ara2[i])
        {
            s++;
        }
    }
    cout << s << endl;
    return 0;
}


#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int ara1[200001],ara2[200001],ara3[400001];

int main()
{
    int n;
    cin >> n;
    int i,d,s = 0,c,st1,st2,l = 0, maximum = 0;
    for(i = 0; i < n; i++)
    {
        cin >> d;
        ara1[d] = i;
    }
    for(i = 0; i < n; i++)
    {
        cin >> d;
        ara2[d] = i;
    }
    st1 = ara1[1];
    st2 = ara2[1];
    for(i = 1;i <= n;i++)
    {
        if(ara1[i] >= st1)
        {
            ara1[i] -= st1;
        }
        else
        {
            ara1[i] = ara1[i] + n - st1;
        }
        if(ara2[i] >= st2)
        {
            ara2[i] -= st2;
        }
        else
        {
            ara2[i] = ara2[i] + n - st2;
        }
        if((ara1[i] - ara2[i]) < 0)
        {
            d = ara1[i] - ara2[i] + n;
            ara3[d]++;
        }
        else
        {
            ara3[ara1[i] - ara2[i]]++;
        }
    }
    for(i = 0;i <= n;i++)
    {
        l = 0;
        if(ara3[i] > l)
        {
            l = ara3[i];
        }
        if(l > maximum)
        {
            maximum = l;
        }
    }
    cout << maximum << endl;
    return 0;
}


#include "bits/stdc++.h"
using namespace std;
typedef long long int ll;
int main(){
    ll tt = 1;
    //cin >> tt;
    while(tt--){
        int n;
        cin >> n;
        int a[n],b[n];
        int pos[n];
        for(int i = 0; i < n; i++){
            cin >> a[i];
            pos[a[i]-1] = i;
        }
        for(int i = 0; i < n; i++){
            cin >> b[i];
        }
        bool visited[n] = {false};
        int max_match = 1;
        for(int i = 0; i < n; i++){
            if(visited[i])
                continue;
            visited[i] = true;
            int match = 1;
            for(int j = i+1; ;j++){
                if(j%n == i)
                    break;
                if(b[j%n] == a[(pos[b[i]-1]+j-i)%n]) {
                    //cout << i << ' ' << b[j%n] << '&';
                    visited[j%n] = true;
                    match++;
                }
            }
            if(match > max_match){
                max_match = match;
                if(max_match == n)
                    break;
            }
        }
        cout << max_match;
    }
    return 0;
}


#include "bits/stdc++.h"
using namespace std;
typedef long long int ll;
int main(){
    ll tt = 1;
    //cin >> tt;
    while(tt--){
        int n;
        cin >> n;
        int a[n],b[n];
        int pos[n];
        for(int i = 0; i < n; i++){
            cin >> a[i];
            pos[a[i]-1] = i;
        }
        for(int i = 0; i < n; i++){
            cin >> b[i];
        }
        //bool visited[n] = {false};
        int max_match = 1;
        for(int i = 0; i < n; i++){
            int match = 1;
            for(int j = i+1; ;j++){
                if(j%n == i)
                    break;
                if(b[j%n] == a[(pos[b[i]-1]+j-i)%n]) {
                    //cout << i << ' ' << b[j%n] << '&';
                    //visited[j%n] = true;
                    match++;
                }
            }
            if(match > max_match){
                max_match = match;
                if(max_match == n)
                    break;
            }
        }
        cout << max_match;
    }
    return 0;
}


#include "bits/stdc++.h"
using namespace std;
typedef long long int ll;
int main(){
    ll tt = 1;
    //cin >> tt;
    while(tt--){
        int n;
        cin >> n;
        int a[n],b[n];
        int pos[n];
        for(int i = 0; i < n; i++){
            cin >> a[i];
            pos[a[i]-1] = i;
        }
        for(int i = 0; i < n; i++){
            cin >> b[i];
        }
        bool visited[n] = {false};
        int max_match = 1;
        for(int i = 0; i < n; i++){
            if(visited[i])
                continue;
            int match = 1;
            for(int j = (i+1)%n; ; j = (j+1)%n){
                if(j == i)
                    break;
                if(b[j%n] == a[(pos[b[i]-1]+j%n-i)%n]) {
                    //cout << i << ' ' << b[j%n] << '&';
                    visited[j%n] = true;
                    match++;
                }
            }
            if(match > max_match)
                max_match = match;
        }
        cout << max_match;
    }
    return 0;
}


#include "bits/stdc++.h"
using namespace std;
int main(){
    int n;
    cin >> n;
    int a[n],b[n],pos[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
        pos[a[i]-1] = i;
    }
    map<int,int> m;
    for(int i = 0; i < n; i++){
        cin >> b[i];
        m[(i-pos[b[i]-1]+n)%n]++;
    }
    int ans = 1;
    for(auto &it:m)
        ans = max(ans, it.second);
    cout << ans << '\n';
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define nl '\n'
#define gcd __gcd
#define nset __builtin_popcount
#define pb push_back
#define btoe(x) x.begin(), x.end()
#define trim_chains(x) (x).resize(unique(btoe(x)) - (x).begin())
#define remove_dups(x) sort(btoe(x)); trim_chains(x);
#define rep(i, a, b)  for (int i = int(a); i <= int(b); i++)
#define nrep(i, a, b) for (int i = int(a); i >= int(b); i--)
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL)

using ll  = long long;
using ull = unsigned long long;
using vi  = vector<int>;
using vl  = vector<long>;
using vll = vector<ll>;
using vb  = vector<bool>;
using vvb = vector<vb>;
using vvi = vector<vector<int> >;
using ii  = pair<int, int>;
using vii = vector<ii>;
using vs  = vector<string>;
using msi = map<string, int>;
using iss = istringstream;

int match(vi &a, vi &b, int p)
{
    int n = a.size();
    int cnt = 0;
    rep(i, 0, n-1)
        cnt += (a[i] == b[(i + p)%n]);
    return cnt;
}

int main()
{
    FASTIO;
    int n; cin >> n;
    vi a(2*n), b(2*n);
    rep(i, 0, n-1) cin >> a[i];
    rep(i, 0, n-1) cin >> b[i];

    vi idx(n + 1);
    rep(i, 0, n-1) idx[a[i]] = i;

    rep(i, 0, n-1) b[i] = idx[b[i]] + 1;
    rep(i, 0, n-1) b[n + i] = b[i];

    vi ans(2*n, 1);
    rep(i, 1, 2*n - 1) {
        if(a[i] > a[i-1]) ans[i] += ans[i-1];
    }

    int hi = 0;
    rep(i, 0, 2*n-1) hi = max(hi, ans[i]);

    cout << hi << nl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define nl '\n'
#define gcd __gcd
#define nset __builtin_popcount
#define pb push_back
#define btoe(x) x.begin(), x.end()
#define trim_chains(x) (x).resize(unique(btoe(x)) - (x).begin())
#define remove_dups(x) sort(btoe(x)); trim_chains(x);
#define rep(i, a, b)  for (int i = int(a); i <= int(b); i++)
#define nrep(i, a, b) for (int i = int(a); i >= int(b); i--)
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL)

using ll  = long long;
using ull = unsigned long long;
using vi  = vector<int>;
using vl  = vector<long>;
using vll = vector<ll>;
using vb  = vector<bool>;
using vvb = vector<vb>;
using vvi = vector<vector<int> >;
using ii  = pair<int, int>;
using vii = vector<ii>;
using vs  = vector<string>;
using msi = map<string, int>;
using iss = istringstream;

int match(vi &a, vi &b, int p)
{
    int n = a.size();
    int cnt = 0;
    rep(i, 0, n-1)
        cnt += (a[i] == b[(i + p)%n]);
    return cnt;
}

int main()
{
    FASTIO;
    int n; cin >> n;
    vi a(n), b(n);
    rep(i, 0, n-1) cin >> a[i];
    rep(i, 0, n-1) cin >> b[i];

    int beg = 0, end = n-1;
    int ans = 0;
    while(beg <= end) {
        int mid = (beg + end) / 2;
        int cnt = match(a, b, mid);
        ans = max(ans, cnt);

        if(mid == n-1) break;

        if(match(a, b, mid+1) >= cnt) beg = mid+1;
        else end = mid - 1;
    }

    cout << ans << nl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define nl '\n'
#define gcd __gcd
#define nset __builtin_popcount
#define pb push_back
#define btoe(x) x.begin(), x.end()
#define trim_chains(x) (x).resize(unique(btoe(x)) - (x).begin())
#define remove_dups(x) sort(btoe(x)); trim_chains(x);
#define rep(i, a, b)  for (int i = int(a); i <= int(b); i++)
#define nrep(i, a, b) for (int i = int(a); i >= int(b); i--)
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL)

using ll  = long long;
using ull = unsigned long long;
using vi  = vector<int>;
using vl  = vector<long>;
using vll = vector<ll>;
using vb  = vector<bool>;
using vvb = vector<vb>;
using vvi = vector<vector<int> >;
using ii  = pair<int, int>;
using vii = vector<ii>;
using vs  = vector<string>;
using msi = map<string, int>;
using iss = istringstream;

int match(vi &a, vi &b, int p)
{
    int n = a.size();
    int cnt = 0;
    rep(i, 0, n-1)
        cnt += (a[i] == b[(i + p)%n]);
    return cnt;
}

int main()
{
    FASTIO;
    int n; cin >> n;
    vi a(n), b(n);
    rep(i, 0, n-1) cin >> a[i];
    rep(i, 0, n-1) cin >> b[i];

    int beg = 0, end = n-1;
    int ans = 0;

    while(beg <= end) {
        int mid = (beg + end) / 2;
        int cnt = match(a, b, mid);
        ans = max(ans, cnt);

        if(mid == n-1) break;

        if(match(a, b, mid+1) >= cnt) beg = mid+1;
        else end = mid - 1;
    }

    beg = 0, end = n-1;

    while(beg <= end) {
        int mid = (beg + end) / 2;
        int cnt = match(a, b, mid);
        ans = max(ans, cnt);

        if(mid == n-1) break;

        if(match(a, b, mid+1) > cnt) beg = mid+1;
        else end = mid - 1;
    }

    cout << ans << nl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define nl '\n'
#define gcd __gcd
#define nset __builtin_popcount
#define pb push_back
#define btoe(x) x.begin(), x.end()
#define trim_chains(x) (x).resize(unique(btoe(x)) - (x).begin())
#define remove_dups(x) sort(btoe(x)); trim_chains(x);
#define rep(i, a, b)  for (int i = int(a); i <= int(b); i++)
#define nrep(i, a, b) for (int i = int(a); i >= int(b); i--)
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL)

using ll  = long long;
using ull = unsigned long long;
using vi  = vector<int>;
using vl  = vector<long>;
using vll = vector<ll>;
using vb  = vector<bool>;
using vvb = vector<vb>;
using vvi = vector<vector<int> >;
using ii  = pair<int, int>;
using vii = vector<ii>;
using vs  = vector<string>;
using msi = map<string, int>;
using iss = istringstream;

ll mod(ll x, ll M)
{
    ll res = x % M;
    return (res >= 0 ? res : res + M);
}

int main()
{
    FASTIO;
    int n; cin >> n;
    vi a(n), b(n);
    rep(i, 0, n-1) cin >> a[i];
    rep(i, 0, n-1) cin >> b[i];

    vi idx1(n + 1);
    vi idx2(n + 1);
    rep(i, 0, n-1) idx1[a[i]] = i;
    rep(i, 0, n-1) idx2[b[i]] = i;

    // rep(i, 1, n) cout << idx1[i] << ' '; cout << nl;
    // rep(i, 1, n) cout << idx2[i] << ' '; cout << nl;

    vi offcnt(n, 0);

    // rep(i, 1, n) cout << mod((idx2[i] - idx1[i]), n) << nl;
    rep(i, 1, n) offcnt[mod((idx2[i] - idx1[i]), n)]++;
    int ans = 0;
    rep(i, 0, n-1) ans = max(ans, offcnt[i]);
    cout << ans << nl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
int x,y=0;
map<int,int>m1,m2,m;
for(int i=0;i<n;i++)
cin>>x,m1[x]=i;
for(int i=0;i<n;i++)
cin>>x,m2[x]=i;
for(int i=1;i<=n;i++)
{x=m1[i]-m2[i];
if(x==-(n-1))x=1;
else if(x==n-1)x=-1;
m[x]++;
y=max(y,m[x]);
}
cout<<y<<endl;}


#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
int x,y=0,a;
map<int,int>m1,m2,m;
m1.clear(),m2.clear(),m.clear();
for(int i=1;i<=n;i++)
cin>>x,m1[x]=i;
for(int i=1;i<=n;i++)
{cin>>x,m2[x]=i;
a=m1[x]-m2[x];
if(a==-(n-1))a=1;
else if(a==n-1)a=-1;
m[a]++;
y=max(y,m[a]);}

cout<<y<<endl;}


#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
int x,y=0;
map<int,int>m1,m2,m;
for(int i=0;i<n;i++)
cin>>x,m1[x]=i;
for(int i=0;i<n;i++)
cin>>x,m2[x]=i;
for(int i=1;i<=n;i++)
{x=m1[i]-m2[i];
if(x<0)
x+=n;
m[x]++;
y=max(y,m[x]);
}
cout<<y<<endl;}


#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
int x,y=0,a,b;
map<int,int>m1,m2,m,m3;
for(int i=1;i<=n;i++)
cin>>x,m1[x]=i;
for(int i=1;i<=n;i++)
{cin>>x,m2[x]=i;
a=m1[x]-m2[x];
if(a>0)
b=n-a;
else if(a<0)
{b=a,a=n+b;}
else b=0;
m[a]++;
m3[b]++;
y=max(y,m[a]);
y=max(y,m3[b]);
}

cout<<y<<endl;}


#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
int x;
map<int,int>m1,m2,m;
for(int i=0;i<n;i++)
cin>>x,m1[x]=i;
for(int i=0;i<n;i++)
cin>>x,m2[x]=i;
for(int i=1;i<=n;i++)
{x=m1[i]-m2[i];
if(x==-(n-1))x=1;
else if(x==n-1)x=-1;
m[x]++;}
cout<<m.rbegin()->second<<endl;}


#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
int x,y=0;
map<int,int>m1,m2,m;
for(int i=1;i<=n;i++)
cin>>x,m1[x]=i;
for(int i=1;i<=n;i++)
cin>>x,m2[x]=i;
for(int i=1;i<=n;i++)
{x=m1[i]-m2[i];
if(x==-(n-1))x=1;
else if(x==n-1)x=-1;
m[x]++;
y=max(y,m[x]);
}
cout<<y<<endl;}


#include <bits/stdc++.h>

using namespace std;

#define ll long long

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);

    ll num, ans =0; cin >> num;

    vector<ll> vec(num+1);
    vector<ll> pos(num+1);
    vector<ll> vec2(num+1);

    map<ll,ll> mapa;

    for(ll i=1;i<=num;i++){
        cin >> vec[i];

        pos[vec[i]] = i;
    }

    for(ll i=1;i<=num;i++){
        cin >> vec2[i];
    }

    for(ll i = 1;i<=num;i++){
        ll sel = pos[vec2[i]]-i;
        if(sel<0)
            sel+=num    ;
        mapa[sel]++;
    }

    for(auto &it:mapa){
        ans = max(ans,it.second);
    }

    cout << ans << "\n";

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define ll long long

ll rl(vector<ll> a, vector<ll> b)
{
    ll val = 0;
    ll cont;

    for(ll j =0;j<a.size();j++){
        ll asd =0;
        for(ll i = 0;i<a.size();i++){
            if(a[j]==b[i]){
                cont = i;
                break;
            }
        }

        for(int i = 0;i<a.size();i++){
            if(a[(j+i)%a.size()]==b[(cont+i)%a.size()]){
                asd++;
            }
        }
        val = max(asd,val);
    }

    return val;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);

    ll n; cin >> n;

    vector<ll> a(n);
    vector<ll> b(n);

    for(ll i=0;i<n;i++){
        cin >> a[i];
    }
    for(ll i = 0; i<n;i++){
        cin >> b[i];
    }

    ll ans = rl(a, b);

    cout << ans << "\n";

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define ll long long

ll rl(vector<ll> a, vector<ll> b)
{
    ll val = 0;
    ll cont;

    for(ll i = 0;i<a.size();i++){
        if(a[0]==b[i]){
            cont = i;
            break;
        }
    }

    for(int i = 0;i<a.size();i++){
        if(a[i]==b[(cont+i)%a.size()]){
            val++;
        }
    }

    return val;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);

    ll n; cin >> n;

    vector<ll> a(n);
    vector<ll> b(n);

    for(ll i=0;i<n;i++){
        cin >> a[i];
    }
    for(ll i = 0; i<n;i++){
        cin >> b[i];
    }

    ll ans = rl(a, b);

    cout << ans << "\n";

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define ll long long

ll rl(vector<ll> a, vector<ll> b)
{
    ll val = 0;
    ll cont;

    ll lon = a.size();

    for(ll i = 0;i<lon;i++){
        if(a[0]==b[i]){
            cont = i;
            break;
        }
    }

    for(int i = 0;i<lon;i++){
        if(a[i]==b[(cont+i)%lon]){
            val++;
        }
    }

    return val;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);

    ll n; cin >> n;

    vector<ll> a(n);
    vector<ll> b(n);

    for(ll i=0;i<n;i++){
        cin >> a[i];
    }
    for(ll i = 0; i<n;i++){
        cin >> b[i];
    }

    ll ans = rl(a, b);

    cout << ans << "\n";

    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

using namespace std;
// #define int long long
mt19937 rnd(time(0));
typedef long long ll;
typedef long double ld;

// #define _GLIBCXX_DEBUG
#define f first
#define s second
#define pb push_back
#define pii pair<int, int>
#define vi vector<int>
#define int ll

void solve(){
	int n;
	cin >> n;
	int a[n];
	for (int i = 0; i < n; ++i) {
		int x;
		cin >> x;
		a[x - 1] = i;
	}
	int ans[n];
	memset(ans, 0, sizeof(ans));
	for (int i = 0; i < n; ++i) {
		int x;
		cin >> x;
		x--;
		if (i >= a[i])
			ans[i - a[i]]++;
		else
			ans[n - (i - a[i])]++;
	}
	cout << *max_element(ans, ans + n) << endl;
}

signed main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	int t = 1;
	while(t--){
		solve();
	}

	return 0;
}