#54292: 一個暴力的python解題方法(我也不確定好不好,反正能過)


woominytr (梧銘)


a=int(input())
b=int(input())
c=[]  
d=''
e=[(a-1)//2,(a-1)//2]  --> 中心點
f=0  -->  目前走了幾步
g=1    -->  步長
h=0  -->  每轉彎兩次加一步長
for _ in range(a):
    c.append(list(map(int,str(input()).split())))  --> 用兩層列表存放整個陣列
    #先y後x

for i in range(a**2):
    d=d+str(c[e[1]][e[0]])  -->  紀錄

    if b%4==1:  -->  移動(注意方向)
        e[1]-=1
    elif b%4==2:
        e[0]+=1
    elif b%4==3:
        e[1]+=1
    else:
        e[0]-=1

    f+=1  -->  按照前面說明方式改方向
    if f== g:
        f=0
        h+=1
        b+=1
        if h ==2:
            g+=1
            h=0
        
print(d)