import std.stdio, std.string, std.array, std.conv, std.algorithm;

void main() {
    int n = readln.chomp.to!int;
    int[] a = readln.chomp.split.to!(int[]);
    int q = readln.chomp.to!int;
    foreach (i; 0 .. q) {
        int[] tmp = readln.chomp.split.to!(int[]);
        a[tmp[0]..tmp[1]].reverse;
    }
    foreach (i, x; a) {
        x.write;
        if (i != n - 1) " ".write;
        else writeln;
    }
}
