#include <iostream>
#include<cstring>
using namespace std;

const int null = 0x3f3f3f3f;
const int N = 1010;
int e[N];
int d;
bool isempty = true;
void preorder(int i, int h) {
    if (e[i] == null)return;
    if (h == d) {
        isempty = false;
        cout << e[i] << ' ';
    }
    preorder(2 * i, h + 1);
    preorder(2 * i + 1, h + 1);
}
int main() {
    int n;

    while (cin >> n ) { // 注意 while 处理多个 case
        memset(e, 0x3f, sizeof e);
        isempty = true;
        for (int i = 1; i <= n; i++)cin >> e[i];
        cin >> d;
        preorder(1, 1);
        if (isempty)cout << "EMPTY" << endl;
        cout << endl;
    }
}
// 64 位输出请用 printf("%lld")