#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 cnt = 0, win = -1;
    for (int i = 0; i < 3; i++) {
      if(used[i])cnt++;
    }
    if(cnt == 1 || cnt == 3){
      draw = true;
    }
    for (int i = 0; i < 5; i++) {
      win = max(win, n[i]%3);
    }
    std::cout << "draw:" << draw << std::endl;
    if(draw){
      for (int i = 0; i < 5; i++) {
        std::cout << 3 << std::endl;
      }
    }else{
      for (int i = 0; i < 5; i++) {
        if(n[i] + 1 == win)std::cout << 1 << std::endl;
        else std::cout << 2 << std::endl;
      }
    }
  }
  return 0;
}