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
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.util.StringTokenizer;

public class tas {

	public static String solve(Reader in) throws IOException {
		
		int noOfCards = (int)Math.pow(2, (long)(in.nextInt()));
		int noOfActions = in.nextInt();

		int[] cards = new int[noOfCards];
		for (int i=0; i<noOfCards; i++) {
			cards[i] = in.nextInt();
		}

		StringBuilder sb = new StringBuilder();
		if (noOfActions % 2 == 0) {
			for (int c: cards) {
				sb.append(c).append(" ");
			}	
		} else {
			for (int i = noOfCards - 1; i>=0; i--) {
				sb.append(cards[i]).append(" ");
			}
		}
		
		return sb.toString();
	}
	
	
	public static void main(String[] args) throws IOException {
		Reader reader = new Reader(System.in);
		Writer writer = new Writer(System.out);
		String solution = solve(reader); 
		writer.println(solution);
		writer.flush();
	}
	
	/** Class for buffered reading int, long and double values */
	public static class Reader {
		BufferedReader reader;
		StringTokenizer tokenizer;

		public Reader(InputStream input) {
			reader = new BufferedReader(new InputStreamReader(input));
			tokenizer = new StringTokenizer("");
		}

		/** get next word */
		String next() throws IOException {
			while (!tokenizer.hasMoreTokens()) {
				String str = reader.readLine();
				if (str == null) {
					return null;
				}
				tokenizer = new StringTokenizer(str);
			}
			return tokenizer.nextToken();
		}

		int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
		
		long nextLong() throws IOException {
			return Long.parseLong(next());
		}
	}

	/** Class for buffered writing int and double values */
	public static class Writer {
		BufferedWriter writer;

		public Writer(OutputStream out) {
			writer = new BufferedWriter(new OutputStreamWriter(out), 512);
		}
		
		void print(char c) throws IOException {
			writer.write(c);
		}

		void print(String str) throws IOException {
			writer.write(str);
		}

		void println(String str) throws IOException {
			writer.write(str);
			writer.write("\n");
		}

		void println() throws IOException {
			writer.write("\n");
		}

		void flush() throws IOException {
			writer.flush();
		}

		@Override
		protected void finalize() {
			try {
				writer.flush();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}
}