def solve(): n = int(input()) a = list(map(int, input().split())) ok = False for z in range(2): n = len(a) broken_adj = [] broken_even = [] broken_odd = [] for i in range(n - 1): d = a[i+1] - a[i] if i & 1 == 0 and d <= 0 or i & 1 == 1 and d >= 0: broken_adj.append(i) for i in range(n - 2): if a[i] == a[i+2]: if i & 1 == 0: broken_even.append(i) else: broken_odd.append(i) if max(map(len, [broken_adj, broken_even, broken_odd])) <= 4: cnt_tot = sum(map(len, [broken_adj, broken_even, broken_odd])) if broken_adj: s = broken_adj[0] t = s + 1 elif broken_even: s = broken_even[0] t = s + 2 else: s = broken_odd[0] t = s + 2 for i in (s, t): for j in range(n): if i == j: continue a[i], a[j] = a[j], a[i] for k in (i, j): if (0 <= k - 2 and a[k-2] == a[k] or k + 2 < n and a[k] == a[k+2] or k & 1 == 0 and ( 0 <= k - 1 and a[k-1] <= a[k] or k + 1 < n and a[k] >= a[k+1] ) or k & 1 == 1 and ( 0 <= k - 1 and a[k-1] >= a[k] or k + 1 < n and a[k] <= a[k+1] )): break else: ba = set(broken_adj) be = set(broken_even) bo = set(broken_odd) for k in (i, j): if k - 2 in bo: bo.remove(k - 2) if k - 2 in be: be.remove(k - 2) if k - 1 in ba: ba.remove(k - 1) if k in bo: bo.remove(k) if k in be: be.remove(k) if k in ba: ba.remove(k) if max(map(len, [ba, be, bo])) == 0: print('Yes') return a[i], a[j] = a[j], a[i] if z == 0: a = [0] + a print('No') return for _ in range(int(input())): solve()