D = [[],[0,0,1,-1],[0,-1,0,1],[0,1,-1,0]]
E = map(str, [3,1,2])
while True:
    d = []
    try:
        d = [int(raw_input()) for _ in xrange(5)]
    except:
        break
    h = set(d)
    print "\n".join(E[sum(D[dd][hh] for hh in h)] for dd in d)