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>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstdio>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,b) FOR(i,0,b)
#define PB push_back
#define MP make_pair
int main(){
  int arm[5];
  while(cin>>arm[0]&&arm[0]){
    arm[0]--;
    bool d[3];
    memset(d,false,sizeof(d));
    for(int i=1;i<5;i++){
      cin>>arm[i];
      arm[i]--;
      d[arm[i]]=true;
    }
    int cnt=0;
    for(int i=0;i<3;i++){
      if(d[i])cnt++;
    }
    if(cnt!=2){
      for(int i=0;i<5;i++){
        cout<<3<<endl;
      }
    }else{
      int win,lose;
      if(d[0]&&d[1]){
        win=0;lose=1;
      }else if(d[1]&&d[2]){
        win=1;lose=2;
      }else if(d[2]&&d[0]){
        win=2;lose=0;
      }
      for(int i=0;i<5;i++){
        if(arm[i]==win)cout<<1<<endl;
        else cout<<2<<endl;
      }
    }
  }
}

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
				winner = 3;
			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<iostream>
using namespace std;

int hand,rock[6],sci[6],par[6],cou_r,cou_s,cou_p;

void priming(int x,int i){
  if(x==1){
    rock[i]=1;
    cou_r++;
  }else if(x==2){
    sci[i]=1;
    cou_s++;
  }else if(x==3){
    par[i]=1;
    cou_p++;
  }
}

int main(){
  
  while(1){
    for(int i=0;i<6;i++)rock[i]=sci[i]=par[i]=0;
    cou_r=cou_s=cou_p=0;
    cin>>hand;
    
    if(hand==0)break;
    
    priming(hand,0);
    
    for(int i=1;i<5;i++) {
      cin>>hand;
      priming(hand,i);
    }
    
    if((cou_r!=0&&cou_s!=0&&cou_p!=0)||cou_r==5||cou_s==5||cou_p==5){
      for(int i=0;i<5;i++)cout<<"3"<<endl;
    }else if(cou_p==0){
      for(int i=0;i<5;i++){
	if(rock[i]==1)cout<<"1"<<endl;
	else cout<<"2"<<endl;
      }
    }else if(cou_r==0){
      for(int i=0;i<5;i++){    
	if(sci[i]==1)cout<<"1"<<endl;
	else cout<<"2"<<endl;
      }
    }else if(cou_s==0){
      for(int i=0;i<5;i++){
        if(par[i]==1)cout<<"1"<<endl;
        else cout<<"2"<<endl;
      }
    }
  
  }
  return 0;
}

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

using namespace std;

#define rep(i,a) for(int i = 0 ; i < a ; i ++)
#define loop(i,a,b) for(int i = a ; i < b ; i ++)

int main(void){
	vector<int> inp(5);
	while(cin>>inp[0],inp[0]){
		bool judge[3] = {false};
		loop(i,1,5){
			cin>>inp[i];
			judge[inp[i]-1]=true;
		}
		if(judge[0]&&judge[1]&&judge[2])
			rep(i,5)cout<<3<<endl;
		else if(judge[0]&&judge[1]&&!judge[2])
			rep(j,5)
				if(inp[j]-1==0)	cout<<1<<endl;
				else 						cout<<2<<endl;
		else if(!judge[0]&&judge[1]&&judge[2])
			rep(j,5)
				if(inp[j]-1==1)	cout<<1<<endl;
				else 						cout<<2<<endl;
		else if(judge[0]&&!judge[1]&&judge[2])
			rep(j,5)
				if(inp[j]-1==2)	cout<<1<<endl;
				else 						cout<<2<<endl;
	}
}

