def power_crisis(n,k):
if n == 1:
return 1
else:
return (power_crisis(n-1,k)+k-1)%n+1
while True:
n = int(input())
if n == 0:
break
i = 1
while power_crisis(n-1,i) != 12:
i += 1
print(i)
def power_crisis(n,k):
if n == 1:
return 1
else:
return (power_crisis(n-1,k)+k-1)%n+1
while True:
n = int(input())
if n == 0:
break
i = 1
while power_crisis(n-1,i) != 12:
i += 1
print(i)