Buggy python submission (verdict: Time Limit Exceeded):
import random
D=int(input())
c=input().split()
c=[int(a) for a in c]
S=[]
for _ in range(D):
    s=input().split()
    s=[int(a) for a in s]
    S.append(s)
answers=[]
scores=[]
numbers=[]
for _ in range(1500000):
    d=random.randrange(0,26,1)
    q=random.randrange(0,26,1)
    numbers.append([d,q])
whole=sum(c)
suuji=1
T=[]
while suuji<=365:
    T.append(random.randrange(0,26,1))
    suuji+=1
for m in range(1500000):
    anss=[]
    ans = 0
    held = [0 for _ in range(26)]
    e=numbers[m][0]
    q=numbers[m][1]
    a=T[e]
    T[e]=q
    wholes=0
    for d in range(D):
        s = S[d]
        place = T[d]
        ans += s[place]
        wholes+=whole
        wholes-=c[place]*((d+1)-held[place])
        held[place] = d + 1
        ans-=wholes
    scores.append(ans)
    answers.append(T)
saidai=max(scores)
basho=scores.index(saidai)

answer=answers[basho]
for answer_ in answer:
    print(answer_+1)


Fixed submission:
D=int(input())
c=input().split()
c=[int(a) for a in c]
S=[]
for _ in range(D):
    s=input().split()
    s=[int(a) for a in s]
    S.append(s)

for d in range(D):
    if d%27==0:
        print(20)
    else:
        print(d%27)

Buggy python submission (verdict: Runtime Error):
import random
D=int(input())
c=input().split()
c=[int(a) for a in c]
S=[]
for _ in range(D):
    s=input().split()
    s=[int(a) for a in s]
    S.append(s)
answers=[]
scores=[]
M=10
numbers=[]
for _ in range(M):
    d=random.randrange(0,26,1)
    q=random.randrange(0,26,1)
    numbers.append([d,q])
whole=sum(c)
number=1
suuji=1
T=[]
while suuji<=365:
    T.append(number)
    number+=1
    suuji+=1
    if number==27:
        number=1
for m in range(M):
    anss=[]
    ans = 0
    held = [0 for _ in range(26)]
    e=numbers[m][0]-1
    q=numbers[m][1]-1
    a=T[e]
    T[e]=q
    wholes=0
    for d in range(D):
        s = S[d]
        place = T[d]
        ans += s[place]
        wholes+=whole
        wholes-=c[place]*((d+1)-held[place])
        held[place] = d + 1
        ans-=wholes
        scores.append(ans)
    answers.append(T)
saidai=max(scores)
basho=scores.index(saidai)
answer=answers[basho]
for answer_ in answer:
    print(answer_)
    

Fixed submission:
D=int(input())
c=input().split()
c=[int(a) for a in c]
S=[]
for _ in range(D):
    s=input().split()
    s=[int(a) for a in s]
    S.append(s)

for d in range(D):
    if d%27==0:
        print(20)
    else:
        print(d%27)

Buggy python submission (verdict: Runtime Error):
D=int(input())
c=input().split()
c=[int(a) for a in c]
S=[]
for _ in range(D):
    s=input().split()
    s=[int(a) for a in s]
    S.append(s)
T=[]
for _ in range(D):
    t=int(input())-1
    T.append(t)

for d in range(D):
    if d%27==0:
        print(20)
    else:
        print(d%27)
        

Fixed submission:
D=int(input())
c=input().split()
c=[int(a) for a in c]
S=[]
for _ in range(D):
    s=input().split()
    s=[int(a) for a in s]
    S.append(s)

for d in range(D):
    if d%27==0:
        print(20)
    else:
        print(d%27)

Buggy python submission (verdict: Runtime Error):
D=int(input())
c=input().split()
c=[int(a) for a in c]
S=[]
for _ in range(D):
    s=input().split()
    s=[int(a) for a in s]
    S.append(s)
T=[]
for _ in range(D):
    t=int(input())-1
    T.append(t)
M=int(input())
numbers=[]
for _ in range(M):
    d,q=map(int,input().split())
    numbers.append([d,q])
for m in range(M):
    ans = 0
    held = [0 for _ in range(26)]
    e=numbers[m][0]-1
    q=numbers[m][1]-1
    a=T[e]
    T[e]=q
    number=[]
    whole = sum(c)
    for d in range(D):
        s = S[d]
        place = T[d]
        held[place] = d + 1
        ans += s[place]
        whole*=(d+1)
        whole+=c[place]*(d+1)
        ans-=whole
for d in range(D):
    if d%27==0:
        print(20)
    else:
        print(d%27)
        

Fixed submission:
D=int(input())
c=input().split()
c=[int(a) for a in c]
S=[]
for _ in range(D):
    s=input().split()
    s=[int(a) for a in s]
    S.append(s)

for d in range(D):
    if d%27==0:
        print(20)
    else:
        print(d%27)