Go: package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	for scanner.Scan() {
		h := make([]int, 5)
		h[0], _ = strconv.Atoi(scanner.Text())
		if h[0] == 0 {
			break
		}
		for i := 1; i <= 4; i++ {
			scanner.Scan()
			h[i], _ = strconv.Atoi(scanner.Text())
		}
		tbl := make([]bool, 3)
		aiko := false
		for _, v := range h {
			tbl[v-1] = true
		}
		if tbl[0] && tbl[1] && tbl[2] { // 全ての手があるあいこ
			aiko = true
		}
		if h[0] == h[1] && h[1] == h[2] && h[2] == h[3] && h[3] == h[4] {
			aiko = true
		}
		if aiko {
			fmt.Printf("3\n3\n3\n3\n3\n")
		} else {
			win := 0
			if !tbl[0] {
				win = 2
			}
			if !tbl[1] {
				win = 3
			}
			if !tbl[2] {
				win = 1
			}
			for i := 0; i < 5; i++ {
				if h[i] == win {
					fmt.Println(1)
				} else {
					fmt.Println(2)
				}
			}
		}
	}
}

Python: from sys import stdin
readline = stdin.readline

def main():
    R, S, P = 1, 2, 3
    W, L, D = 1, 2, 3

    rps = {
        (R, S, P):{R:D, S:D, P:D},
        (R, S)   :{R:W, S:L},
        (S, P)   :{S:W, P:L},
        (R, P)   :{P:W, R:L}
    }

    while True:
        try:
            hands = [int(readline()) for _ in range(5)]
        except:
            break
        hand_set = tuple(sorted(set(hands)))
        for h in hands:
            print(rps[hand_set][h])
main()

Python: a = []
while(True):
    n = int(input())
    if n == 0:
        break
    a.append(n)
    if len(a) == 5:
        uni = set(a)
        if len(uni) == 2 and 1 in uni and 2 in uni:
            for b in a: print(2 if b == 2 else 1)
        elif len(uni) == 2 and 2 in uni and 3 in uni:
            for b in a: print(2 if b == 3 else 1)
        elif len(uni) == 2 and 3 in uni and 1 in uni:
            for b in a: print(2 if b == 1 else 1)
        else:
            for _ in range(5): print(3)
        a = []

Python: while 1:
    a=int(input())
    if a==0:break
    a=[a]+[int(input()) for _ in range(4)]
    r=a.count(1);s=a.count(2);p=5-r-s
    if not r or not s or not p and [r,s,p].count(0)!=2:
        if r and s:w=1
        elif r and p:w=3
        else:w=2
        [print([2,1][w==x])for x in a]
    else:print('3\n'*5,end='')

Python: # AOJ 0205: Rock, Paper, Scissors
# Python3 2018.6.25 bal4u

h = [0]*5
while True:
	try:
		for i in range(5): h[i] = int(input())
	except: break
	print(type(h), h)
	if len(set(h)) == 1 or len(set(h)) == 3:
		print(*[3]*5, sep='\n')
		continue
	ans = [1]*5
	for i in range(5):
		if   h[i] == 1: ans[i] += (h.count(3) > 0)
		elif h[i] == 2: ans[i] += (h.count(1) > 0)
		else:           ans[i] += (h.count(2) > 0)
	print(*ans, sep='\n')

Python: # AOJ 0205: Rock, Paper, Scissors
# Python3 2018.6.25 bal4u

h = [0]*5
while True:
	try:
		for i in range(5): h[i] = int(input())
	except: break
	if len(set(h)) == 1 or len(set(h)) == 3:
		print(*[3]*5, sep='\n')
		continue
	ans = [1]*5
	for i in range(5):
		if   h[i] == 1: ans[i] += (h.count(3) > 0)
		elif h[i] == 2: ans[i] += (h.count(1) > 0)
		else:           ans[i] += (h.count(2) > 0)
	print(*ans, sep='\n')

Python: while True:
    h1 = int(input())
    if h1 == 0:
        break
    h = [h1] + [int(input()) for _ in range(4)]
    if len(set(h)) == 1 or len(set(h)) == 3:
        print(*[3]*5, sep="\n")
        continue
    for hi in h:
        print([2, 1][(hi%3)+1 in h])

