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: #5個のうち1番目の入力が0なら処理を終わる。
while True:
    line = []
    line.append(int(input()))
    if line[0] == 0:break

    #標準入力をしリストをセットにしたものを作る。
    for _ in range(4):line.append(int(input()))
    se = set(line)
    
    #全員が同じ数を出すか3種類の手が出たら5こ"3"を出力する。
    if len(se) == 1 or len(se) == 3:
        for _ in range(5):print("3")
        ""
    #じゃんけんの勝敗に基づき勝ちだったら"1"負けだったら"2"を出力する
    else:
        if sum(se) == 3:
            for i in line:
                if i == 1:print("1")
                else:print("2")
        if sum(se) == 4:
            for i in line:
                if i == 3:print("1")
                else:print("2")
        if sum(se) == 5:
            for i in line:
                if i == 2:print("1")
                else:print("2")

Python: while True:
    h1= int(input())
    if h1== 0: break
    h2, h3, h4, h5= [int(input()) for _ in range(4)]
    sh= set([h1, h2, h3, h4, h5])
    if len(sh)== 3:
        print("\n".join(["3","3","3","3","3"]))
    else:
        for h in [h1, h2, h3, h4, h5]:
            if h== 1:
                print(1 if 2 in sh else 2)
            elif h== 2:
                print(1 if 3 in sh else 2)
            else:
                print(1 if 1 in sh else 2)

Python: 
while True:
    L = []
    H = []
    for _ in range(5):
        c = int(input())
        if c == 0:
            exit()
        L.append(c)

    h = set(L)

    if len(h) in [1, 3]:
        for _ in range(5):
            H.append(3)
    else:
        r = list(set([1,2,3])-h)[0]
        if r == 1:
            w = 2
        elif r == 2:
            w = 3
        else:
            w = 1
        for i in L:
            if i == w:
                H.append(1)
            else:
                H.append(2)
    for i in H:
        print(i)

Python: while True:
    try:
        a = [int(input()) for i in range(5)]
    except:
        break
    if (1 in a and 2 in a and 3 in a) or a.count(a[0]) == 5:
        for i in range(5):
            print(3)
    elif not 3 in a:
        for b in a:
            if b == 1:
                print(1)
            else:
                print(2)
    elif not 2 in a:
        for b in a:
            if b == 1:
                print(2)
            else:
                print(1)
    else:
        for b in a:
            if b == 2:
                print(1)
            else:
                print(2)

Python: def judge(h, hands):
  if h == '1':
    if '2' in hands:
      if '3' not in hands:
        return 1
      else:
        return 3
    elif '2' not in hands:
      if '3' not in hands:
        return 3
      else:
        return 2
  elif h == '2':
    if '3' in hands:
      if '1' not in hands:
        return 1
      else:
        return 3
    elif '3' not in hands:
      if '1' not in hands:
        return 3
      else:
        return 2
  else:
    if '1' in hands:
      if '2' not in hands:
        return 1
      else:
        return 3
    elif '1' not in hands:
      if '2' not in hands:
        return 3
      else:
        return 2

while True:
  hands = []
  for _ in range(5):
    h = input()
    if h == '0':
      exit()
    else:
      hands.append(h)
  for h in hands:
    print(judge(h, hands))

Python: while True:
    h1= int(input())
    if h1== 0: break
    h2, h3, h4, h5= [int(input()) for _ in range(4)]
    sh= set([h1, h2, h3, h4, h5])
    if len(sh)== 3:
        print("\n".join(["3","3","3","3","3"]))
    else:
        for h in [h1, h2, h3, h4, h5]:
            if h== 1:
                print('1' if 2 in sh else '2')
            elif h== 2:
                print('1' if 3 in sh else '2')
            else:
                print('1' if 1 in sh 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: win=[0,2,3,1]
lose=[0,3,1,2]
while True:
    exist=[False for i in range(4)]
    h=[0 for i in range(5)]
    h[0] = int(input())
    exist[h[0]]=True
    if h[0] == 0 :
        break
    for i in range(1,5):
        h[i]=int(input())
        exist[h[i]]=True
    for i in range(5):
        if exist[win[h[i]]] and not exist[lose[h[i]]]:
            print(1)
        elif not exist[win[h[i]]] and exist[lose[h[i]]]:
            print(2)
        else:
            print(3)

Python: while True:
    
    has=[False, False, False, False]
    
    n=input()
    if n=='0':
        break
    te=[]
    te.append(n)
    has[int(n)]=True
    for adf in range(4):
        n=input()
        has[int(n)] = True
        te.append(n)
        
    if has[1] and has[2] and has[3]:
        for qwer in range(5):
            print(3)
    elif te[1]==te[2] and te[2]==te[3] and te[3]==te[4] and te[0]==te[4]:
        for asdd in range(5):
            print(3)
    elif not has[3]:
        for g in range(5):
            if te[g]=='1':
                print('1')
            else:
                print('2')
    elif not has[2]:
        for g in range(5):
             if te[g]=='3':
                print('1')
             else:
                print('2')
    else:
        for g in range(5):
            if te[g]=='2':
                print('1')
            else:
                print('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:
            if h < 1 or 3 < h:
                raise ValueError
            #print(rps[hand_set][h])
main()

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
    d = {1:2, 2:3, 3:1}
    for c in h:
        print([2, 1][d[c] in h])

Python: def judge(h, hset):
  rest = hset - {h}
  if len(rest) in (0, 2):
    return 3
  if h % 3 + 1 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: from sys import stdin
readline = stdin.readline


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:
    hand = int(readline())
    if hand == 0:
        break
    hands = [hand] + [int(readline()) for _ in range(4)]
    hand_set = tuple(sorted(set(hands)))
    for h in hands:
        print(rps[hand_set][h])