#include<stdio.h>
#include<time.h>
#include<stdlib.h>
#include<string.h>
#include<vector>

struct man{
  char nick[55];
  bool isSpy;
  int voted;
};

man spy[105];
man nor[105];
int cntSpy, cntNor, oriNor, tarNor, leftNor;
int cntTot;

bool tarIsSpy;
int tarVoted, tarVotedCnt, tarVotedPos;
char tarNick[55];

void init(){

  srand(time(NULL));

  while(1){
    man tmp; int isSpy;
    if(scanf("%s %d", tmp.nick, &isSpy)==EOF) break;
    if(isSpy == 1){
      tmp.isSpy = true;
      spy[cntSpy++] = tmp;
    }
    else{
      tmp.isSpy = false;
      nor[cntNor++] = tmp;
    }
  }

  oriNor = cntNor;
  leftNor = tarNor = (oriNor + 1) / 2;
}

int getRand(int maxVal){
  return rand()%maxVal;
}

void voteAll(int voter, char nick[]){
  int tar;
  int cnt = cntSpy + cntNor;
  int rnd;
  while( (rnd = getRand(cnt) ) == voter);
  if( rnd >= cntNor ){
    spy[rnd-cntNor].voted++;
    if(tarVoted == spy[rnd-cntNor].voted) tarVotedCnt++;
    if(tarVoted < spy[rnd-cntNor].voted){
      tarVotedCnt = 1;
      tarVoted = spy[rnd-cntNor].voted;
      tarVotedPos = rnd-cntNor;
      tarIsSpy = true;
      strcpy(tarNick,spy[rnd-cntNor].nick);
    }
    printf("%s -> %s",nick, spy[rnd-cntNor].nick);
  }
  else{
    nor[rnd].voted++;
    if(tarVoted == nor[rnd].voted) tarVotedCnt++;
    if(tarVoted < nor[rnd].voted){
      tarVotedCnt = 1;
      tarVoted = nor[rnd].voted;
      tarVotedPos = rnd;
      tarIsSpy = false;
      strcpy(tarNick,nor[rnd].nick);
    }
    printf("%s -> %s",nick, nor[rnd].nick);
  }
}

void voteNor(char nick[]){
  int tar;
  int cnt = cntNor;
  int rnd = getRand(cnt);
  nor[rnd].voted++;
  if(tarVoted == nor[rnd].voted) tarVotedCnt++;
  if(tarVoted < nor[rnd].voted){
    tarVotedCnt = 1;
    tarVoted = nor[rnd].voted;
    tarVotedPos = rnd;
    tarIsSpy = false;
    strcpy(tarNick,nor[rnd].nick);
  }
  printf("%s -> %s",nick, nor[rnd].nick);
}

int main(){
  init();

  int dayCnt = 0;
  while(1){
    printf("%d번째 투표입니다.\n", ++dayCnt);
    for(int i=0;i<cntNor;i++){
      nor[i].voted = 0;
    }
    for(int i=0;i<cntSpy;i++){
      spy[i].voted = 0;
    }
    tarVotedCnt = 0;
    tarVoted = 0;
    tarVotedPos = -1;

    for(int i=0;i<cntNor;i++){
      if(i!=0) printf(", ");
      voteAll(i,nor[i].nick);
    }
    for(int i=0;i<cntSpy;i++){
      printf(", ");
      voteNor(spy[i].nick);
    }
    printf("\n");

    printf("%s님: %d표", nor[0].nick, nor[0].voted);
    for(int i=1 ;i<cntNor;i++){
      printf(", %s님: %d표", nor[i].nick, nor[i].voted);
    }
    for(int i=0;i<cntSpy;i++){
      printf(", %s님: %d표", spy[i].nick, spy[i].voted);
    }
    printf("\n");

    if(tarVotedCnt != 1){
      printf("※ 동표가 발생하여 이번 투표는 무효로 합니다.\n");
    }
    else{
      printf("※ 다수결로 %s님을 처형했습니다.\n", tarNick);

      if(tarIsSpy == true){
        printf("※ %s님은 스파이였습니다.\n",tarNick);
        printf("※ 일반군의 승리로 게임이 종료됩니다.\n");
        break;
      }
      else{
        for(int i = tarVotedPos; i<cntNor; i++){
          nor[i] = nor[i+1];
        }
        cntNor--;
        leftNor--;
        if(leftNor <= 0){
          printf("※ 과반의 일반군(%d명)을 처형했습니다.\n", tarNor);
          printf("※ 스파이의 승리로 게임이 종료됩니다.\n");
          break;
        }
      }
    }

    printf("\n\n");

  }


  return 0;
}


