#include <stdio.h>
#include <stdlib.h>

int main() {
    char phone[11];
    int num;
    int error = 0;

    scanf("%10s", phone);

    while (scanf("%d", &num) > 0) {
        if (num == -1) {
            printf("%s\n", phone);
        } else if (num >= 0 && num <= 9) {
            printf("%c\n", phone[num]);
        } else {
            printf("ERROR\n");
            error = 1;
        }
    }

    return error;
}