class INPUT: def __init__(self): self._l=open(0).read().split() self._length=len(self._l) self._index=0 return def stream(self,k=1,f=int,f2=False): assert(-1 return left all #listを変数で受け取るとき、必ずlistをTrueにすること。 from collections import Counter def main(): p,q,r,K=pin(4) p%=10 q%=10 r%=10 A=[p,q,r] S=Counter() for i in range(K-3): t=(A[i]+A[i+1]+A[i+2])%10 #print(S[(A[i],A[i+1],A[i+2])]) if S[(A[i],A[i+1],A[i+2])]!=0: u=S[(A[i],A[i+1],A[i+2])]-1 loop=i-u left=K-i-1 v=left%loop print(A[u+v]) #print(A) #print(u,v) #print(i,len(A)) #print(left,loop) return S[(A[i],A[i+1],A[i+2])]=i+1 A.append(t) print(A[-1]) #print(A) return main()