C++: #include<iostream>
using namespace std;
int main(){
long x[5],y[5],h[4],i;
while(cin>>x[0]){
if(x[0]==0)break;
for(i=1;i<=3;i++)h[i]=0;
h[x[0]]++;
for(i=1;i<5;i++){cin>>x[i];h[x[i]]++;}
for(i=1;i<=3;i++)if(h[i]==0||h[i]==5)break;
if(i==4||h[i]==5){
for(i=0;i<5;i++)cout<<"3"<<endl;
}else if(i==1){
for(i=0;i<5;i++)cout<<x[i]-1<<endl;
}else if(i==2){
for(i=0;i<5;i++)cout<<(x[i]+1)%3<<endl;
}else if(i==3){
for(i=0;i<5;i++)cout<<x[i]<<endl;
}
}
return 0;
}

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

bool flag[4];
int hand[5];
int ans[5];

void solve() {
  for(int i = 0 ; i < 5 ; i++) {
    if(hand[i] == 1) flag[1] = true; //O[
    if(hand[i] == 2) flag[2] = true; //`L
    if(hand[i] == 3) flag[3] = true; //p[
  }
}

int main() { 
  while(cin >> hand[0], hand[0]) {
    for(int i = 1 ; i < 5 ; i++) cin >> hand[i];
    for(int i = 1 ; i < 4 ; i++) flag[i] = false;
    solve();
    
    for(int i = 0 ; i < 5 ; i++) { 
      if(flag[1] == true && flag[2] == true && flag[3] == false) {
	if(hand[i] == 1) ans[i] = 1;
	if(hand[i] == 2) ans[i] = 2;
      }	      
      else if(flag[1] == false && flag[2] == true && flag[3] == true) {
	if(hand[i] == 2) ans[i] = 1;
	if(hand[i] == 3) ans[i] = 2;
      }	      
      else if(flag[1] == true && flag[2] == false && flag[3] == true) {
	if(hand[i] == 3) ans[i] = 1;
	if(hand[i] == 1) ans[i] = 2;
      }
      else ans[i] = 3;
    }

    for(int i = 0 ; i < 5 ; i++) {
      cout << ans[i] << endl;
    }
  }
  return 0;
}

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

int main(){
	while(1){
		int j[5], rps[3] = {0};

		cin>>j[0];
		if(j[0] == 0)
			break;
		
		for(int i=1;i<5;i++)
			cin>>j[i];

		for(int i=0;i<5;i++)
			rps[j[i]-1]++;

		if((rps[0] != 0) && (rps[1] != 0) && (rps[2] != 0)){
			for(int i=0;i<5;i++)
				j[i] = 3;
		}else if((rps[0] == 5) || (rps[1] == 5) || (rps[2] == 5)){
			for(int i=0;i<5;i++)
				j[i] = 3;
		}else if(rps[0] == 0){
			for(int i=0;i<5;i++)
				if(j[i] == 2)
					j[i] = 1;
				else
					j[i] = 2;
		}else if(rps[1] == 0){
			for(int i=0;i<5;i++)
				if(j[i] == 3)
					j[i] = 1;
				else
					j[i] = 2;
		}

		for(int i=0;i<5;i++)
			cout<<j[i]<<endl;
	}

	return 0;
}

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

int main(){
	int human[5];
	while(cin>>human[0],human[0]){
		bool hand[3]={};
		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]) 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 hand[ 5 ], ans[ 5 ];
	while( cin >> hand[ 0 ] && hand[ 0 ] ){
		int flag = 0;
		for( int i = 1; i < 5; ++i ){
			cin >> hand[ i ];
			flag |= ( 1 << ( hand[ i ] - 1 ) );
		}
		if( flag == 1 || flag == 2 || flag == 4 || flag == 7 ){
			for( int i = 0; i < 5; ++i ){
				ans[ i ] = 3;
			}
		}else{
			int win = 0;
			if( flag == 3 ) win = 1;
			if( flag == 6 ) win = 2;
			if( flag == 5 ) win = 3;
			for( int i = 0; i < 5; ++i ){
				if( hand[ i ] == win ) ans[ i ] = 1;
				else ans[ i ] = 2;
			}
		}
		for( int i = 0; i < 5; ++i ){
			cout << ans[ i ] << endl;
		}
	}
	return 0;
}