#include <stdio.h>

int main()
{
  char phone[11];
  int code = scanf("%s", phone);
  int isError = 0;

  while (code != EOF)
  {
    int num;
    scanf("%d", &num);
    if (num == -1)
    {
      printf("%s \n", phone);
    }
    else if ((0 <= num) && (num <= 9))
    {
      printf("%c \n", phone[num]);
    }
    else
    {
      printf("ERROR \n");
      isError = 1;
    }
  }
  return isError;
}
keep taking in input until standard output is closed
