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(void){
	int hands[5];
	int w,l;
	
	while(cin >> hands[0] && hands[0]){
		bool exists[3] = {false, false, false};
		
		for(int i=1;i<=4;i++){
			cin >> hands[i];
		}
		for(int i=0;i<5;i++){
			exists[hands[i]-1] = true;
		}
		
		//print results
		if( ((int)exists[0] + (int)exists[1] + (int)exists[2]) % 2 == 1){
			for(int i=0; i<5;i++) cout << 3 << endl;
		}else{
			if(exists[0] == false){
				w = 2; l = 3;
			}else if(exists[1] == false){
				w = 3; l = 1;
			}else{
				w = 1; l = 2;
			}
			for(int i=0;i<5;i++){
				if(hands[i] == w){
					cout << 1 << endl;
				}else{
					cout << 2 << endl;
				}
			}
		}
	}
}

C++: #include<iostream>

void solve(int *data);

using namespace std;

int main(){
	int player[5] = {0};
	int cnt = 0;

	while(1){
		int flag = -1;

		cin >> flag;

		if(flag == 0)break;

		player[0] = flag;

		cin >> player[1] >> player[2] >> player[3] >> player[4];

		solve(player);
	}
	return 0;
}

void solve(int *player){
	bool gu = false,pa = false,ty = false;

	for(int i=0;i<5;i++){
		if(player[i] == 1)gu = true;
		else if(player[i] == 2)ty = true;
		else if(player[i] == 3)pa = true;
	}

	if(gu && pa && ty){
		for(int j=0;j<5;j++)
			cout << 3 << endl;
		return ;
	}

	for(int i=0;i<5;i++){
		if(gu && pa){
			if(player[i] == 3)cout << 1 << endl;
			else cout << 2 << endl;
		}
		else if(gu && ty){
			if(player[i] == 1)cout << 1 << endl;
			else cout << 2 << endl;
		}
		else if(ty && pa){
			if(player[i] == 2)cout << 1 << endl;
			else cout << 2 << endl;
		}
	}
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(int argc, char *argv[]){
  int n[5];
  while(std::cin >> n[0], n[0]){
    n[0]--;
    for (int i = 0; i < 4; i++) {
      std::cin >> n[i + 1];
      n[i + 1]--;
    }
    bool used[3] = {}, draw = false;
    for (int i = 0; i < 5; i++) {
      used[n[i]] = true;
    }
    int win = -1;
    set<int> a;
    vector<int> ans;
    for (int i = 0; i < 5; i++) {
      a.insert(n[i]);
    }
    for (int i: a){
      ans.push_back(i);
    }
    if(ans.size() == 1 || ans.size() == 3){
      draw = true;
    }else if(ans[0] == 0 && ans[1] == 1){
      win = 0;
    }else if(ans[0] == 1 && ans[1] == 2){
      win = 1;
    }else if(ans[0] == 0 && ans[1] == 2){
      win = 2;
    }
    if(draw){
      for (int i = 0; i < 5; i++) {
        std::cout << 3 << std::endl;
      }
    }else{
      for (int i = 0; i < 5; i++) {
        if(win == n[i])std::cout << 1 << std::endl;
        else std::cout << 2 << std::endl;
      }
    }
  }
  return 0;
}

C++: #include <stdio.h>
#include <vector>
#include <algorithm>
#include <stack>

using namespace std;


int main(){

	int member[5],check[4],num_of_val;

	while(true){

		for(int i = 1; i <= 3; i++)check[i] = 0;

		scanf("%d",&member[0]);

		if(member[0] == 0)break;
		else{
			check[member[0]]++;
		}

		for(int i = 1; i < 5; i++){
			scanf("%d",&member[i]);
			check[member[i]]++;
		}

		num_of_val = 0;

		for(int i = 1; i <= 3; i++){
			if(check[i] > 0)num_of_val++;
		}

		if(num_of_val == 3 || num_of_val == 1){
			printf("3\n3\n3\n3\n3\n");
		}else{
			if(check[1] > 0 && check[2] > 0){	//??°?????¨?????§???
				for(int i = 0; i < 5; i++){
					if(member[i] == 1)printf("1\n");
					else{
						printf("2\n");
					}
				}
			}else if(check[1] > 0 && check[3] > 0){	//??°?????¨??????
				for(int i = 0; i < 5; i++){
					if(member[i] == 3)printf("1\n");
					else{
						printf("2\n");
					}
				}
			}else{ //?????§?????¨??????
				for(int i = 0; i < 5; i++){
					if(member[i] == 2)printf("1\n");
					else{
						printf("2\n");
					}
				}
			}
		}
	}
    return 0;
}

C++: #include <iostream>
#include <algorithm>

using namespace std;

int player[5];

int main()
{	
	while (cin >> player[0], player[0]){
		int a[2] = {0}, j = 0;
		int check[4] = {1, 1, 1, 1};

		check[player[0]] = -1;
		for (int i = 1; i < 5; i++){
			cin >> player[i];
			check[player[i]] = -1;
		}
		for (int i = 1; i < 4; i++){
			check[0] *= check[i];
			if (check[i] == -1){
				a[j++] = i;
			}
		}
		if (check[0] == -1){
			for (int i = 0; i < 5; i++){
				player[i] = 3;
			}
		}
		else if (check[3] == -1 && check[1] == -1){
			for (int i = 0; i < 5; i++){
				if (player[i] == 3)	player[i] = 1;
				else	player[i] = 2;
			}
		}
		else {
			for (int i = 0; i < 5; i++){
				if (player[i] == min(a[0], a[1]))	player[i] = 1;
				else 	player[i] = 2;
			}
		}
		for (int i = 0; i < 5; i++){
			cout << player[i] << endl;
		}
	}
	return (0);
}

C++: #include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <limits>
#include <sstream>

using namespace std;

int main (void)
{
	int y = 0;
	for (int u = 0; u < 200; u++)
	{
		int a[6],h1 = 0,h2 = 0,h3 = 0;

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

		for (int i = 0; i < 5; i++)
		{
			if (a[i] == 1)
			{
				h1 += 1;
			}
			else if (a[i] == 2)
			{
				h2 += 1;
			}
			else if (a[i] == 3)
			{
				h3 += 1;
			}
		}


		int ke = 0;
		if (h1 != 0 && h2 != 0)
		{
			if (h3 != 0)
			{
				ke += 1;
				for (int gg = 0; gg < 5; gg++)
				{
					cout << '3' << endl;
				}
			}
		}

		if (h1 == 0 && ke == 0)
		{
			for (int j = 0; j < 5; j++)
			{
				if (a[j] == 2)
				{
					cout << '1' << endl;
				}
				else
				{
					cout << '2' << endl;
				}
			}
		}
		else if (h2 == 0 && ke == 0)
		{
			for (int j = 0; j < 5; j++)
			{
				if (a[j] == 1)
				{
					cout << '2' << endl;
				}
				else
				{
					cout << '1' << endl;
				}
			}
		}
		else if (h3 == 0 && ke == 0)
		{
			for (int j = 0; j < 5; j++)
			{
				if (a[j] == 1)
				{
					cout << '1' << endl;
				}
				else
				{
					cout << '2' << endl;
				}
			}
		}
	}
}

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

int main(){
	int human[5];
	while(cin>>human[0],human[0]){
		bool hand[3]={0,0,0};
		if(human[0]==1) hand[0]++;
		else if(human[0]==2) hand[1]++;
		else hand[2]++;
		for(int i=1;i<5;i++){
			cin>>human[i];
			if(human[i]==1) hand[0]++;
			else if(human[i]==2) hand[1]++;
			else hand[2]++;
		}
		if((hand[0]==true&&hand[0]==hand[1]&&hand[0]==hand[2])||(hand[0]==false&&hand[0]==hand[1])||(hand[0]==false&&hand[0]==hand[2])||(hand[1]==false&&hand[1]==hand[2])){
			for(int i=0;i<5;i++)cout<<'3'<<endl;
		}
		else if(hand[0]==true&&hand[0]==hand[1]){
			for(int i=0;i<5;i++){
				if(human[i]==1)cout<<'1'<<endl;
				else cout<<'2'<<endl;
			}
		}
		else if(hand[0]==true&&hand[0]==hand[2]){
			for(int i=0;i<5;i++){
				if(human[i]==3)cout<<'1'<<endl;
				else cout<<'2'<<endl;
			}
		}
		else if(hand[1]==true&&hand[1]==hand[2]){
			for(int i=0;i<5;i++){
				if(human[i]==2)cout<<'1'<<endl;
				else cout<<'2'<<endl;
			}
		}
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
int main() {
  int N;cin>>N;
  while(N>0) {
    int v[5],b=0,f=0,d[]={0,0,0,1,0,3,2,0};
    for(;b<5;++b) {
      v[b]=N;f|=1<<--N;cin>>N;
    }
    for(b=0;b<5;++b) cout<<((v[b]==d[f])?1:(d[f]?2:3))<<endl;
  }
  return 0;
}