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)
				}
			}
		}
	}
}

C++: #include<iostream>
using namespace std;

int main()
{
    int a[5], b[4];

    while( cin >> a[0] )
    {
        if( a[0] == 0 )
            break;
        for( int i = 0; i < 4; i++ )
            b[i] = 0;
        b[a[0]]++;
        for( int i = 1; i < 5; i++ )
        {
            cin >> a[i];
            b[a[i]]++;
        }

        if( b[1] != 0 && b[2] != 0 && b[3] != 0 || b[1] == 5 || b[2] == 5 || b[3] == 5 )
            for( int i = 0; i < 5; i++ )
                cout << 3 << endl;
        else
        {
            if( b[1] == 0 )
            {
                for( int i = 0; i < 5; i++ )
                    if( a[i] == 2 )
                        cout << 1 << endl;
                    else
                        cout << 2 << endl;
            }
            else if( b[2] == 0 )
            {
                for( int i = 0; i < 5; i++ )
                    if( a[i] == 3 )
                        cout << 1 << endl;
                    else
                        cout << 2 << endl;
            }
            else
            {
                for( int i = 0; i < 5; i++ )
                    if( a[i] == 1 )
                        cout << 1 << endl;
                    else
                        cout << 2 << endl;
            }
        }
    }
    return 0;
}

C++: #include <iostream>
#include <map>
using namespace std;

int main() {
	int a[5];
	while(1){
		int flag1=0,flag2=0,flag3=0;
		
		for(int i=0;i<5;i++){
			cin>>a[i];
			if(a[i]==1)flag1=1;
			if(a[i]==2)flag2=1;
			if(a[i]==3)flag3=1;
		}
		if(a[0]==0)break;
		for(int i=0;i<5;i++){
			if(flag1==1&&flag2==1&&flag3==1){
				cout<<3<<endl;
			}else if(flag1==1&&flag2==1){
				if(a[i]==1)cout<<1<<endl;
				else cout<<2<<endl;
			}else if(flag2==1&&flag3==1){
				if(a[i]==2)cout<<1<<endl;
				else cout<<2<<endl;
			}else if(flag1==1&&flag3==1){
				if(a[i]==3)cout<<1<<endl;
				else cout<<2<<endl;
			}
		}
		
	}
	return 0;
}

C++: #include <iostream>

int main(){
	//紙 3 はさみ 2 石 1
	bool eflag = false;
	while(!eflag){
		int hands[5] = {0}, things[4] = {0};
		for(int i=0;i<5&&!eflag;i++){
			int n;
			std::cin >> n;
			hands[i] = n, things[n]++;
			if(!n)eflag = true;
		}
		if(!eflag){
			int winner = 0;
			//あいこのとき
			if(things[1] && things[2] && things[3])
				winner = -1;
			else if(things[1] && things[2])
				winner = 1;
			else if(things[2] && things[3])
				winner = 2;
			else if(things[1] && things[3])
				winner = 3;
			else
				winner = -1;
			for(int i=0;i<5;i++){
				if(winner < 0)
					std::cout << "3\n";
				else if(hands[i] == winner)
					std::cout << "1\n";
				else
					std::cout << "2\n";
			}
		}
	}
}

C++: #include<stdio.h>
int main()
{
	int p[5],g=0,c=0,pa=0,w;
	while(1){
	for(int i=0;i<5;i++){
		scanf("%d",&p[i]);
		if(p[i]==1)g++;
		else if(p[i]==2)c++;
		else if(p[i]==3)pa++;
		else goto A;
	}
	if(g>0&&c>0&&pa>0||g==5||c==5||pa==5){
		for(int i=0;i<5;i++)printf("3\n");
	}
	else
	{
		if(g>0&&c>0){
			w=1;
		}
		else if(c>0&&p>0){
			w=2;
		}
		else{
			w=3;
		}
		for(int i=0;i<5;i++){
			if(p[i]==w)
				printf("1\n");
			else
				printf("2\n");
		}

	}
	g=c=pa=0;
	}
	A:
	return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

int main()
{
    
    while (1) {
        vector<int> DataBase;

        for (int i = 0; i < 5; ++i) {
            int data;
            cin >> data;
            if (data == 0) break;
            DataBase.push_back(data);
        }

        if (DataBase.size() == 0) {
            break;
        }

        bool win_stone = false;
        bool win_sissor = false;
        bool win_paper = false;
        bool aiko = false;

        win_stone = static_cast<bool>(find(DataBase.begin(), DataBase.end(), 1) != DataBase.end() &&
                                        find(DataBase.begin(), DataBase.end(), 2) != DataBase.end() &&
                                        find(DataBase.begin(), DataBase.end(), 3) == DataBase.end());

        win_sissor = static_cast<bool>(find(DataBase.begin(), DataBase.end(), 1) == DataBase.end() &&
                                        find(DataBase.begin(), DataBase.end(), 2) != DataBase.end() &&
                                        find(DataBase.begin(), DataBase.end(), 3) != DataBase.end());
        win_paper = static_cast<bool>(find(DataBase.begin(), DataBase.end(), 1) != DataBase.end() &&
                                        find(DataBase.begin(), DataBase.end(), 2) == DataBase.end() &&
                                        find(DataBase.begin(), DataBase.end(), 3) != DataBase.end());
        aiko = static_cast<bool>(find(DataBase.begin(), DataBase.end(), 1) != DataBase.end() &&
                                        find(DataBase.begin(), DataBase.end(), 2) != DataBase.end() &&
                                        find(DataBase.begin(), DataBase.end(), 3) != DataBase.end());
        
        vector<int> ResultBase(5, 0);

        if (win_stone) {
            for (int i = 0; i < static_cast<int>(DataBase.size()); ++i) {
                switch(DataBase[i]) {
                    case 1:
                        ResultBase[i] = 1;
                        break;
                    case 2:
                        ResultBase[i] = 2;
                        break;
                    default:
                        break;
                }
            }
        }

        if (win_sissor) {
            for (int i = 0; i < static_cast<int>(DataBase.size()); ++i) {
                switch(DataBase[i]) {
                    case 2:
                        ResultBase[i] = 1;
                        break;
                    case 3:
                        ResultBase[i] = 2;
                        break;
                    default:
                        break;
                }
            }
        }

        if (win_paper) {
            for (int i = 0; i < static_cast<int>(DataBase.size()); ++i) {
                switch(DataBase[i]) {
                    case 3:
                        ResultBase[i] = 1;
                        break;
                    case 1:
                        ResultBase[i] = 2;
                        break;
                    default:
                        break;
                }
            }
        }

        if (aiko) {
            for (int i = 0; i < static_cast<int>(DataBase.size()); ++i) {
                 ResultBase[i] = 3;
             }
        }
        
        for (int i = 0; i < static_cast<int>(ResultBase.size()); ++i) {
            cout << ResultBase[i] << endl;
        }
    }

    return 0;
}