// NOTE: it is recommended to use this even if you don't understand the following code.

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

#define MAXS 100001
#define MAXQ 100000

int    N, Q, i;
char   S[MAXS];
int    l[MAXQ], r[MAXQ];
char   ans[MAXQ][MAXS];

int main() {
    // uncomment the two following lines if you want to read/write from files
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    assert(1 == scanf("%d", &N));
    
    assert(1 == scanf("%s", S));
    
    assert(1 == scanf("%d", &Q));
    
    for (i = 0; i < Q; ++i)
        assert(2 == scanf("%d%d", &l[i], &r[i]));
    
    
    
    // INSERT YOUR CODE HERE
    
    
    for (i = 0; i < Q; ++i)
        printf("%s ", ans[i]);
    printf("\n");

    return 0;
}
