← Home
```go
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	reader := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	var t int
	fmt.Fscan(reader, &t)

	for tc := 0; tc < t; tc++ {
		var n int
		fmt.Fscan(reader, &n)

		a := make([]int, n)
		counts := make(map[int]int)
		maxFreq := 0
		for i := 0; i < n; i++ {
			fmt.Fscan(reader, &a[i])
			counts[a[i]]++
			if counts[a[i]] > maxFreq {
				maxFreq = counts[a[i]]
			}
		}

		if maxFreq > (n+1)/2 {
			fmt.Fprintln(writer, "NO")
			continue
		}

		limitA := (n + 1) / 2
		limitB := n / 2

		A := make([]int, 0, limitA)
		B := make([]int, 0, limitB)
		
		var dfs func(int, int, int) bool
		
		memo := make(map[uint64]bool)

		dfs = func(idx, countA, countB int) bool {
			if idx == n {
				return true
			}

			state := uint64(idx)<<40 | uint64(countA)<<20 | uint64(countB)
			if val, exists := memo[state]; exists {
				return val
			}

			val := a[idx]

			if countA < limitA {
				valid := true
				if countB > 0 && countA == countB {
					if B[countB-1] == val {
						valid = false
					}
				}
				if countB > 0 && countA == countB-1 {
					if B[countA] == val {
						valid = false
					}
				}
				if countA > 0 && countA == countB {
					if B[countB-1] == val {
						valid = false
					}
				}
				
				if valid {
					A = append(A, val)
					if dfs(idx+1, countA+1, countB) {
						return true
					}
					A = A[:len(A)-1]
				}
			}

			if countB < limitB {
				valid := true
				if countA > 0 && countB == countA-1 {
					if A[countB] == val {
						valid = false
					}
				}
				if countA > 0 && countB == countA {
					if A[countB] == val {
						valid = false
					}
				}

				if valid {
					B = append(B, val)
					if dfs(idx+1, countA, countB+1) {
						return true
					}
					B = B[:len(B)-1]
				}
			}

			memo[state] = false
			return false
		}

		if dfs(0, 0, 0) {
			fmt.Fprintln(writer, "YES")
			
			// Reconstruct permutation
			p := make([]int, n)
			ptrA := 0
			ptrB := 0
			
			// Track assignments for indices
			idxA := make([]int, 0, limitA)
			idxB := make([]int, 0, limitB)
			
			// Reset and trace again
			currA := 0
			currB := 0
			for i := 0; i < n; i++ {
				val := a[i]
				if currA < limitA && A[currA] == val {
					idxA = append(idxA, i+1)
					currA++
				} else {
					idxB = append(idxB, i+1)
					currB++
				}
			}
			
			for i := 0; i < n; i++ {
				if i%2 == 0 {
					p[i] = idxA[ptrA]
					ptrA++
				} else {
					p[i] = idxB[ptrB]
					ptrB++
				}
			}
			
			for i := 0; i < n; i++ {
				if i > 0 {
					fmt.Fprint(writer, " ")
				}
				fmt.Fprint(writer, p[i])
			}
			fmt.Fprintln(writer)
		} else {
			fmt.Fprintln(writer, "NO")
		}
	}
}
```