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

int main(int argc, char **argv) {
    char phone[11];
    int i, len;

    scanf("%s %d%n", phone, &i, &len);
//  len = strlen(i);

    while (i != EOF && len == 1) {
        if (i < -1 || i > 9) {
            printf("ERROR\n");
            return 1;
        } else if (i == -1) {
            printf("%s\n", phone);
        } else { 
            printf("%c\n", phone[i]);
        }   

        scanf(" %d%n", &i, &len);
    }   

    return 0;
}
stop while loop when end-of-file reached with scanf