#include <cstdio>
using namespace std;

int main(){
    int a[5];
    while(scanf("%d%d%d%d%d", a, a+1, a+2, a+3, a+4)!=EOF){
        int b = 0;
        for(int x = 0; x < 5; x++){
            b = b | (1 << (a[x]-1));
        }
        if( b == 1 || b == 2 || b == 4 || b == 7){
            printf("3\n3\n3\n3\n3\n");
        }else if( b == 3 ){
            for(int x = 0; x < 5; x++){
                printf("%d\n", (a[x]-1)?2:1);
            }
        }else if( b == 5 ){
            for(int x = 0; x < 5; x++){
                printf("%d\n", (a[x]-3)?2:1);
            }
        }else if( b == 6 ){
            for(int x = 0; x < 5; x++){
                printf("%d\n", (a[x]-2)?2:1);
            }
        }
    }
    return 0;
}