N, K = map(int, input().split()) A = list(map(int, input().split())) C = list(map(int, input().split())) dp = [[0 for _ in range(N)] for _ in range(N)] for i in range(N): dp[i][i] = 1<>l)&q: dp[i][(i+k+1+j)%N] |= (p>>l)&q | (((p>>l)&q)<>l): dp[i][(i+k+1+j)%N] |= p&(q>>l) | ((p&(q>>l))<>l)&q: dp[(i-1-j)%N][(i+k)%N] |= (p>>l)&q | (((p>>l)&q)<>l): dp[(i-1-j)%N][(i+k)%N] |= p&(q>>l) | ((p&(q>>l))<j: ans = max(ans, S[j+1+N]-S[i]) else: ans = max(ans, S[j+1]-S[i]) print(ans)