#include <stdio.h>

int main(){

	char phone_num[11];
	scanf("%s", phone_num);

	int a, contains_error = 0;

	while(1){
		scanf("%d", &a);

		if(a == -1){

			printf("%s\n", phone_num);

		}else if(a >= 0 && a <= 9){

			printf("%c\n", phone_num[a]);

		}else{

			printf("ERROR\n");
			contains_error = 1;

		}
	}

	if(contains_error){
		return 1;
	}else{
		return 0;
	}
}