1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// 2003 was a great year for music.  that has nothing to do with this code but i just - i just needed to tell someone
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstring>
#include <cassert>
using namespace std;
#define rep(i,a,n) for (int i=a;i<(n);i++)
#define per(i,a,n) for (int i=(n)-1;i>=(a);i--)
template<typename T> ostream& operator<<(ostream& s, vector<T> t) {
    rep(i, 0, t.size()) s << (i ? " " : "") << t[i]; return s;
}
typedef long long ll;


int main() {
    ios_base::sync_with_stdio(false);
    int n, t;
    cin >> n >> t;
    n = 1 << n;
    vector<int> a(n);
    rep(i, 0, n) cin >> a[i];
    if (t % 2) reverse(a.begin(), a.end());
    cout << a << endl;
    return 0;
}