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
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#include <iostream>
#include <fstream>
#include <vector>
#include <iterator>
#include <sstream>
#include <limits>
#include <tgmath.h>
#include <cstdio>
#include <list>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <map>

using namespace std;

long long n;
long long t;
long long liczbaKart;

vector<long long> karty;

template<typename T> struct czyPointer { static const bool value = false; };

template<typename T> struct czyPointer<T*> { static const bool value = true; };

template <typename T> void pisz( const T & t ) {
	ostringstream os;
	os << t;
	cout << os.str();
	cout << endl;
}

template <typename T> string str( const T & t ) {
	ostringstream os;
	os << t;
	return os.str();
}

template <typename T> void pisz_vector(const vector<T>* s) {
	for(typename vector<T>::const_iterator i = s->begin(); i != s->end(); ++i){
		cout << *i << " ";
		cout << endl;
	}
}

template <typename T> void wrzucDoWektora(vector<T>* v1, vector<T>* v2){ //wrzuca cala zawartosc v2 na koniec v1
	v1->insert(v1->end(), v2->begin(), v2->end());
}

bool parzysta(int a){
	return a%2 == 0;
}

bool nieparzysta(int a){
	return !parzysta(a);
}

void czytaj(){
	string a;
	long long param = 0;

	bool pierwszyWers = true;

	//freopen("in/tas0.in", "r", stdin);

	while(cin >> a){
		param++;
		if(pierwszyWers){
            istringstream is(a);
            if(param == 1){
                is >> n;
            }else{
                is >> t;
                param = 0;
                pierwszyWers = false;
            }
		}else{
            istringstream is(a);
            long long mWartosc;
            is >> mWartosc;
            karty.push_back(mWartosc);
		}
	}
}

void tasuj(vector<long long>* kart, long long tas){
    if(kart->size() == 2){
        reverse(kart->begin(), kart->end());
    }else{
        if(nieparzysta(tas)){
            reverse(kart->begin(), kart->end());
        }else{
            // wynik jest identyczny jak talia kart na poczatku -> nie nie rob
        }/**
        size_t srodek = kart->size()/2;
        vector<long long>::const_iterator srodekIterator(kart->cbegin());
        advance(srodekIterator, srodek);
        vector<long long> gora(kart->cbegin(), srodekIterator);
        vector<long long> dol(srodekIterator, kart->cend());
        tasuj(&gora);
        tasuj(&dol);
        kart->clear();
        wrzucDoWektora(kart, &dol);
        wrzucDoWektora(kart, &gora);**/
    }
}

void rozwiaz(){
    liczbaKart = pow(2, n);
    vector<long long> mKarty = karty;
    tasuj(&mKarty, t);
    for(auto nowe : mKarty){
        cout<<nowe<<" ";
    }
}

int main()
{
    ios_base::sync_with_stdio(0);
    czytaj();
    rozwiaz();
    return 0;
}