def dfs(l,r) return l if l + 1 == r if r - l <= 3 (l ... r).to_a else mid = (r + l) / 2 [mid, dfs(l, mid), dfs(mid + 1, r)] end end K = gets.to_i puts dfs(1, 1 << K).flatten * ' '