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
33
34
35
36
37
38
39
40
#define NDEBUG
#include<bits/stdc++.h>
using namespace std;

#define REP(I,N) for(int I=0;I<(N);I++)
#define FOR(I,A,B) for(int I=(A);I<=(B);I++)
#define FORD(I,A,B) for(int I=(A);I>=(B);I--)
#define PB push_back

typedef vector<string> VS;

inline VS parse(const string &s,const int rs,const char ch=' '){string a;VS wyn;wyn.reserve(rs);REP(i,(int)s.size()) if(s[i]!=ch) a+=s[i];else if(!a.empty()){wyn.PB(a);a="";} if(!a.empty()) wyn.PB(a);return wyn;}

int n,t;

int main(){
  ios::sync_with_stdio(false);
  cin>>n>>t;
  cin.ignore();
  n=1<<n;
  t&=1;
  string line;
  line.reserve(12*n);
  getline(cin,line);
  if(t){
    string ret;
    ret.reserve(12*n);
    VS p=parse(line,n);
    FORD(i,n-1,1){
      ret+=p[i];
      ret+=" ";
    }
    ret+=p[0]+"\n";
    cout<<ret;
  } else{
    cout<<line<<"\n";
  }

  return 0;
}