data = 'DG'
repeat = 10

rep = {'D':'DAGAGA', 'G':'GADADA', 'A': 'AA'}

for i in range(repeat):
    data = "".join([rep[c] for c in data])

d = 0 #0=nord, 1=est, 2=sud, 3=ouest,
y = 0
x = 0

for c in data:
    if c == 'A':
        if d == 0:
            y+=10
        elif d == 1:
            x+=10
        elif d == 2:
            y-=10
        else:
            x-=10
    elif c == 'D':
        d = (d+1)%4
    else:
        d = (d-1)%4

print(y,x)