#44193: python


suyueh (suyueh)

學校 : 不指定學校
編號 : 272111
來源 : [101.12.162.212]
最後登入時間 :
2024-11-10 22:20:41
f580. 2. 骰子 -- 2020年7月APCS | From: [111.242.18.129] | 發表日期 : 2024-11-11 19:16

n,m=map(int,input().split())
dices=[[-1]]+[[-1,3,5,1,2,6,4] for _ in range(n)]
def top(dice):
    return dice[3]
def front(dice):
    dice[1],dice[3],dice[6],dice[5]=dice[5],dice[1],dice[3],dice[6]
def right(dice):
    dice[2],dice[3],dice[4],dice[5]=dice[5],dice[2],dice[3],dice[4]
for i in range(m):
    a,b=map(int,input().split())
    if b>0: dices[a],dices[b]=dices[b],dices[a]#swap(dices[a],dices[b])
    elif b==-1: front(dices[a])
    elif b==-2: right(dices[a])
for i in range(1,n+1):
    print(top(dices[i]),end=' ')
print()
 
ZeroJudge Forum