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: hs = []
while True:
    h= int(input())
    if h== 0: break
    hs = hs+[h]
    if len(hs)==5:
        for i in range(5):
            if 1 in hs and 2 in hs and 3 in hs:
                print("3")
            elif hs[i]==1:
                print("2" if 3 in hs else "1")
            elif hs[i]==2:
                print("2" if 1 in hs else "1")
            else:
                print("2" if 2 in hs else "1")
        hs= []

Python: while 1:
    hands = []
    h = int(input())
    if h == 0:
        break
    hands.append(h)

    for _ in range(4):
        h = int(input())
        hands.append(h)

    h_uni = list(set(hands))
    if len(h_uni) != 2:
        for _ in range(5):
            print(3)
        continue

    h_uni.sort()
    if h_uni[0] == 1 and h_uni[1] == 2:
        for h in hands:
            if h == 1:
                print(1)
            else:
                print(2)
    elif h_uni[0] == 1 and h_uni[1] == 3:
        for h in hands:
            if h == 1:
                print(2)
            else:
                print(1)
    else:
        for h in hands:
            if h == 2:
                print(1)
            else:
                print(2)

Python: """ Created by Jieyi on 8/22/16. """


def check_aiko(arr):
    rps = [1, 2, 3]
    for t in rps:
        if t not in arr:
            return False

    return True


def check_v(arr):
    rps = {}
    o = []
    for t in arr:
        if t not in rps:
            rps[t] = 0
    if 1 in rps.keys() and 2 in rps.keys():
        rps[1], rps[2] = 1, 2
    elif 2 in rps.keys() and 3 in rps.keys():
        rps[2], rps[3] = 1, 2
    elif 1 in rps.keys() and 3 in rps.keys():
        rps[3], rps[1] = 1, 2

    for n in arr:
        o.append(rps.get(n))
    return o


def algorithm():
    g = []
    out = []

    while True:
        inp = int(input())
        if inp == 0:
            break

        g.append(inp)
        if len(g) == 5:
            if check_aiko(g):
                out = [3] * 5
            else:
                out = check_v(g)

            for o in out:
                print(o)
            g.clear()
            out.clear()


def main():
    algorithm()


if __name__ == '__main__':
    main()

Python: while True:
    h = int(input())
    if h == 0:break
    h = [h] + [int(input()) for _ in range(4)]
    if 1 and 2 and 3 in h:
        print("\n".join(['3','3','3','3','3']))
    else:
        for i in range(len(h)):
            if h[i]==1:
                print('1' if 2 in h else '2')
            elif h[i]==2:
                print('1' if 3 in h else '2')
            else:
                print('1' if 1 in h else '2')

Python: while True:
    h = int(input())
    if h == 0:
        break
    h = [h] + [int(input()) for _ in range(4)]
    if len(set(h)) == 3:
        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: d = {1:2, 2:3, 3:1}
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:
        print([2, 1][d[c] in h])

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 [r,s,p].count(0)==1:
        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: def check_aiko(arr):
    if all(arr[0] == a for a in arr):
        return True

    rps = [1, 2, 3]
    for t in rps:
        if t not in arr:
            return False

    return True


def check_v(arr):
    rps = {}
    o = []
    for t in arr:
        if t not in rps:
            rps[t] = 0
    if 1 in rps.keys() and 2 in rps.keys():
        rps[1], rps[2] = 1, 2
    elif 2 in rps.keys() and 3 in rps.keys():
        rps[2], rps[3] = 1, 2
    elif 1 in rps.keys() and 3 in rps.keys():
        rps[3], rps[1] = 1, 2

    for n in arr:
        o.append(rps.get(n))
    return o


def algorithm():
    g = []
    out = []

    while True:
        inp = int(input())
        if inp == 0:
            break

        g.append(inp)
        if len(g) == 5:
            if check_aiko(g):
                out = [3] * 5
            else:
                out = check_v(g)

            for o in out:
                print(o)
            g.clear()
            out.clear()


def main():
    algorithm()


if __name__ == '__main__':
    main()

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:
            pass
            #print(rps[hand_set][h])
main()

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:3, 2:3, 3:3}
    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()

Python: while True:
    h1= int(input())
    if h1== 0:
        break
    h2,h3,h4,h5= [int(input()) for _ in range(4)]
    l= [h1,h2,h3,h4,h5]
    if 1 and 2 and 3 in l:
        for _ in range(5): print("3")
    else:
        for i in range(5):
            if l[i]==1:
                print('1' if 2 in l else '2')
            elif l[i]==2:
                print('1' if 3 in l else '2')
            else:
                print('1' if 1 in l else '2')

Python: def judge(h, hset):
  rest = hset - {h}
  if len(rest) in (0, 2):
    return 3
  if (h + 1) % 3 in rest:
    return 1
  else:
    return 2

while True:
  h1 = int(input())
  if h1 == 0:
    break
  hlst = []
  hset = set()
  hlst.append(h1)
  hset.add(h1)
  for _ in range(4):
    h = int(input())
    hlst.append(h)
    hset.add(h)
  for h in hlst:
    print(judge(h, hset))

Python: d = {'1': '3', '2': '1', '3': '1'}
while True:
    h = input()
    if h == '0':
        break
    h = [h] + [input() for _ in range(4)]
    if set(h) == {'1', '2', '3'}:
        print('\n'.join(['3']*5))
    else:
        for v in h:
            print('2' if d[v] in h else '1')