parseInt(x) = parse(Int, x) parseMap(x::Array{SubString{String},1}) = map(parseInt, x) function refresh(st::Array{Int,1},lt::Array{Int,1},x) n = length(st) rt = n>>1 if x<=rt st[x<<1] += lt[x] st[x<<1+1] += lt[x] lt[x] = 0 end end function main() n,q = readline() |> split |> parseMap a = readline() |> split |> parseMap k = 0 while 2^k split |> parseMap if f==1 tmp = st[rt+ll] st[rt+ll]=st[rt+rr] st[rt+rr]=tmp else rp = Int[] m = 10^18 for i in k:-1:0 l = (rt+ll)>>i r = (rt+rr)>>i if r-l>1&&i>0 if l%2==0 m=min(m,st[l+1]) end if r%2==1 m=min(m,st[r-1]) end elseif i==0 m=min(m,st[l]) m=min(m,st[r]) end end println(m) end end end main()