func main() var n: int :: cui@inputInt() var t: []int :: #[n]int var s: []char :: #[n]char var cnt: int :: 0 for i(0, n - 1) do t[i] :: cui@inputInt() if(t[i] = 1) do cnt :+ 1 end if do s[i] :: cui@inputChar() end for var s1: []char :: #[cnt]char var s2: []char :: #[n - cnt]char var iS1: int :: 0 var iS2: int :: 0 for i(0, n - 1) if(t[i] = 1) do s1[iS1] :: s[i] do iS1 :+ 1 else do s2[iS2] :: s[i] do iS2 :+ 1 end if end for do s1.reverse() do cui@print("\{s1}\{s2}\n") end func