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


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

    // repeatedly reads integers until standard input is closed
    while (scanf("%d", &i) != EOF) {
        if (i == -1) {
            // prints the phone number
            printf("%s\n", phone);
        } else if (i > -1 && i < 10) {
            // prints the character at that index in the phone number
            printf("%c\n", phone[i]);
        } else {
            // prints an error message
            printf("ERROR\n");
            return 1;
        }
    }
    return 0;
}
