#!/usr/bin/env python3
n = None
while True:
    response = input()
    if response == "I give up":
        break
    response_int = int(response)

    if n == None:
        n = response_int
    else:
        n = n - response_int
    if n%4 == 0:
        move = 3
    else:
        move = n%4-1

    n = n - move
    print(move, flush=True)
