#23479: 李俊hank


ernestii260928@gmail.com (黃冠穎)

School : No School
ID : 124082
IP address : [114.46.146.125]
Last Login :
2021-12-11 19:49:21
c292. APCS2017-0304-3數字龍捲風 -- 2017年3月APCS | From: [101.137.72.40] | Post Date : 2020-11-20 21:26

yalei yalei 
# z=[[4,1,2],[3,0,5],[6,7,8]]
# z=[[3, 4, 2, 1, 4], [4, 2, 3, 8, 9], [2, 1, 9, 5, 6], [4, 2, 3, 7, 8], [1, 2, 6, 4, 3]]
# x=5
# d=0
x=int(input())
d=int(input())
z=[]
for i in range(x):
  z.append(list(map(int,input().split())))
t=0 #2
c=1
cn=0
nowx=int((x+1)/2)-1
nowy=int((x+1)/2)-1
h=""
def a(d):
    global t,cn,c
    cn+=1
    if cn>=c: #==
        cn=0
        t+=1
        if t==2:
            t=0
            c+=1
        if d==0:
            return 1
        elif d==1:
            return 2
        elif d==2:
            return 3
        elif d==3:
            return 0
    return d
for i in range(x*x):
    print(nowx,nowy)#
    h+=str(z[nowx][nowy])
    if d==1:
        nowx-=1
    elif d==2:
        nowy+=1
    elif d==3:
        nowx+=1
    elif d==0:
        nowy-=1
    d=a(d)
print(h)
 
ZeroJudge Forum