local q = io.read("*n") local a = {} local c = {} local function solve() local n = io.read("*n") for i = 1, 2 * n do a[i] = io.read("*n") end if a[1] ~= 1 then return false end local spos = 0 for i = 2, n + 1 do if i <= n and a[i] ~= i then spos = i - 1 break elseif i == n + 1 and a[i] ~= 1 then spos = i - 1 break end end if 0 < spos then local tpos = spos + n for i = spos + 1, tpos - 1 do local j = spos + tpos - i if j <= i then break end a[i], a[j] = a[j], a[i] end end for i = 1, n do if a[i] ~= i then return false end if a[n + i] ~= i then return false end end return true end for iq = 1, q do print(solve() and "Yes" or "No") end