Python: while True:
    h = int(input())
    if h == 0:
        break
    dataset = [h] + [int(input()) for _ in range(4)]
    if len(set(dataset)) == 3 or len(set(dataset)) == 1:
        print(*[3]*5, sep="\n")
    for data in dataset:
        if data == 1:
            print(2 if 3 in dataset else 1)
        elif data == 2:
            print(2 if 1 in dataset else 1)
        else:
            print(2 if 2 in dataset else 1)

Python: while True:
    h = int(input())
    if h == 0:
        break
    h = [h] + [int(input()) for _ in range(4)]
    if len(set(h)) == 3 or len(set(h)) == 1:
        print(*["3"]*5, sep='\n')
        continue
    for c in h:
        if c == 1:
            print("1" if 2 in h else "2")
        elif c == 2:
            print("1" if 3 in h else "2")
        else:
            print("1" if 1 in h else "2")

Python: from sys import stdin
readline = stdin.readline

from io import StringIO
readline = StringIO('''1
2
3
2
1
1
2
2
2
1
0''').readline

R, S, P = 1, 2, 3  # rock, scissors, paper
W, L, D = 1, 2, 3  # win, lose, draw


while True:
    hands = []
    hands.append(int(readline()))
    if hands[0] == 0:
        break
    for _ in range(4):
        hands.append(int(readline()))

    hands_set = tuple(sorted(set(hands)))
    for h in hands:
        print(rps[hands_set][h])

Python: from sys import stdin
readline = stdin.readline


R, S, P = 1, 2, 3  # rock, scissors, paper
W, L, D = 1, 2, 3  # win, lose, draw

rps = {
    (R, S, P): {R: D, S: D, P: D},
    (R, S):    {R: W, S: L},
    (S, P):    {S: W, P: L},
    (R, P):    {P: W, R: L},
    (R,):       {R: D},
    (S,):       {S: D},
    (P,):       {P: D}
    }

while True:
    hands = []
    hands.append(int(readline()))
    if hands[0] == 0:
        break
    for _ in range(4):
        hands.append(int(readline()))

    hands_set = tuple(sorted(set(hands)))
    for h in hands:
        print(rps[hands_set][h])

Python: # -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0205

"""
import sys
from sys import stdin
input = stdin.readline


def main(args):
    while True:
        hands = [0] * 5
        hands[0] = int(input())
        if hands[0] == 0:
            break
        hands[1] = int(input())
        hands[2] = int(input())
        hands[3] = int(input())
        hands[4] = int(input())

        # ?????????????????????????????±???????????????
        if 1 in hands and 2 in hands and 3 in hands: #  ??¨????????????????????´???
            for _ in range(5):
                print(3)
        elif hands.count(hands[0]) == 5: #  ??¨????????????????????´???
            for _ in range(5):
                print(3)
        # ??????????????????????????±???????????????
        else:
            for h in hands:
                if h+1 in hands:
                    print(1)
                else:
                    print(2)


if __name__ == '__main__':
    main(sys.argv[1:])

Python: # Aizu Problem 0205: Rock Paper Scissor
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")

        
while True:
    try:
        game = [int(input()) for _ in range(5)]
    except EOFError:
        break
    if 1 in game and 2 in game:
        w = 1
    elif 1 in game:
        w = 3
    else:
        w = 2
    if len(set(game)) != 2:
        for g in game:
            print(3)
    else:
        for g in game:
            print(1 if g == w else 2)

Python: # -*- coding: utf-8 -*-
#import pdb;    pdb.set_trace()
import sys

def solv(v):
    w = set(v)
    if len(w)==1 or len(w)==3:
        d={1:2, 2:2, 3:2}
    elif 1 in w and 2 in w:
        d={1:1, 2:2}
    elif 2 in w and 3 in w:
        d={2:1, 3:2}
    else:
        d={3:1, 1:2}
    return(list(map(lambda x:d[x], v) ))
def main():
    if True:
        fh = sys.stdin
    else:
        fh = open('vol2_0205.txt', 'r')
    try:
        while True:
            te = []
            for _ in range(5):
                x=int(fh.readline().strip())
                if x==0:
                    raise Exception
                te.append(x)
            b=(solv(te))
            for i in b:
                print(i)
    except Exception:
        1
    fh.close()
    
if __name__ == '__main__':
    main()