def dfs(l,r) mid = (r + l) / 2 mid == l ? l : [mid, dfs(l, mid), dfs(mid + 1, r)] end puts [1, dfs(2, 1 << gets.to_i)].flatten * ' '