package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

// TwoSlices : WTF
type TwoSlices struct {
	originSlice []int
	sortSlice   []int
}

func (t TwoSlices) Len() int { return len(t.originSlice) }
func (t TwoSlices) Less(i, j int) bool {
	return t.originSlice[t.sortSlice[i]] < t.originSlice[t.sortSlice[j]]
}
func (t TwoSlices) Swap(i, j int) { t.sortSlice[i], t.sortSlice[j] = t.sortSlice[j], t.sortSlice[i] }

func main() {

	reader := bufio.NewReader(os.Stdin)

	// n, m, d
	line, _ := reader.ReadString('\n')
	//line = strings.TrimSuffix(line, "\n")
	line = line[:len(line)-2]
	numbers := strings.Split(line, " ")
	n, _ := strconv.Atoi(numbers[0])
	d, _ := strconv.Atoi(numbers[2])

	//
	line, _ = reader.ReadString('\n')
	//line = strings.TrimSuffix(line, "\n")
	line = line[:len(line)-2]
	numbers = strings.Split(line, " ")

	//  a[i], b[i]
	a := make([]int, n)
	b := make([]int, n)
	r := make([]int, n)

	for i := 0; i < n; i++ {
		nums, _ := strconv.Atoi(numbers[i])
		a[i] = nums
		b[i] = i
	}
	s := TwoSlices{originSlice: a, sortSlice: b}

	// Sort b
	sort.Sort(TwoSlices(s))

	// Day Sequence
	sequence := 1

	// Available Earliest Time
	earliest := -1

	// First : Setting 0
	r[s.sortSlice[0]] = sequence
	earliest = 0
	sequence++

	// phase
	for cur := 1; cur < n; cur++ {

		if (s.originSlice[s.sortSlice[cur]] - s.originSlice[s.sortSlice[earliest]]) > d {
			r[s.sortSlice[cur]] = r[s.sortSlice[earliest]]
			earliest = earliest + 1
		} else {
			r[s.sortSlice[cur]] = sequence
			sequence++
		}

	}

	// Output
	fmt.Printf("%v\n", sequence-1)

	for i := 0; i < n; i++ {
		fmt.Printf("%v ", r[i])
	}
	fmt.Println()

}

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

// TwoSlices : WTF
type TwoSlices struct {
	originSlice []int
	sortSlice   []int
}

func (t TwoSlices) Len() int { return len(t.originSlice) }
func (t TwoSlices) Less(i, j int) bool {
	return t.originSlice[t.sortSlice[i]] < t.originSlice[t.sortSlice[j]]
}
func (t TwoSlices) Swap(i, j int) { t.sortSlice[i], t.sortSlice[j] = t.sortSlice[j], t.sortSlice[i] }

func main() {

	reader := bufio.NewReader(os.Stdin)

	// n, m, d
	line, _ := reader.ReadString('\n')
	line = strings.TrimRight(line, "\r\n")
	//line = line[:len(line)-2]
	numbers := strings.Split(line, " ")
	n, _ := strconv.Atoi(numbers[0])
	d, _ := strconv.Atoi(numbers[2])

	//
	line, _ = reader.ReadString('\n')
	line = strings.TrimRight(line, "\r\n")
	//line = line[:len(line)-2]
	numbers = strings.Split(line, " ")

	//  a[i], b[i]
	a := make([]int, n)
	b := make([]int, n)
	r := make([]int, n)

	for i := 0; i < n; i++ {
		nums, _ := strconv.Atoi(numbers[i])
		a[i] = nums
		b[i] = i
	}
	s := TwoSlices{originSlice: a, sortSlice: b}

	// Sort b
	sort.Sort(TwoSlices(s))

	// Day Sequence
	sequence := 1

	// Available Earliest Time
	earliest := -1

	// First : Setting 0
	r[s.sortSlice[0]] = sequence
	earliest = 0
	sequence++

	// phase
	for cur := 1; cur < n; cur++ {

		if (s.originSlice[s.sortSlice[cur]] - s.originSlice[s.sortSlice[earliest]]) > d {
			r[s.sortSlice[cur]] = r[s.sortSlice[earliest]]
			earliest = earliest + 1
		} else {
			r[s.sortSlice[cur]] = sequence
			sequence++
		}

	}

	// Output
	fmt.Printf("%v\n", sequence-1)

	for i := 0; i < n; i++ {
		fmt.Printf("%v ", r[i])
	}
	fmt.Println()

}

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

// TwoSlices : WTF
type TwoSlices struct {
	originSlice []int
	sortSlice   []int
}

func (t TwoSlices) Len() int { return len(t.originSlice) }
func (t TwoSlices) Less(i, j int) bool {
	return t.originSlice[t.sortSlice[i]] < t.originSlice[t.sortSlice[j]]
}
func (t TwoSlices) Swap(i, j int) { t.sortSlice[i], t.sortSlice[j] = t.sortSlice[j], t.sortSlice[i] }

func main() {

	reader := bufio.NewReader(os.Stdin)

	// n, m, d
	line, _ := reader.ReadString('\n')
	line = strings.TrimSuffix(line, "\n")
	numbers := strings.Split(line, " ")
	n, _ := strconv.Atoi(numbers[0])
	d, _ := strconv.Atoi(numbers[2])

	fmt.Printf("x%vx Type:%T\n", numbers[2], numbers[2])

	//
	line, _ = reader.ReadString('\n')
	line = strings.TrimSuffix(line, "\n")
	numbers = strings.Split(line, " ")

	//  a[i], b[i]
	a := make([]int, n)
	b := make([]int, n)
	r := make([]int, n)

	for i := 0; i < n; i++ {
		nums, _ := strconv.Atoi(numbers[i])
		a[i] = nums
		b[i] = i
	}
	fmt.Println(a)
	s := TwoSlices{originSlice: a, sortSlice: b}

	// Sort b
	sort.Sort(TwoSlices(s))

	// Day Sequence
	sequence := 1

	// Available Earliest Time
	earliest := -1

	// First : Setting 0
	r[s.sortSlice[0]] = sequence
	earliest = 0
	sequence++

	// phase
	for cur := 1; cur < n; cur++ {

		if (s.originSlice[s.sortSlice[cur]] - s.originSlice[s.sortSlice[earliest]]) > d {
			r[s.sortSlice[cur]] = r[s.sortSlice[earliest]]
			earliest = earliest + 1
		} else {
			r[s.sortSlice[cur]] = sequence
			sequence++
		}

	}

	// Output
	fmt.Printf("%v\n", sequence-1)

	for i := 0; i < n; i++ {
		fmt.Printf("%v ", r[i])
	}
	fmt.Println()

}

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

// TwoSlices : WTF
type TwoSlices struct {
	originSlice []int
	sortSlice   []int
}

func (t TwoSlices) Len() int { return len(t.originSlice) }
func (t TwoSlices) Less(i, j int) bool {
	return t.originSlice[t.sortSlice[i]] < t.originSlice[t.sortSlice[j]]
}
func (t TwoSlices) Swap(i, j int) { t.sortSlice[i], t.sortSlice[j] = t.sortSlice[j], t.sortSlice[i] }

func main() {

	reader := bufio.NewReader(os.Stdin)

	// n, m, d
	line, _ := reader.ReadString('\n')
	line = line[:len(line)-1]
	numbers := strings.Split(line, " ")
	n, _ := strconv.Atoi(numbers[0])
	d, _ := strconv.Atoi(numbers[2])

	if numbers[2] == "3" {
		fmt.Println("Same")
	} else {
		fmt.Printf("%v %v\n", len(numbers[2]), numbers[2])

		for j := 0; j < len(numbers[2]); j++ {
			fmt.Println(j, numbers[2][j])
		}

		fmt.Println("Diff")
	}

	//
	line, _ = reader.ReadString('\n')
	line = strings.TrimSuffix(line, "\n")
	numbers = strings.Split(line, " ")

	//  a[i], b[i]
	a := make([]int, n)
	b := make([]int, n)
	r := make([]int, n)

	for i := 0; i < n; i++ {
		nums, _ := strconv.Atoi(numbers[i])
		a[i] = nums
		b[i] = i
	}
	fmt.Println(a)
	s := TwoSlices{originSlice: a, sortSlice: b}

	// Sort b
	sort.Sort(TwoSlices(s))

	// Day Sequence
	sequence := 1

	// Available Earliest Time
	earliest := -1

	// First : Setting 0
	r[s.sortSlice[0]] = sequence
	earliest = 0
	sequence++

	// phase
	for cur := 1; cur < n; cur++ {

		if (s.originSlice[s.sortSlice[cur]] - s.originSlice[s.sortSlice[earliest]]) > d {
			r[s.sortSlice[cur]] = r[s.sortSlice[earliest]]
			earliest = earliest + 1
		} else {
			r[s.sortSlice[cur]] = sequence
			sequence++
		}

	}

	// Output
	fmt.Printf("%v\n", sequence-1)

	for i := 0; i < n; i++ {
		fmt.Printf("%v ", r[i])
	}
	fmt.Println()

}

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strings"
)

// TwoSlices : WTF
type TwoSlices struct {
	originSlice []int
	sortSlice   []int
}

func (t TwoSlices) Len() int { return len(t.originSlice) }
func (t TwoSlices) Less(i, j int) bool {
	return t.originSlice[t.sortSlice[i]] < t.originSlice[t.sortSlice[j]]
}
func (t TwoSlices) Swap(i, j int) { t.sortSlice[i], t.sortSlice[j] = t.sortSlice[j], t.sortSlice[i] }

func main() {

	// n, m, d
	var n, m, d int
	fmt.Scan(&n, &m, &d)

	//
	reader := bufio.NewReader(os.Stdin)
	line, _ := reader.ReadString('\n')
	line = strings.TrimSuffix(line, "\n")
	//numbers := strings.Split(line, " ")

	//  a[i], b[i]
	a := make([]int, n)
	b := make([]int, n)
	r := make([]int, n)

	for i := 0; i < n; i++ {
		//a[i], _ = strconv.Atoi(numbers[i])
		a[i] = i
		b[i] = i
	}
	s := TwoSlices{originSlice: a, sortSlice: b}

	// Sort b
	sort.Sort(TwoSlices(s))

	// Day Sequence
	sequence := 1

	// Available Earliest Time
	earliest := -1

	// First : Setting 0
	r[s.sortSlice[0]] = sequence
	earliest = 0
	sequence++

	// phase
	for cur := 1; cur < n; cur++ {

		if (s.originSlice[s.sortSlice[cur]] - s.originSlice[s.sortSlice[earliest]]) > d {
			r[s.sortSlice[cur]] = r[s.sortSlice[earliest]]
			earliest = earliest + 1
		} else {
			r[s.sortSlice[cur]] = sequence
			sequence++
		}

	}

	// Output
	fmt.Printf("%v\n", sequence-1)

	for i := 0; i < n; i++ {
		fmt.Printf("%v ", r[i])
	}
	fmt.Println()

}

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

// TwoSlices : WTF
type TwoSlices struct {
	originSlice []int
	sortSlice   []int
}

func (t TwoSlices) Len() int { return len(t.originSlice) }
func (t TwoSlices) Less(i, j int) bool {
	return t.originSlice[t.sortSlice[i]] < t.originSlice[t.sortSlice[j]]
}
func (t TwoSlices) Swap(i, j int) { t.sortSlice[i], t.sortSlice[j] = t.sortSlice[j], t.sortSlice[i] }

func main() {

	reader := bufio.NewReader(os.Stdin)

	// n, m, d
	line, _ := reader.ReadString('\n')
	line = strings.TrimSuffix(line, "\n")
	numbers := strings.Split(line, " ")
	n, _ := strconv.Atoi(numbers[0])
	d, _ := strconv.Atoi(numbers[2])

	if numbers[2] == "3" {
		fmt.Println("Same")
	} else {
		fmt.Printf("%v %v\n", len(numbers[2]), numbers[2])
		fmt.Println("Diff")
	}

	//
	line, _ = reader.ReadString('\n')
	line = strings.TrimSuffix(line, "\n")
	numbers = strings.Split(line, " ")

	//  a[i], b[i]
	a := make([]int, n)
	b := make([]int, n)
	r := make([]int, n)

	for i := 0; i < n; i++ {
		nums, _ := strconv.Atoi(numbers[i])
		a[i] = nums
		b[i] = i
	}
	fmt.Println(a)
	s := TwoSlices{originSlice: a, sortSlice: b}

	// Sort b
	sort.Sort(TwoSlices(s))

	// Day Sequence
	sequence := 1

	// Available Earliest Time
	earliest := -1

	// First : Setting 0
	r[s.sortSlice[0]] = sequence
	earliest = 0
	sequence++

	// phase
	for cur := 1; cur < n; cur++ {

		if (s.originSlice[s.sortSlice[cur]] - s.originSlice[s.sortSlice[earliest]]) > d {
			r[s.sortSlice[cur]] = r[s.sortSlice[earliest]]
			earliest = earliest + 1
		} else {
			r[s.sortSlice[cur]] = sequence
			sequence++
		}

	}

	// Output
	fmt.Printf("%v\n", sequence-1)

	for i := 0; i < n; i++ {
		fmt.Printf("%v ", r[i])
	}
	fmt.Println()

}

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

// TwoSlices : WTF
type TwoSlices struct {
	originSlice []int
	sortSlice   []int
}

func (t TwoSlices) Len() int { return len(t.originSlice) }
func (t TwoSlices) Less(i, j int) bool {
	return t.originSlice[t.sortSlice[i]] < t.originSlice[t.sortSlice[j]]
}
func (t TwoSlices) Swap(i, j int) { t.sortSlice[i], t.sortSlice[j] = t.sortSlice[j], t.sortSlice[i] }

func main() {

	reader := bufio.NewReader(os.Stdin)

	// n, m, d
	line, _ := reader.ReadString('\n')
	line = line[:len(line)-2]
	numbers := strings.Split(line, " ")
	n, _ := strconv.Atoi(numbers[0])
	d, _ := strconv.Atoi(numbers[2])

	if numbers[2] == "3" {
		fmt.Println("Same")
	} else {
		fmt.Printf("%v %v\n", len(numbers[2]), numbers[2])

		for j := 0; j < len(numbers[2]); j++ {
			fmt.Println(j, numbers[2][j])
		}

		fmt.Println("Diff")
	}

	//
	line, _ = reader.ReadString('\n')
	line = strings.TrimSuffix(line, "\n")
	numbers = strings.Split(line, " ")

	//  a[i], b[i]
	a := make([]int, n)
	b := make([]int, n)
	r := make([]int, n)

	for i := 0; i < n; i++ {
		nums, _ := strconv.Atoi(numbers[i])
		a[i] = nums
		b[i] = i
	}
	fmt.Println(a)
	s := TwoSlices{originSlice: a, sortSlice: b}

	// Sort b
	sort.Sort(TwoSlices(s))

	// Day Sequence
	sequence := 1

	// Available Earliest Time
	earliest := -1

	// First : Setting 0
	r[s.sortSlice[0]] = sequence
	earliest = 0
	sequence++

	// phase
	for cur := 1; cur < n; cur++ {

		if (s.originSlice[s.sortSlice[cur]] - s.originSlice[s.sortSlice[earliest]]) > d {
			r[s.sortSlice[cur]] = r[s.sortSlice[earliest]]
			earliest = earliest + 1
		} else {
			r[s.sortSlice[cur]] = sequence
			sequence++
		}

	}

	// Output
	fmt.Printf("%v\n", sequence-1)

	for i := 0; i < n; i++ {
		fmt.Printf("%v ", r[i])
	}
	fmt.Println()

}

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

// TwoSlices : WTF
type TwoSlices struct {
	originSlice []int
	sortSlice   []int
}

func (t TwoSlices) Len() int { return len(t.originSlice) }
func (t TwoSlices) Less(i, j int) bool {
	return t.originSlice[t.sortSlice[i]] < t.originSlice[t.sortSlice[j]]
}
func (t TwoSlices) Swap(i, j int) { t.sortSlice[i], t.sortSlice[j] = t.sortSlice[j], t.sortSlice[i] }

func main() {

	reader := bufio.NewReader(os.Stdin)

	// n, m, d
	line, _ := reader.ReadString('\n')
	//line = strings.TrimSuffix(line, "\n")
	line = line[:len(line)-2]
	numbers := strings.Split(line, " ")
	n, _ := strconv.Atoi(numbers[0])
	d, _ := strconv.Atoi(numbers[2])

	//
	line, _ = reader.ReadString('\n')
	//line = strings.TrimSuffix(line, "\n")
	line = line[:len(line)-2]
	numbers = strings.Split(line, " ")

	//  a[i], b[i]
	a := make([]int, n)
	b := make([]int, n)
	r := make([]int, n)

	for i := 0; i < n; i++ {
		nums, _ := strconv.Atoi(numbers[i])
		a[i] = nums
		b[i] = i
	}
	fmt.Println(a)
	s := TwoSlices{originSlice: a, sortSlice: b}

	// Sort b
	sort.Sort(TwoSlices(s))

	// Day Sequence
	sequence := 1

	// Available Earliest Time
	earliest := -1

	// First : Setting 0
	r[s.sortSlice[0]] = sequence
	earliest = 0
	sequence++

	// phase
	for cur := 1; cur < n; cur++ {

		if (s.originSlice[s.sortSlice[cur]] - s.originSlice[s.sortSlice[earliest]]) > d {
			r[s.sortSlice[cur]] = r[s.sortSlice[earliest]]
			earliest = earliest + 1
		} else {
			r[s.sortSlice[cur]] = sequence
			sequence++
		}

	}

	// Output
	fmt.Printf("%v\n", sequence-1)

	for i := 0; i < n; i++ {
		fmt.Printf("%v ", r[i])
	}
	fmt.Println()

}

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

// TwoSlices : WTF
type TwoSlices struct {
	originSlice []int
	sortSlice   []int
}

func (t TwoSlices) Len() int { return len(t.originSlice) }
func (t TwoSlices) Less(i, j int) bool {
	return t.originSlice[t.sortSlice[i]] < t.originSlice[t.sortSlice[j]]
}
func (t TwoSlices) Swap(i, j int) { t.sortSlice[i], t.sortSlice[j] = t.sortSlice[j], t.sortSlice[i] }

func main() {

	reader := bufio.NewReader(os.Stdin)

	// n, m, d
	line, _ := reader.ReadString('\n')
	line = strings.TrimSuffix(line, "\n")
	numbers := strings.Split(line, " ")
	n, _ := strconv.Atoi(numbers[0])
	d, _ := strconv.Atoi(numbers[2])
	ch := numbers[2]
	x, _ := strconv.Atoi(ch)
	fmt.Println(d, ch, x)

	//
	line, _ = reader.ReadString('\n')
	line = strings.TrimSuffix(line, "\n")
	numbers = strings.Split(line, " ")

	//  a[i], b[i]
	a := make([]int, n)
	b := make([]int, n)
	r := make([]int, n)

	for i := 0; i < n; i++ {
		nums, _ := strconv.Atoi(numbers[i])
		a[i] = nums
		b[i] = i
	}
	fmt.Println(a)
	s := TwoSlices{originSlice: a, sortSlice: b}

	// Sort b
	sort.Sort(TwoSlices(s))

	// Day Sequence
	sequence := 1

	// Available Earliest Time
	earliest := -1

	// First : Setting 0
	r[s.sortSlice[0]] = sequence
	earliest = 0
	sequence++

	// phase
	for cur := 1; cur < n; cur++ {

		if (s.originSlice[s.sortSlice[cur]] - s.originSlice[s.sortSlice[earliest]]) > d {
			r[s.sortSlice[cur]] = r[s.sortSlice[earliest]]
			earliest = earliest + 1
		} else {
			r[s.sortSlice[cur]] = sequence
			sequence++
		}

	}

	// Output
	fmt.Printf("%v\n", sequence-1)

	for i := 0; i < n; i++ {
		fmt.Printf("%v ", r[i])
	}
	fmt.Println()

}

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

// TwoSlices : WTF
type TwoSlices struct {
	originSlice []int
	sortSlice   []int
}

func (t TwoSlices) Len() int { return len(t.originSlice) }
func (t TwoSlices) Less(i, j int) bool {
	return t.originSlice[t.sortSlice[i]] < t.originSlice[t.sortSlice[j]]
}
func (t TwoSlices) Swap(i, j int) { t.sortSlice[i], t.sortSlice[j] = t.sortSlice[j], t.sortSlice[i] }

func main() {

	reader := bufio.NewReader(os.Stdin)

	// n, m, d
	line, _ := reader.ReadString('\n')
	line = strings.TrimSuffix(line, "\n")
	numbers := strings.Split(line, " ")
	n, _ := strconv.Atoi(numbers[0])
	d, _ := strconv.Atoi(numbers[2])

	if numbers[2] == "3" {
		fmt.Println("Same")
	} else {
		fmt.Println("Diff")
	}

	//
	line, _ = reader.ReadString('\n')
	line = strings.TrimSuffix(line, "\n")
	numbers = strings.Split(line, " ")

	//  a[i], b[i]
	a := make([]int, n)
	b := make([]int, n)
	r := make([]int, n)

	for i := 0; i < n; i++ {
		nums, _ := strconv.Atoi(numbers[i])
		a[i] = nums
		b[i] = i
	}
	fmt.Println(a)
	s := TwoSlices{originSlice: a, sortSlice: b}

	// Sort b
	sort.Sort(TwoSlices(s))

	// Day Sequence
	sequence := 1

	// Available Earliest Time
	earliest := -1

	// First : Setting 0
	r[s.sortSlice[0]] = sequence
	earliest = 0
	sequence++

	// phase
	for cur := 1; cur < n; cur++ {

		if (s.originSlice[s.sortSlice[cur]] - s.originSlice[s.sortSlice[earliest]]) > d {
			r[s.sortSlice[cur]] = r[s.sortSlice[earliest]]
			earliest = earliest + 1
		} else {
			r[s.sortSlice[cur]] = sequence
			sequence++
		}

	}

	// Output
	fmt.Printf("%v\n", sequence-1)

	for i := 0; i < n; i++ {
		fmt.Printf("%v ", r[i])
	}
	fmt.Println()

}

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

// TwoSlices : WTF
type TwoSlices struct {
	originSlice []int
	sortSlice   []int
}

func (t TwoSlices) Len() int { return len(t.originSlice) }
func (t TwoSlices) Less(i, j int) bool {
	return t.originSlice[t.sortSlice[i]] < t.originSlice[t.sortSlice[j]]
}
func (t TwoSlices) Swap(i, j int) { t.sortSlice[i], t.sortSlice[j] = t.sortSlice[j], t.sortSlice[i] }

func main() {

	reader := bufio.NewReader(os.Stdin)

	// n, m, d
	line, _ := reader.ReadString('\n')
	line = strings.TrimSuffix(line, "\n")
	numbers := strings.Split(line, " ")
	n, _ := strconv.Atoi(numbers[0])
	d, _ := strconv.Atoi(numbers[2])

	fmt.Println(numbers[2], d)

	//
	line, _ = reader.ReadString('\n')
	line = strings.TrimSuffix(line, "\n")
	numbers = strings.Split(line, " ")

	//  a[i], b[i]
	a := make([]int, n)
	b := make([]int, n)
	r := make([]int, n)

	for i := 0; i < n; i++ {
		nums, _ := strconv.Atoi(numbers[i])
		a[i] = nums
		b[i] = i
	}
	fmt.Println(a)
	s := TwoSlices{originSlice: a, sortSlice: b}

	// Sort b
	sort.Sort(TwoSlices(s))

	// Day Sequence
	sequence := 1

	// Available Earliest Time
	earliest := -1

	// First : Setting 0
	r[s.sortSlice[0]] = sequence
	earliest = 0
	sequence++

	// phase
	for cur := 1; cur < n; cur++ {

		if (s.originSlice[s.sortSlice[cur]] - s.originSlice[s.sortSlice[earliest]]) > d {
			r[s.sortSlice[cur]] = r[s.sortSlice[earliest]]
			earliest = earliest + 1
		} else {
			r[s.sortSlice[cur]] = sequence
			sequence++
		}

	}

	// Output
	fmt.Printf("%v\n", sequence-1)

	for i := 0; i < n; i++ {
		fmt.Printf("%v ", r[i])
	}
	fmt.Println()

}

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

// TwoSlices : WTF
type TwoSlices struct {
	originSlice []int
	sortSlice   []int
}

func (t TwoSlices) Len() int { return len(t.originSlice) }
func (t TwoSlices) Less(i, j int) bool {
	return t.originSlice[t.sortSlice[i]] < t.originSlice[t.sortSlice[j]]
}
func (t TwoSlices) Swap(i, j int) { t.sortSlice[i], t.sortSlice[j] = t.sortSlice[j], t.sortSlice[i] }

func main() {

	reader := bufio.NewReader(os.Stdin)

	// n, m, d
	line, _ := reader.ReadString('\n')
	line = strings.TrimSuffix(line, "\r")
	line = strings.TrimSuffix(line, "\n")
	numbers := strings.Split(line, " ")
	n, _ := strconv.Atoi(numbers[0])
	d, _ := strconv.Atoi(numbers[2])

	fmt.Println(numbers[2], d)

	//
	line, _ = reader.ReadString('\n')
	line = strings.TrimSuffix(line, "\r")
	line = strings.TrimSuffix(line, "\n")
	numbers = strings.Split(line, " ")

	//  a[i], b[i]
	a := make([]int, n)
	b := make([]int, n)
	r := make([]int, n)

	for i := 0; i < n; i++ {
		nums, _ := strconv.Atoi(numbers[i])
		a[i] = nums
		b[i] = i
	}
	fmt.Println(a)
	s := TwoSlices{originSlice: a, sortSlice: b}

	// Sort b
	sort.Sort(TwoSlices(s))

	// Day Sequence
	sequence := 1

	// Available Earliest Time
	earliest := -1

	// First : Setting 0
	r[s.sortSlice[0]] = sequence
	earliest = 0
	sequence++

	// phase
	for cur := 1; cur < n; cur++ {

		if (s.originSlice[s.sortSlice[cur]] - s.originSlice[s.sortSlice[earliest]]) > d {
			r[s.sortSlice[cur]] = r[s.sortSlice[earliest]]
			earliest = earliest + 1
		} else {
			r[s.sortSlice[cur]] = sequence
			sequence++
		}

	}

	// Output
	fmt.Printf("%v\n", sequence-1)

	for i := 0; i < n; i++ {
		fmt.Printf("%v ", r[i])
	}
	fmt.Println()

}

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

// TwoSlices : WTF
type TwoSlices struct {
	originSlice []int
	sortSlice   []int
}

func (t TwoSlices) Len() int { return len(t.originSlice) }
func (t TwoSlices) Less(i, j int) bool {
	return t.originSlice[t.sortSlice[i]] < t.originSlice[t.sortSlice[j]]
}
func (t TwoSlices) Swap(i, j int) { t.sortSlice[i], t.sortSlice[j] = t.sortSlice[j], t.sortSlice[i] }

func main() {

	reader := bufio.NewReader(os.Stdin)

	// n, m, d
	line, _ := reader.ReadString('\n')
	line = strings.TrimSuffix(line, "\n")
	numbers := strings.Split(line, " ")
	n, _ := strconv.Atoi(numbers[0])
	d, _ := strconv.Atoi(numbers[2])

	fmt.Println(numbers[2], d)

	//
	line, _ = reader.ReadString('\n')
	line = strings.TrimSuffix(line, "\n")
	numbers = strings.Split(line, " ")

	//  a[i], b[i]
	a := make([]int, n)
	b := make([]int, n)
	r := make([]int, n)

	for i := 0; i < n; i++ {
		nums, _ := strconv.Atoi(numbers[i])
		a[i] = nums
		b[i] = i
	}
	s := TwoSlices{originSlice: a, sortSlice: b}

	// Sort b
	sort.Sort(TwoSlices(s))

	// Day Sequence
	sequence := 1

	// Available Earliest Time
	earliest := -1

	// First : Setting 0
	r[s.sortSlice[0]] = sequence
	earliest = 0
	sequence++

	// phase
	for cur := 1; cur < n; cur++ {

		if (s.originSlice[s.sortSlice[cur]] - s.originSlice[s.sortSlice[earliest]]) > d {
			r[s.sortSlice[cur]] = r[s.sortSlice[earliest]]
			earliest = earliest + 1
		} else {
			r[s.sortSlice[cur]] = sequence
			sequence++
		}

	}

	// Output
	fmt.Printf("%v\n", sequence-1)

	for i := 0; i < n; i++ {
		fmt.Printf("%v ", r[i])
	}
	fmt.Println()

}

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

// TwoSlices : WTF
type TwoSlices struct {
	originSlice []int
	sortSlice   []int
}

func (t TwoSlices) Len() int { return len(t.originSlice) }
func (t TwoSlices) Less(i, j int) bool {
	return t.originSlice[t.sortSlice[i]] < t.originSlice[t.sortSlice[j]]
}
func (t TwoSlices) Swap(i, j int) { t.sortSlice[i], t.sortSlice[j] = t.sortSlice[j], t.sortSlice[i] }

func main() {

	reader := bufio.NewReader(os.Stdin)

	// n, m, d
	var n, m, d int
	fmt.Scan(&n, &m, &d)
	line, _ := reader.ReadString('\n')

	//
	line, _ = reader.ReadString('\n')
	line = strings.TrimSuffix(line, "\n")
	numbers := strings.Split(line, " ")

	//  a[i], b[i]
	a := make([]int, n)
	b := make([]int, n)
	r := make([]int, n)

	for i := 0; i < n; i++ {
		n, _ := strconv.Atoi(numbers[i])
		a[i] = n
		b[i] = i
	}
	s := TwoSlices{originSlice: a, sortSlice: b}

	// Sort b
	sort.Sort(TwoSlices(s))

	// Day Sequence
	sequence := 1

	// Available Earliest Time
	earliest := -1

	// First : Setting 0
	r[s.sortSlice[0]] = sequence
	earliest = 0
	sequence++

	// phase
	for cur := 1; cur < n; cur++ {

		if (s.originSlice[s.sortSlice[cur]] - s.originSlice[s.sortSlice[earliest]]) > d {
			r[s.sortSlice[cur]] = r[s.sortSlice[earliest]]
			earliest = earliest + 1
		} else {
			r[s.sortSlice[cur]] = sequence
			sequence++
		}

	}

	// Output
	fmt.Printf("%v\n", sequence-1)

	for i := 0; i < n; i++ {
		fmt.Printf("%v ", r[i])
	}
	fmt.Println()

}

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

// TwoSlices : WTF
type TwoSlices struct {
	originSlice []int
	sortSlice   []int
}

func (t TwoSlices) Len() int { return len(t.originSlice) }
func (t TwoSlices) Less(i, j int) bool {
	return t.originSlice[t.sortSlice[i]] < t.originSlice[t.sortSlice[j]]
}
func (t TwoSlices) Swap(i, j int) { t.sortSlice[i], t.sortSlice[j] = t.sortSlice[j], t.sortSlice[i] }

func main() {

	reader := bufio.NewReader(os.Stdin)

	// n, m, d
	line, _ := reader.ReadString('\n')
	line = strings.TrimSuffix(line, "\n")
	numbers := strings.Split(line, " ")
	n, _ := strconv.Atoi(numbers[0])
	d, _ := strconv.Atoi(numbers[2])

	fmt.Println(numbers)

	//
	line, _ = reader.ReadString('\n')
	line = strings.TrimSuffix(line, "\n")
	numbers = strings.Split(line, " ")

	//  a[i], b[i]
	a := make([]int, n)
	b := make([]int, n)
	r := make([]int, n)

	for i := 0; i < n; i++ {
		nums, _ := strconv.Atoi(numbers[i])
		a[i] = nums
		b[i] = i
	}
	s := TwoSlices{originSlice: a, sortSlice: b}

	// Sort b
	sort.Sort(TwoSlices(s))

	// Day Sequence
	sequence := 1

	// Available Earliest Time
	earliest := -1

	// First : Setting 0
	r[s.sortSlice[0]] = sequence
	earliest = 0
	sequence++

	// phase
	for cur := 1; cur < n; cur++ {

		if (s.originSlice[s.sortSlice[cur]] - s.originSlice[s.sortSlice[earliest]]) > d {
			r[s.sortSlice[cur]] = r[s.sortSlice[earliest]]
			earliest = earliest + 1
		} else {
			r[s.sortSlice[cur]] = sequence
			sequence++
		}

	}

	// Output
	fmt.Printf("%v\n", sequence-1)

	for i := 0; i < n; i++ {
		fmt.Printf("%v ", r[i])
	}
	fmt.Println()

}

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

// TwoSlices : WTF
type TwoSlices struct {
	originSlice []int
	sortSlice   []int
}

func (t TwoSlices) Len() int { return len(t.originSlice) }
func (t TwoSlices) Less(i, j int) bool {
	return t.originSlice[t.sortSlice[i]] < t.originSlice[t.sortSlice[j]]
}
func (t TwoSlices) Swap(i, j int) { t.sortSlice[i], t.sortSlice[j] = t.sortSlice[j], t.sortSlice[i] }

func main() {

	reader := bufio.NewReader(os.Stdin)

	// n, m, d
	line, _ := reader.ReadString('\n')
	line = strings.TrimSuffix(line, "\n")
	numbers := strings.Split(line, " ")
	n, _ := strconv.Atoi(numbers[0])
	d, _ := strconv.Atoi(numbers[2])

	fmt.Println(line)

	//
	line, _ = reader.ReadString('\n')
	line = strings.TrimSuffix(line, "\n")
	numbers = strings.Split(line, " ")

	//  a[i], b[i]
	a := make([]int, n)
	b := make([]int, n)
	r := make([]int, n)

	for i := 0; i < n; i++ {
		nums, _ := strconv.Atoi(numbers[i])
		a[i] = nums
		b[i] = i
	}
	s := TwoSlices{originSlice: a, sortSlice: b}

	// Sort b
	sort.Sort(TwoSlices(s))

	// Day Sequence
	sequence := 1

	// Available Earliest Time
	earliest := -1

	// First : Setting 0
	r[s.sortSlice[0]] = sequence
	earliest = 0
	sequence++

	// phase
	for cur := 1; cur < n; cur++ {

		if (s.originSlice[s.sortSlice[cur]] - s.originSlice[s.sortSlice[earliest]]) > d {
			r[s.sortSlice[cur]] = r[s.sortSlice[earliest]]
			earliest = earliest + 1
		} else {
			r[s.sortSlice[cur]] = sequence
			sequence++
		}

	}

	// Output
	fmt.Printf("%v\n", sequence-1)

	for i := 0; i < n; i++ {
		fmt.Printf("%v ", r[i])
	}
	fmt.Println()

}

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

// TwoSlices : WTF
type TwoSlices struct {
	originSlice []int
	sortSlice   []int
}

func (t TwoSlices) Len() int { return len(t.originSlice) }
func (t TwoSlices) Less(i, j int) bool {
	return t.originSlice[t.sortSlice[i]] < t.originSlice[t.sortSlice[j]]
}
func (t TwoSlices) Swap(i, j int) { t.sortSlice[i], t.sortSlice[j] = t.sortSlice[j], t.sortSlice[i] }

func main() {

	reader := bufio.NewReader(os.Stdin)

	// n, m, d
	line, _ := reader.ReadString('\n')
	line = strings.TrimSuffix(line, "\n")
	numbers := strings.Split(line, " ")
	n, _ := strconv.Atoi(numbers[0])
	d, _ := strconv.Atoi(numbers[2])

	if numbers[2] == "3" {
		fmt.Println("Same")
	} else {
		fmt.Printf("%v %T\n", numbers[2], numbers[2])
		fmt.Println("Diff")
	}

	//
	line, _ = reader.ReadString('\n')
	line = strings.TrimSuffix(line, "\n")
	numbers = strings.Split(line, " ")

	//  a[i], b[i]
	a := make([]int, n)
	b := make([]int, n)
	r := make([]int, n)

	for i := 0; i < n; i++ {
		nums, _ := strconv.Atoi(numbers[i])
		a[i] = nums
		b[i] = i
	}
	fmt.Println(a)
	s := TwoSlices{originSlice: a, sortSlice: b}

	// Sort b
	sort.Sort(TwoSlices(s))

	// Day Sequence
	sequence := 1

	// Available Earliest Time
	earliest := -1

	// First : Setting 0
	r[s.sortSlice[0]] = sequence
	earliest = 0
	sequence++

	// phase
	for cur := 1; cur < n; cur++ {

		if (s.originSlice[s.sortSlice[cur]] - s.originSlice[s.sortSlice[earliest]]) > d {
			r[s.sortSlice[cur]] = r[s.sortSlice[earliest]]
			earliest = earliest + 1
		} else {
			r[s.sortSlice[cur]] = sequence
			sequence++
		}

	}

	// Output
	fmt.Printf("%v\n", sequence-1)

	for i := 0; i < n; i++ {
		fmt.Printf("%v ", r[i])
	}
	fmt.Println()

}

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

// TwoSlices : WTF
type TwoSlices struct {
	originSlice []int
	sortSlice   []int
}

func (t TwoSlices) Len() int { return len(t.originSlice) }
func (t TwoSlices) Less(i, j int) bool {
	return t.originSlice[t.sortSlice[i]] < t.originSlice[t.sortSlice[j]]
}
func (t TwoSlices) Swap(i, j int) { t.sortSlice[i], t.sortSlice[j] = t.sortSlice[j], t.sortSlice[i] }

func main() {

	reader := bufio.NewReader(os.Stdin)

	// n, m, d
	line, _ := reader.ReadString('\n')
	line = strings.TrimSuffix(line, "\n")
	numbers := strings.Split(line, " ")
	numbers[2] = strings.TrimSuffix(numbers[2], "\n")
	n, _ := strconv.Atoi(numbers[0])
	d, _ := strconv.Atoi(numbers[2])

	if numbers[2] == "3" {
		fmt.Println("Same")
	} else {
		fmt.Printf("%v %v\n", len(numbers[2]), numbers[2])

		for j := 0; j < len(numbers[2]); j++ {
			fmt.Println(j, numbers[2][j])
		}

		fmt.Println("Diff")
	}

	//
	line, _ = reader.ReadString('\n')
	line = strings.TrimSuffix(line, "\n")
	numbers = strings.Split(line, " ")

	//  a[i], b[i]
	a := make([]int, n)
	b := make([]int, n)
	r := make([]int, n)

	for i := 0; i < n; i++ {
		nums, _ := strconv.Atoi(numbers[i])
		a[i] = nums
		b[i] = i
	}
	fmt.Println(a)
	s := TwoSlices{originSlice: a, sortSlice: b}

	// Sort b
	sort.Sort(TwoSlices(s))

	// Day Sequence
	sequence := 1

	// Available Earliest Time
	earliest := -1

	// First : Setting 0
	r[s.sortSlice[0]] = sequence
	earliest = 0
	sequence++

	// phase
	for cur := 1; cur < n; cur++ {

		if (s.originSlice[s.sortSlice[cur]] - s.originSlice[s.sortSlice[earliest]]) > d {
			r[s.sortSlice[cur]] = r[s.sortSlice[earliest]]
			earliest = earliest + 1
		} else {
			r[s.sortSlice[cur]] = sequence
			sequence++
		}

	}

	// Output
	fmt.Printf("%v\n", sequence-1)

	for i := 0; i < n; i++ {
		fmt.Printf("%v ", r[i])
	}
	fmt.Println()

}

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

// TwoSlices : WTF
type TwoSlices struct {
	originSlice []int
	sortSlice   []int
}

func (t TwoSlices) Len() int { return len(t.originSlice) }
func (t TwoSlices) Less(i, j int) bool {
	return t.originSlice[t.sortSlice[i]] < t.originSlice[t.sortSlice[j]]
}
func (t TwoSlices) Swap(i, j int) { t.sortSlice[i], t.sortSlice[j] = t.sortSlice[j], t.sortSlice[i] }

func main() {

	reader := bufio.NewReader(os.Stdin)

	// n, m, d
	//var n, m, d int
	//fmt.Scan(&n, &m, &d)
	line, _ := reader.ReadString('\n')
	line = strings.TrimSuffix(line, "\n")
	numbers := strings.Split(line, " ")
	n, _ := strconv.Atoi(numbers[0])
	m, _ := strconv.Atoi(numbers[1])
	d, _ := strconv.Atoi(numbers[2])
	m = m + 1

	//
	line, _ = reader.ReadString('\n')
	line = strings.TrimSuffix(line, "\n")
	numbers = strings.Split(line, " ")

	//  a[i], b[i]
	a := make([]int, n)
	b := make([]int, n)
	r := make([]int, n)

	for i := 0; i < n; i++ {
		nums, _ := strconv.Atoi(numbers[i])
		a[i] = nums
		b[i] = i
	}
	s := TwoSlices{originSlice: a, sortSlice: b}

	// Sort b
	sort.Sort(TwoSlices(s))

	// Day Sequence
	sequence := 1

	// Available Earliest Time
	earliest := -1

	// First : Setting 0
	r[s.sortSlice[0]] = sequence
	earliest = 0
	sequence++

	// phase
	for cur := 1; cur < n; cur++ {

		if (s.originSlice[s.sortSlice[cur]] - s.originSlice[s.sortSlice[earliest]]) > d {
			r[s.sortSlice[cur]] = r[s.sortSlice[earliest]]
			earliest = earliest + 1
		} else {
			r[s.sortSlice[cur]] = sequence
			sequence++
		}

	}

	// Output
	fmt.Printf("%v\n", sequence-1)

	for i := 0; i < n; i++ {
		fmt.Printf("%v ", r[i])
	}
	fmt.Println()

}

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

// TwoSlices : WTF
type TwoSlices struct {
	originSlice []int
	sortSlice   []int
}

func (t TwoSlices) Len() int { return len(t.originSlice) }
func (t TwoSlices) Less(i, j int) bool {
	return t.originSlice[t.sortSlice[i]] < t.originSlice[t.sortSlice[j]]
}
func (t TwoSlices) Swap(i, j int) { t.sortSlice[i], t.sortSlice[j] = t.sortSlice[j], t.sortSlice[i] }

func main() {

	reader := bufio.NewReader(os.Stdin)

	// n, m, d
	line, _ := reader.ReadString('\n')
	line = strings.TrimSuffix(line, "\n")
	numbers := strings.Split(line, " ")
	n, _ := strconv.Atoi(numbers[0])
	d, _ := strconv.Atoi(numbers[2])

	fmt.Println(n, d)

	//
	line, _ = reader.ReadString('\n')
	line = strings.TrimSuffix(line, "\n")
	numbers = strings.Split(line, " ")

	//  a[i], b[i]
	a := make([]int, n)
	b := make([]int, n)
	r := make([]int, n)

	for i := 0; i < n; i++ {
		nums, _ := strconv.Atoi(numbers[i])
		a[i] = nums
		b[i] = i
	}
	s := TwoSlices{originSlice: a, sortSlice: b}

	// Sort b
	sort.Sort(TwoSlices(s))

	// Day Sequence
	sequence := 1

	// Available Earliest Time
	earliest := -1

	// First : Setting 0
	r[s.sortSlice[0]] = sequence
	earliest = 0
	sequence++

	// phase
	for cur := 1; cur < n; cur++ {

		if (s.originSlice[s.sortSlice[cur]] - s.originSlice[s.sortSlice[earliest]]) > d {
			r[s.sortSlice[cur]] = r[s.sortSlice[earliest]]
			earliest = earliest + 1
		} else {
			r[s.sortSlice[cur]] = sequence
			sequence++
		}

	}

	// Output
	fmt.Printf("%v\n", sequence-1)

	for i := 0; i < n; i++ {
		fmt.Printf("%v ", r[i])
	}
	fmt.Println()

}

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

// TwoSlices : WTF
type TwoSlices struct {
	originSlice []int
	sortSlice   []int
}

func (t TwoSlices) Len() int { return len(t.originSlice) }
func (t TwoSlices) Less(i, j int) bool {
	return t.originSlice[t.sortSlice[i]] < t.originSlice[t.sortSlice[j]]
}
func (t TwoSlices) Swap(i, j int) { t.sortSlice[i], t.sortSlice[j] = t.sortSlice[j], t.sortSlice[i] }

func main() {

	reader := bufio.NewReader(os.Stdin)

	// n, m, d
	line, _ := reader.ReadString('\n')
	line = strings.TrimSuffix(line, "\n")
	numbers := strings.Split(line, " ")
	n, _ := strconv.Atoi(numbers[0])
	d, _ := strconv.Atoi(numbers[2])

	if numbers[2] == "3" {
		fmt.Println("Same")
	} else {
		fmt.Printf("%v %v\n", len(numbers[2]), numbers[2])

		for j := 0; j < len(numbers[2]); j++ {
			fmt.Println(j, numbers[2][j])
		}

		fmt.Println("Diff")
	}

	//
	line, _ = reader.ReadString('\n')
	line = strings.TrimSuffix(line, "\n")
	numbers = strings.Split(line, " ")

	//  a[i], b[i]
	a := make([]int, n)
	b := make([]int, n)
	r := make([]int, n)

	for i := 0; i < n; i++ {
		nums, _ := strconv.Atoi(numbers[i])
		a[i] = nums
		b[i] = i
	}
	fmt.Println(a)
	s := TwoSlices{originSlice: a, sortSlice: b}

	// Sort b
	sort.Sort(TwoSlices(s))

	// Day Sequence
	sequence := 1

	// Available Earliest Time
	earliest := -1

	// First : Setting 0
	r[s.sortSlice[0]] = sequence
	earliest = 0
	sequence++

	// phase
	for cur := 1; cur < n; cur++ {

		if (s.originSlice[s.sortSlice[cur]] - s.originSlice[s.sortSlice[earliest]]) > d {
			r[s.sortSlice[cur]] = r[s.sortSlice[earliest]]
			earliest = earliest + 1
		} else {
			r[s.sortSlice[cur]] = sequence
			sequence++
		}

	}

	// Output
	fmt.Printf("%v\n", sequence-1)

	for i := 0; i < n; i++ {
		fmt.Printf("%v ", r[i])
	}
	fmt.Println()

}


package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
	"sort"
)

// github.com/EndlessCheng/codeforces-go
func CF1354D(_r io.Reader, _w io.Writer) {
	in := bufio.NewScanner(_r)
	in.Split(bufio.ScanWords)
	r := func() (x int) {
		in.Scan()
		data := in.Bytes()
		if data[0] == '-' {
			for _, b := range data[1:] {
				x = x*10 + int(b&15)
			}
			return -x
		}
		for _, b := range data {
			x = x*10 + int(b&15)
		}
		return
	}

	n, q := r(), r()
	a := make([]int, n)
	for i := range a {
		a[i] = r()
	}
	b := make([]int, q)
	for i := range b {
		b[i] = r()
	}
	ans := sort.Search(1e6+1, func(x int) bool {
		c := 0
		for _, v := range a {
			if v <= x {
				c++
			}
		}
		for _, v := range b {
			if v > 0 {
				if v <= x {
					c++
				}
			} else if -v <= c {
				c--
			}
		}
		return c > 0
	})
	if ans == 1e6+1 {
		ans = 0
	}
	Fprint(_w, ans)
}

func main() { CF1354D(os.Stdin, os.Stdout) }

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
	"sort"
)

// github.com/EndlessCheng/codeforces-go
func CF1354D(_r io.Reader, _w io.Writer) {
	in := bufio.NewScanner(_r)
	in.Split(bufio.ScanWords)
	r := func() (x int) {
		in.Scan()
		data := in.Bytes()
		if data[0] == '-' {
			for _, b := range data[1:] {
				x = x*10 + int(b&15)
			}
			return -x
		}
		for _, b := range data {
			x = x*10 + int(b&15)
		}
		return
	}

	n, q := r(), r()
	a := make([]int, n)
	for i := range a {
		a[i] = r()
	}
	b := make([]int, q)
	for i := range b {
		b[i] = r()
	}
	f := func(x int) (c int) {
		for _, v := range a {
			if v <= x {
				c++
			}
		}
		for _, v := range b {
			if v > 0 {
				if v <= x {
					c++
				}
			} else if -v <= c {
				c--
			}
		}
		return
	}
	if f(1e9) == 0 {
		Fprint(_w, 0)
	} else {
		Fprint(_w, sort.Search(1e6+1, func(x int) bool { return f(x) > 0 }))
	}
}

func main() { CF1354D(os.Stdin, os.Stdout) }

package main

import (
	. "fmt"
	"io"
	"os"
	"sort"
)

// github.com/EndlessCheng/codeforces-go
func CF1354D(_r io.Reader, _w io.Writer) {
	buf := make([]byte, 4096)
	_i := len(buf)
	rc := func() byte {
		if _i == len(buf) {
			_r.Read(buf)
			_i = 0
		}
		b := buf[_i]
		_i++
		return b
	}
	r := func() (x int) {
		b := rc()
		neg := false
		for ; '0' > b; b = rc() {
			if b == '-' {
				neg = true
			}
		}
		for ; '0' <= b; b = rc() {
			x = x*10 + int(b&15)
		}
		if neg {
			return -x
		}
		return
	}

	n, q := r(), r()
	a := make([]int, n)
	for i := range a {
		a[i] = r()
	}
	b := make([]int, q)
	for i := range b {
		b[i] = r()
	}
	f := func(x int) (c int) {
		for _, v := range a {
			if v <= x {
				c++
			}
		}
		for _, v := range b {
			if v > 0 {
				if v <= x {
					c++
				}
			} else if -v <= c {
				c--
			}
		}
		return
	}
	if f(1e9) == 0 {
		Fprint(_w, 0)
	} else {
		Fprint(_w, sort.Search(1e6, func(x int) bool { return f(x) > 0 }))
	}
}

func main() { CF1354D(os.Stdin, os.Stdout) }


package main

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

func main() {
    start := time.Now()
    defer func () {
        run := time.Since(start)
        _ = run
        // fmt.Println("Run in", run)
    }()

    stdin := bufio.NewReader(os.Stdin)

    var n int
    var s string

    fmt.Fscanln(stdin, &n)
    fmt.Fscanln(stdin, &s)

    var markFront = make([]bool, n)
    var markBack = make([]bool, n)
    var cntFront = make([]int, n)
    var cntBack = make([]int, n)

    Value := func (x int) int {
        if s[x] == 40 {
            return 1
        } else {
            return -1
        }
    }

    for i,cnt:=0, 0; i < n; i++ {
        cnt += Value(i)
        cntFront[i] = cnt
        if i > 0 {
            markFront[i] = (cnt >= 0) && markFront[i - 1]
            // cntFront[i] = cntFront[i-1] + cnt
        } else {
            markFront[i] = (cnt >= 0)
            // cntFront[i] = cnt
        }
    }

    for i, cnt:= n-1, 0; i >=0; i-- {
        cnt += Value(i)
        cntBack[i] = cnt
        if i < n-1 {
            markBack[i] = (cnt <= 0) && markBack[i+1]
            // cntBack[i] = cntBack[i+1] + cnt
        } else {
            markBack[i] = (cnt <= 0)
            // cntBack[i] = cnt
        }
    }

    Check := func (x int) (bool, int, int) {
        var front, back = true, true
        var resFront, resBack int
        if x > 0 {
            front = markFront[x-1]
            resFront = cntFront[x-1]
        }
        if x < n - 1 {
            back = markBack[x+1]
            resBack = cntBack[x+1]
        }
        return front && back, resFront, resBack
    }

    var res int
    for i := 0; i < n; i++ {
        var check, front, back = Check(i)
        // fmt.Println("Check at", i, check, front, back)
        if check {
            var cnt = Value(i) * -1
            if front + cnt >= 0 && back + cnt <= 0 && front + cnt + back == 0 {
                res++
            }
        }
    }

    //fmt.Println(markFront)
    //fmt.Println(markBack)
    //fmt.Println(cntFront, cntBack)
    fmt.Println(res)
}

package main

import (
	"bytes"
	"fmt"
	"io/ioutil"
	"os"
)

func handle(s string) int {
	n := len(s)
	ans := 0
	// '(' -> ')'
	d := 0
	diff := make([]int, n)
	for i := 0;i < n;i ++ {
		if s[i] == '(' {
			d ++
		} else {
			d --
		}
		diff[i] = d
	}
	for i := 0;i < n;i ++ {
		if diff[i] < 0 {
			return 0
		} else if diff[i] < 2 {
			ans = 0
		} else if diff[i] >= 2 && s[i] == '(' {
			ans ++
		}
	}
	return ans
}

func main() {
	bs, _ := ioutil.ReadAll(os.Stdin)
	reader := bytes.NewBuffer(bs)

	var n int
	var s string
	fmt.Fscanf(reader, "%d\n", &n)
	fmt.Fscanf(reader, "%s", &s)
	d := 0
	for i := 0;i < n;i ++ {
		if s[i] == '(' {
			d ++
		} else {
			d --
		}
	}
	if d != 2 && d != -2 {
		fmt.Printf("0")
		return
	} else if d == 2 {
		fmt.Printf("%d", handle(s))
	} else {
		b0 := []byte(s)
		b1 := make([]byte, n)
		for i := 0;i < n;i ++ {
			b1[i] = b0[n - i - 1]
			if b1[i] == '(' {
				b1[i] = ')'
			} else {
				b1[i] = '('
			}
		}
		fmt.Printf("%d", handle(string(b1)))
	}

}

package main

import (
	"bytes"
	"fmt"
	"io/ioutil"
	"os"
)

func handle(s string) int {
	n := len(s)
	ans := 0
	// '(' -> ')'
	d := 0
	for i := 0;i < n;i ++ {
		if s[i] == '(' {
			d ++
		} else {
			d --
		}
		if d == 0 {
			ans = 0
		}
		if s[i] == '(' && d >= 2 {
			ans ++
		}
		if d < -2 {
			return 0
		}
	}
	return ans
}

func main() {
	bs, _ := ioutil.ReadAll(os.Stdin)
	reader := bytes.NewBuffer(bs)

	var n int
	var s string
	fmt.Fscanf(reader, "%d\n", &n)
	fmt.Fscanf(reader, "%s", &s)
	d := 0
	for i := 0;i < n;i ++ {
		if s[i] == '(' {
			d ++
		} else {
			d --
		}
	}
	if d != 2 && d != -2 {
		fmt.Printf("0")
		return
	} else if d == 2 {
		fmt.Printf("%d", handle(s))
	} else {
		b0 := []byte(s)
		b1 := make([]byte, n)
		for i := 0;i < n;i ++ {
			b1[i] = b0[n - i - 1]
			if b1[i] == '(' {
				b1[i] = ')'
			} else {
				b1[i] = '('
			}
		}
		fmt.Printf("%d", handle(string(b1)))
	}

}

package main

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

type pair struct {
	b byte
	p int
}

func NewPair(b byte, p int) pair {
	return pair{b: b, p: p}
}

func main() {
	start := time.Now()
	defer func() {
		run := time.Since(start)
		_ = run
		// fmt.Println("Run in", run)
	}()

	var stdin *bufio.Reader
	// LOCAL
	f, _ := os.Open("input.txt")
	stdin = bufio.NewReader(f)

	// ONLINE JUDGE
	stdin = bufio.NewReader(os.Stdin)

	var n int
	fmt.Fscanln(stdin, &n)
	var s string
	fmt.Fscanln(stdin, &s)

	var stack = []pair{NewPair(s[0], 0)}
	for i := 1; i < n; i++ {
		stack = append(stack, NewPair(s[i], i))
		if len(stack) > 1 && stack[len(stack)-1].b == 41 && stack[len(stack)-2].b == 40 {
			stack = stack[:len(stack)-2]
		}
	}
	if len(stack) == 2 {
		if stack[0].b == 40 {
			fmt.Println(stack[1].p + 1)
		} else if stack[1].b == 41 {
			fmt.Println(stack[0].p + 1)
		} else {
			fmt.Println(0)
		}
	} else {
		fmt.Println(0)
	}
	// fmt.Println(stack)
}


package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

func solve(_r io.Reader, _w io.Writer) {

	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)

	defer out.Flush()

	var n, T int
	Fscan(in, &T)
	for ; T > 0; T-- {
		Fscan(in, &n)
		a := make([]int, n+1)
		r := make([]int, n+2)
		for i := 1; i <= n; i++ {
			Fscan(in, &a[i])
			r[i] = n
		}
		r[n+1] = n
		for i := n; i >= 1; i-- {
			r[i] = min(r[i], r[i+1])
			if a[i] >= i {
				continue
			}
			r[i-a[i]] = min(r[i-a[i]], i-1)
		}
		var res int64
		for i := 1; i <= n; i++ {
			res += int64(r[i] - i + 1)
		}
		Fprintln(out, res)
	}

}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func gcd(x, y int) int {
	if y == 0 {
		return x
	}
	return gcd(y, x%y)
}

func lcm(x, y int) int {
	return x / gcd(x, y) * y
}

func main() { solve(os.Stdin, os.Stdout) }

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

func main() {
	c1736(os.Stdin, os.Stdout)
}

func c1736(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var T int
	var n int
	var x int

	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n)
		a := make([]int, n)

		for i := 0; i < n; i++ {
			Fscan(in, &x)
			a[i] = x
		}

		ans := 0
		s := 0
		l := 0
		for e, v := range a {
			l++
			for s < e && v < l {
				s++
				l--
			}
			ans += e - s + 1
		}

		Fprintln(out, ans)
	}
}

package main

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

var sc = bufio.NewScanner(os.Stdin)

const INF = 1e18
const N = 2e5 + 5

func main() {
	sc.Buffer(make([]byte, 500000*1+1), 500000)
	sc.Split(bufio.ScanWords)

	f := make([]int, N)
	for i := 1; i < N; i++ {
		f[i] = f[i-1] + i
	}
	// fmt.Println(f[5])
	T := nextInt()
	for T > 0 {
		T--
		n := nextInt()
		a := make([]int, n)
		for i := 0; i < n; i++ {
			a[i] = nextInt()
		}
		ans := 0
		for l, r := 0, 0; l < n; l++ {
			for r < n && a[r] >= r-l+1 {
				r++
			}
			ans += r - l
		}
		fmt.Println(ans)
	}
}

func min(args ...int) int {
	res := args[0]
	for _, v := range args {
		if v < res {
			res = v
		}
	}
	return res
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

package main

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

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }

func solve() {
	var n int
	scanf("%d\n", &n)
	a := make([]int, n+1)
	for i:=1; i<=n; i++ {
		scanf("%d ", &a[i])
	}
	scanf("\n")

	i, j := 0, 1
	var res int64 = 0
	for j <= n {
		if a[j] >= (j - i) {
			res += int64(j-i)
			j++
			continue
		}
		i++
	}
	printf("%v\n", res)
}

func main() {
	defer writer.Flush()

	var T int
	scanf("%d\n", &T)
	for tt:=1; tt<=T; tt++ {
		solve()
	}
}

package main

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

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

	var T int
	fmt.Fscan(in, &T)
	for t := 0; t < T; t++ {
		var n int
		fmt.Fscan(in, &n)
		aa := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &aa[i])
		}

		var tot int64
		j, k := 0, 1
		for i := 0; i < n; i++ {
			for j < n && aa[i] < k {
				j++
				k--
			}
			tot += int64(i - j + 1)
			k++
		}
		fmt.Fprintln(out, tot)
	}
}

package main

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

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

	var T int
	for fmt.Fscan(r, &T); T > 0; T-- {

		var n int
		fmt.Fscan(r, &n)

		a := make([]int, n)

		for i := range a {
			fmt.Fscan(r, &a[i])
		}

		res := 1
		cnt := 1
		for i, v := range a {
			if i == 0 { continue }
			if v > cnt {
				cnt++
			} else {
				cnt = v
			}
			res += cnt
		}

		fmt.Fprintln(w, res)
	}

}

package main

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

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

	var T int
	fmt.Fscan(in, &T)
	for t := 0; t < T; t++ {
		var n int
		fmt.Fscan(in, &n)
		aa := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &aa[i])
		}

		tot := int64(n)
		for i := 2; i <= n; i++ {
			for j := 0; j+i <= n; j++ {
				d := -1
				for k := 0; k < i; k++ {
					if aa[j+k] < k+1 {
						d = j + k
						break
					}
				}
				if d < 0 {
					tot++
				} else {
					j = d - 1
				}
			}
		}
		fmt.Fprintln(out, tot)
	}
}

package main

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

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

	var T int
	fmt.Fscan(in, &T)
	for t := 0; t < T; t++ {
		var n int
		fmt.Fscan(in, &n)
		aa := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &aa[i])
		}

		tot := int64(n)
		for i := 2; i <= n; i++ {
			for j := 0; j+i <= n; j++ {
				d := -1
				for k := 0; k < i; k++ {
					if aa[j+k] < k+1 {
						d = j + k
					}
				}
				if d < 0 {
					tot++
				} else {
					j = d - 1
				}
			}
		}
		fmt.Fprintln(out, tot)
	}
}

package main

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

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

	var T int
	for fmt.Fscan(r, &T); T > 0; T-- {

		var n int
		fmt.Fscan(r, &n)

		a := make([]int, n)
		// b := make([]int, n+1)
		fact := make([]int, n+1)
		for i := range fact {
			if i == 0 {
				fact[i] = 1
			} else {
				fact[i] = fact[i-1] * i
			}
		}

		for i := range a {
			fmt.Fscan(r, &a[i])
		}

		cmp := 0
		res := 0
		for _, v := range a {
			if v > cmp {
				cmp++
			} else {
				res += fact[cmp]
				cmp = 1
			}
		}
		res += fact[cmp]
		/*
		res := 0
		cnt := 0
		for i := range b {
			fmt.Fprintln(w, "%%%%% ", b[i], cnt, res)
			if b[i] == 0 {
				res += fact[cnt]
				cnt = 0
			} else {
				cnt++
			}
		}
		*/

		fmt.Fprintln(w, res)
	}

}


package main
import (
  "fmt"
)
var (
  x[600] int
  t =0
)
func main() {
  fmt.Scanf("%d\n",&t)
  for ;t>0;t-- {
    n,f,sum:=0,0,0
    _,err:=fmt.Scanf("%d\n",&n)
    if err !=nil{
      fmt.Println("INPUT ERROR")
      return
    }
    for  i := 1 ; i <= n ;i++ {
      fmt.Scanf("%d",&x[i])
      sum += x[i]
    }
    fmt.Scanln()
    for i := 2 ; i * i <= sum ; i++ {
      if sum % i == 0 {
        f = 1
        break
      }
    }
    if f == 1 {
      fmt.Printf("%d\n",n)
      for  i := 1 ; i <= n ;i++ {
        fmt.Printf("%d ",i)

        //sum += x[i]
      }
    }else {
      fmt.Printf("%d\n",n - 1)
      f = 0
      for  i := 1 ; i <= n ;i++ {
        if x[i] % 2 == 0 {
          fmt.Printf("%d ",i)
        } else if f == 1 {
          fmt.Printf("%d ",i)
        }else {
          f = 1
        }
        //sum += x[i]
      }

    }
    fmt.Printf("\n")
  }

  //fmt.Println(t)
}

package main

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

func IsPrime(n int) bool {
	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			return false
		}
	}
	return n != 1
}

func solve() {
	f := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	N, n := 0, 0
	fmt.Fscan(f, &N)
	for i := 0; i < N; i++ {
		fmt.Fscan(f, &n)
		o, sum := []int{}, 0
		for j := 0; j < n; j++ {
			p := 0
			fmt.Fscan(f, &p)
			o = append(o, p)
			sum += p
		}
		if !IsPrime(sum) {
			fmt.Fprint(w, n, "\n")
			for j := 0; j < n; j++ {
				fmt.Fprint(w, j+1, " ")
			}
		} else {
			for j := 0; j < n; j++ {
				if !IsPrime(sum - o[j]) {
					fmt.Fprint(w, n-1, "\n")
					for k := 0; k < n; k++ {
						if k != j {
							fmt.Fprint(w, k+1, " ")
						}
					}
					break
				}
			}
		}
		fmt.Fprintln(w, "")
	}
	w.Flush()
}

func main() {
	solve()
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"
)

func main() {
	reader := bufio.NewReaderSize(os.Stdin, 16 * 1024 * 1024)

	stdout := os.Stdout

	defer stdout.Close()

	writer := bufio.NewWriterSize(stdout, 16 * 1024 * 1024)

	tTemp, err := strconv.ParseInt(readLine(reader), 10, 64)
	checkError(err)
	t := int(tTemp)

	for t > 0 {
		nTemp, err := strconv.ParseInt(readLine(reader), 10, 64)
		checkError(err)
		n := int(nTemp)

		arTemp := strings.Split(strings.TrimSpace(readLine(reader)), " ")

		var ar []int

		for i := 0; i < n; i++ {
			arItemTemp, err := strconv.ParseInt(arTemp[i], 10, 64)
			checkError(err)
			arItem := int(arItemTemp)
			ar = append(ar, arItem)
		}

		var sum int
		var idx int
		for i, v := range ar {
			if v % 2 != 0 {
				idx = i
			}
			sum += v
		}

		var x = n - 1
		for s := 2; s <= int(math.Sqrt(float64(sum))) + 1; s++ {
			if sum % s == 0 {
				x = n
				break
			}
		}

		if x == n - 1 {
			fmt.Fprintln(writer, x)
			for i := 0; i < n; i++ {
				if i != idx {
					fmt.Fprintf(writer, "%d ", i+1)
				}
			}
		} else {
			fmt.Fprintf(writer, "%d\n", x)
			for i := 0; i < n; i++ {
				fmt.Fprintf(writer, "%d ", i+1)
			}
		}
		fmt.Fprintln(writer)

		t--
	}

	writer.Flush()
}

func readLine(reader *bufio.Reader) string {
	str, _, err := reader.ReadLine()
	if err == io.EOF {
		return ""
	}

	return strings.TrimRight(string(str), "\r\n")
}

func checkError(err error) {
	if err != nil {
		panic(err)
	}
}

package main

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

var (
	reader = bufio.NewReader(os.Stdin)
	t, n   int
)

func isPrime(x int) bool {
	for i := 2; i*i <= x; i++ {
		if x%i == 0 {
			return false
		}
	}
	return true
}

func solve(n int, a []int) {
	var sum, p int
	for i, x := range a {
		sum += x
		if x%2 == 1 {
			p = i
		}
	}
	if isPrime(sum) {
		fmt.Println(n - 1)
		for i := range a {
			if i != p {
				fmt.Print(i+1, " ")
			}
		}
		fmt.Println()
		return
	}
	fmt.Println(n)
	for i := range a {
		fmt.Print(i+1, " ")
	}
	fmt.Println()
	return
}

func main() {
	fmt.Fscan(reader, &t)
	for ; t > 0; t-- {
		fmt.Fscan(reader, &n)
		a := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(reader, &a[i])
		}
		solve(n, a)
	}
}

package main

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

var (
	input = bufio.NewReader(os.Stdin)
	output = bufio.NewWriter(os.Stdout)
)

func assert(test bool) {
    if !test {panic("assert!")}
}

func main() {
    //solve()
    //return
	var t int
	fmt.Fscan(input, &t)
    for t > 0 {
        t--
        solve()
    }
	output.Flush()
}

func solve() {
    var n int
    fmt.Fscan(input, &n)
    a := make([]int, n)
    sum := 0
    for i := 0; i < n; i++ {
        fmt.Fscan(input, &a[i])
        sum += a[i]
    }
    if !isPrime(sum) {
        out(a)
        return
    }
    // find odd elem
    fmt.Fprintln(output, len(a) - 1)
    skipped := false
    for i := 0; i < len(a); i++ {
        if !skipped && a[i] % 2 == 1 {
            skipped = true
            continue
        }
        fmt.Fprint(output, i + 1, " ")
    }
    fmt.Fprintln(output)
}

func isPrime(x int) bool {
    for i := 2; i*i <= x; i++ {
        if x % i == 0 {
            return false
        }
    }
    return true
}
func out(a []int) {
    fmt.Fprintln(output, len(a))
    for i := 0; i < len(a); i++ {
        fmt.Fprint(output, i + 1, " ")
    }
    fmt.Fprintln(output)
}

package main

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

func main() {

	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in, &t)
	for ; t > 0; t-- {
		var n int
		fmt.Fscan(in, &n)
		a := make([]int, n)
		b := make([]int, n)
		var sum int = 0
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &a[i])
			sum += a[i]
		}
		for i := 0; i < len(b); i++ {
			b[i] = i
		}
		sort.Slice(b, func(l, r int) bool {
			return a[b[l]]%2 < a[b[r]]%2
		})
		var flag int = 1
		for i := 2; i*i <= sum; i++ {
			if sum%i == 0 {
				flag -= 1
			}
		}
		var n_len int = n
		if flag == 1 {
			n_len--
		}
		fmt.Fprint(out, n_len, "\n")
		for i := 0; i < n_len; i++ {
			fmt.Fprint(out, b[i]+1, " ")
		}
		fmt.Fprintln(out)
	}
}

package main
import (
  "C"
  "fmt"
)
var (
  x[600] int
  t =0
)
func main() {
  fmt.Scanf("%d\n",&t)
  for ;t>0;t-- {
    n,f,sum:=0,0,0
    _,err:=fmt.Scanf("%d\n",&n)
    if err !=nil{
      fmt.Println("INPUT ERROR")
      return
    }
    for  i := 1 ; i <= n ;i++ {
      fmt.Scanf("%d",&x[i])
      sum += x[i]
    }
    fmt.Scanln()
    for i := 2 ; i * i <= sum ; i++ {
      if sum % i == 0 {
        f = 1
        break
      }
    }
    if f == 1 {
      fmt.Printf("%d\n",n)
      for  i := 1 ; i <= n ;i++ {
        fmt.Printf("%d ",i)

        //sum += x[i]
      }
    }else {
      fmt.Printf("%d\n",n - 1)
      f = 0
      for  i := 1 ; i <= n ;i++ {
        if x[i] % 2 == 0 {
          fmt.Printf("%d ",i)
        } else if f == 1 {
          fmt.Printf("%d ",i)
        }else {
          f = 1
        }
        //sum += x[i]
      }

    }
    fmt.Printf("\n")
  }

  //fmt.Println(t)
}

package main
import (
  "fmt"
)
var (
  x = make([]int,600)
  t =0
)
func main() {
  fmt.Scanf("%d\n",&t)
  for ;t>0;t-- {
    n,f,sum:=0,0,0
    _,err:=fmt.Scanf("%d\n",&n)
    if err !=nil{
      fmt.Println("INPUT ERROR")
      return
    }
    for  i := 1 ; i <= n ;i++ {
      fmt.Scanf("%d",&x[i])
      sum += x[i]
    }
    fmt.Scanln()
    for i := 2 ; i * i <= sum ; i++ {
      if sum % i == 0 {
        f = 1
        break
      }
    }
    if f == 1 {
      fmt.Printf("%d\n",n)
      for  i := 1 ; i <= n ;i++ {
        fmt.Printf("%d ",i)

        //sum += x[i]
      }
    }else {
      fmt.Printf("%d\n",n - 1)
      f = 0
      for  i := 1 ; i <= n ;i++ {
        if x[i] % 2 == 0 {
          fmt.Printf("%d ",i)
        } else if f == 1 {
          fmt.Printf("%d ",i)
        }else {
          f = 1
        }
        //sum += x[i]
      }

    }
    fmt.Printf("\n")
  }

  //fmt.Println(t)
}

package main

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

/*
5
3
8 1 2
4
6 9 4 2
9
1 2 3 4 5 6 7 8 9
3
200 199 198
3
6 5 2
---
2
2 1
4
2 1 4 3
9
6 9 1 2 3 4 5 7 8
3
1 2 3
2
1 3
==========
1
4
4 5 8 6
---
3
1 2 4
*/

//goland:noinspection GoUnhandledErrorResult
func main() {
	defer writer.Flush()

	var t int
	scanf("%d\n", &t)

	bld := strings.Builder{}

	for k := 0; k < t; k++ {
		var n int
		scanf("%d\n", &n)

		sum := 0
		a := make([]int, n)
		for i := 0; i < n; i++ {
			scanf("%d", &a[i])
			sum += a[i]
		}
		scanf("\n")

		if !isPrime(sum) {
			fmt.Fprintf(&bld, "%d\n", n)
			for i := range a {
				fmt.Fprintf(&bld, "%d ", i+1)
			}
		} else {
			fmt.Fprintf(&bld, "%d\n", n-1)

			excluded := false
			for i, v := range a {
				if !excluded && v%2 == 1 {
					excluded = true
					continue
				}

				fmt.Fprintf(&bld, "%d ", i+1)
			}
		}
		fmt.Fprintf(&bld, "\n")
	}

	printf("%s", bld.String())
}

func isPrime(n int) bool {
	if n == 2 || n == 3 {
		return true
	}

	if n <= 1 || n%2 == 0 || n%3 == 0 {
		return false
	}

	for i := 5; i*i <= n; i += 6 {
		if n%i == 0 || n%(i+2) == 0 {
			return false
		}
	}

	return true
}

const maxUint = ^uint(0)

//goland:noinspection GoUnusedConst
const minUint = 0
const maxInt = int(maxUint >> 1)

//goland:noinspection GoUnusedConst
const minInt = -maxInt - 1

//goland:noinspection GoUnusedType
type pair struct {
	fst, snd int
}

var reader = bufio.NewReader(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

//goland:noinspection GoUnusedFunction
func printf(f string, a ...interface{}) {
	if _, err := fmt.Fprintf(writer, f, a...); err != nil {
		panic(err)
	}
}

func scanf(f string, a ...interface{}) {
	if _, err := fmt.Fscanf(reader, f, a...); err != nil {
		panic(err)
	}
}

//goland:noinspection GoUnusedFunction
func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

//goland:noinspection GoUnusedFunction
func max(x, y int64) int64 {
	if x > y {
		return x
	}
	return y
}

//goland:noinspection GoUnusedFunction
func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

package main

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

func main() {
	CF1583A(os.Stdin, os.Stdout)
}

func CF1583A(in io.Reader, out io.Writer) {
	r := bufio.NewReader(in)
	w := bufio.NewWriter(out)
	defer w.Flush()

	var T int
	for fmt.Fscan(r, &T); T > 0; T-- {
		var n int
		fmt.Fscan(r, &n)
		arr := make([]int, n)
		var total int
		for i := 0; i < n; i++ {
			fmt.Fscan(r, &arr[i])
			total += int(arr[i])
		}
		found := 0
		for j := 2; j*j <= total; j++ {
			if total%j == 0 {
				found = 1
				break
			}
		}
		fmt.Fprintln(w, n+found-1)
		for i, v := range arr {
			if v%2 == 1 && found == 0 {
				found = 1
			} else {
				fmt.Fprint(w, i+1, " ")
			}
		}
		fmt.Fprintln(w)
	}
}

package main
import (
  "C"
  "fmt"
)
var (
  x[600] int
  t =0
)
func main() {
  fmt.Scanf("%d",&t)
  for ;t>0;t-- {
    n,f,sum:=0,0,0
    _,err:=fmt.Scanf("%d",&n)
    if err !=nil{
      fmt.Println("INPUT ERROR")
      return
    }
    for  i := 1 ; i <= n ;i++ {
      fmt.Scanf("%d",&x[i])
      sum += x[i]
    }
    //fmt.Scanln()
    for i := 2 ; i * i <= sum ; i++ {
      if sum % i == 0 {
        f = 1
        break
      }
    }
    if f == 1 {
      fmt.Printf("%d\n",n)
      for  i := 1 ; i <= n ;i++ {
        fmt.Printf("%d ",i)

        //sum += x[i]
      }
    }else {
      fmt.Printf("%d\n",n - 1)
      f = 0
      for  i := 1 ; i <= n ;i++ {
        if x[i] % 2 == 0 {
          fmt.Printf("%d ",i)
        } else if f == 1 {
          fmt.Printf("%d ",i)
        }else {
          f = 1
        }
        //sum += x[i]
      }

    }
    fmt.Printf("\n")
  }

  //fmt.Println(t)
}

package main
import (
  "fmt"
)
var (
  x = make([]int,600)
  t =0
)
func main() {
  fmt.Scanf("%d\n",&t)
  for ;t>0;t-- {
    n,f,sum:=0,0,0
    _,err:=fmt.Scanf("%d",&n)
    if err !=nil{
      fmt.Println("INPUT ERROR")
      return
    }
    for  i := 1 ; i <= n ;i++ {
      fmt.Scanf("%d",&x[i])
      sum += x[i]
    }
    for i := 2 ; i * i <= sum ; i++ {
      if sum % i == 0 {
        f = 1
        break
      }
    }
    if f == 1 {
      fmt.Printf("%d\n",n)
      for  i := 1 ; i <= n ;i++ {
        fmt.Printf("%d ",i)

        //sum += x[i]
      }
    }else {
      fmt.Printf("%d\n",n - 1)
      f = 0
      for  i := 1 ; i <= n ;i++ {
        if x[i] % 2 == 0 {
          fmt.Printf("%d ",i)
        } else if f == 1 {
          fmt.Printf("%d ",i)
        }else {
          f = 1
        }
        //sum += x[i]
      }

    }
    fmt.Printf("\n")
  }

  //fmt.Println(t)
}

package main
import (
  "fmt"
)
var (
  x = make([]int,600)
  t =0
)
func main() {
  fmt.Scanf("%d",&t)
  for ;t>0;t-- {
    n,f,sum:=0,0,0
    _,err:=fmt.Scanf("%d",&n)
    if err !=nil{
      fmt.Println("INPUT ERROR")
      return
    }
    for  i := 1 ; i <= n ;i++ {
      fmt.Scanf("%d",&x[i])
      sum += x[i]
    }
    for i := 2 ; i * i <= sum ; i++ {
      if sum % i == 0 {
        f = 1
        break
      }
    }
    if f == 1 {
      fmt.Printf("%d\n",n)
      for  i := 1 ; i <= n ;i++ {
        fmt.Printf("%d ",i)

        //sum += x[i]
      }
    }else {
      fmt.Printf("%d\n",n - 1)
      f = 0
      for  i := 1 ; i <= n ;i++ {
        if x[i] % 2 == 0 {
          fmt.Printf("%d ",i)
        } else if f == 1 {
          fmt.Printf("%d ",i)
        }else {
          f = 1
        }
        //sum += x[i]
      }

    }
    fmt.Printf("\n")
  }

  //fmt.Println(t)
}

package main
import (
  "fmt"
)
var (
  x = make([]int,600)
  t =0
)
func main() {
  fmt.Scanf("%v",&t)
  for ;t>0;t-- {
    n,f,sum:=0,0,0
    _,err:=fmt.Scanf("%v",&n)
    if err !=nil{
      fmt.Println("INPUT ERROR")
      return
    }
    for  i := 1 ; i <= n ;i++ {
      fmt.Scanf("%v",&x[i])
      sum += x[i]
    }
    for i := 2 ; i * i <= sum ; i++ {
      if sum % i == 0 {
        f = 1
        break
      }
    }
    if f == 1 {
      fmt.Printf("%d\n",n)
      for  i := 1 ; i <= n ;i++ {
        fmt.Printf("%d ",i)

        //sum += x[i]
      }
    }else {
      fmt.Printf("%d\n",n - 1)
      f = 0
      for  i := 1 ; i <= n ;i++ {
        if x[i] % 2 == 0 {
          fmt.Printf("%d ",i)
        } else if f == 1 {
          fmt.Printf("%d ",i)
        }else {
          f = 1
        }
        //sum += x[i]
      }

    }
    fmt.Printf("\n")
  }

  //fmt.Println(t)
}

package main
import (
  "fmt"
)
var (
  x = make([]int,600)
  t =0
)
func main() {
  fmt.Scanf("%v",&t)
  for ;t>0;t-- {
    n,f,sum:=0,0,0
    fmt.Scanf("%v",&n)
    for  i := 1 ; i <= n ;i++ {
      fmt.Scanf("%v",&x[i])
      sum += x[i]
    }
    for i := 2 ; i * i <= sum ; i++ {
      if sum % i == 0 {
        f = 1
        break
      }
    }
    if f == 1 {
      fmt.Printf("%d\n",n)
      for  i := 1 ; i <= n ;i++ {
        fmt.Printf("%d ",i)

        //sum += x[i]
      }
    }else {
      fmt.Printf("%d\n",n - 1)
      f = 0
      for  i := 1 ; i <= n ;i++ {
        if x[i] % 2 == 0 {
          fmt.Printf("%d ",i)
        } else if f == 1 {
          fmt.Printf("%d ",i)
        }else {
          f = 1
        }
        //sum += x[i]
      }

    }
    fmt.Printf("\n")
  }

  //fmt.Println(t)
}

package main
import (
  "fmt"
)
var (
  x = make([]int,600)
  t =0
)
func main() {
  fmt.Scanf("%d",&t)
  for ;t>0;t-- {
    n,f,sum:=0,0,0
    fmt.Scanf("%d",&n)
    for  i := 1 ; i <= n ;i++ {
      fmt.Scanf("%d",&x[i])
      sum += x[i]
    }
    for i := 2 ; i * i <= sum ; i++ {
      if sum % i == 0 {
        f = 1
        break
      }
    }
    if f == 1 {
      fmt.Printf("%d\n",n)
      for  i := 1 ; i <= n ;i++ {
        fmt.Printf("%d ",i)

        //sum += x[i]
      }
    }else {
      fmt.Printf("%d\n",n - 1)
      f = 0
      for  i := 1 ; i <= n ;i++ {
        if x[i] % 2 == 0 {
          fmt.Printf("%d ",i)
        } else if f == 1 {
          fmt.Printf("%d ",i)
        }else {
          f = 1
        }
        //sum += x[i]
      }

    }
    fmt.Printf("\n")
  }

  //fmt.Println(t)
}

package main
import (
  "fmt"
)
var x[600] int
func main() {
  var t int
  fmt.Scanf("%d",&t)
  for ;t>0;t-- {
    n,f,sum:=0,0,0
    fmt.Scanf("%d",&n)
    for  i := 1 ; i <= n ;i++ {
      fmt.Scanf("%d",&x[i])
      sum += x[i]
    }
    for i := 2 ; i * i <= sum ; i++ {
      if sum % i == 0 {
        f = 1
        break
      }
    }
    if f == 1 {
      fmt.Printf("%d\n",n)
      for  i := 1 ; i <= n ;i++ {
        fmt.Printf("%d ",i)

        //sum += x[i]
      }
    }else {
      fmt.Printf("%d\n",n - 1)
      f = 0
      for  i := 1 ; i <= n ;i++ {
        if x[i] % 2 == 0 {
          fmt.Printf("%d ",i)
        } else if f == 1 {
          fmt.Printf("%d ",i)
        }else {
          f = 1
        }
        //sum += x[i]
      }

    }
    fmt.Printf("\n")
  }

  //fmt.Println(t)
}

package main

import (
  "fmt"
)
var x[600] int
func main() {
  var t int
  fmt.Scanln(&t)
  for {
    if t == 0 {
      break
    }
    t--
    var n int
    fmt.Scanln(&n)
     sum := 0
    for  i := 1 ; i <= n ;i++ {
      fmt.Scanf("%d",&x[i])
      sum += x[i]
    }
    f := 0
    for i := 2 ; i * i <= sum ; i++ {
      if sum % i == 0 {
        f = 1
        break
      }
    }
    if f == 1 {
      fmt.Println(n)
      for  i := 1 ; i <= n ;i++ {
        fmt.Printf("%d ",i)

        //sum += x[i]
      }
    }else {
      fmt.Println(n - 1)
      f = 0
      for  i := 1 ; i <= n ;i++ {
        if x[i] % 2 == 0 {
          fmt.Printf("%d ",i)
        } else if f == 1 {
          fmt.Printf("%d ",i)
        }else {
          f = 1
        }
        //sum += x[i]
      }

    }
    fmt.Println()
  }

  //fmt.Println(t)
}

package main

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

/*
5
3
8 1 2
4
6 9 4 2
9
1 2 3 4 5 6 7 8 9
3
200 199 198
3
6 5 2
---
2
2 1
4
2 1 4 3
9
6 9 1 2 3 4 5 7 8
3
1 2 3
2
1 3
==========
1
4
4 5 8 6
---
3
1 2 4
*/

//goland:noinspection GoUnhandledErrorResult
func main() {
	defer writer.Flush()

	var t int
	scanf("%d\n", &t)

	bld := strings.Builder{}

	for k := 0; k < t; k++ {
		var n int
		scanf("%d\n", &n)

		sum := 0
		a := make([]int, n)
		for i := 0; i < n; i++ {
			scanf("%d", &a[i])
			sum += a[i]
		}
		scanf("\n")

		if isComposite(sum) {
			fmt.Fprintf(&bld, "%d\n", n)
			for i := range a {
				fmt.Fprintf(&bld, "%d ", i+1)
			}
		} else {
			excluded := false
			fmt.Fprintf(&bld, "%d\n", n-1)
			for i, v := range a {
				if !excluded && v%2 == 1 {
					excluded = true
					continue
				}

				fmt.Fprintf(&bld, "%d ", i+1)
			}
		}
		fmt.Fprintf(&bld, "\n")
	}

	printf("%s", bld.String())
}

func isComposite(n int) bool {
	return (n%2 == 0 && n != 2) ||
		(n%3 == 0 && n != 3) ||
		(n%5 == 0 && n != 5) ||
		(n%7 == 0 && n != 7) ||
		(n%11 == 0 && n != 11) ||
		(n%13 == 0 && n != 13)
}

const maxUint = ^uint(0)

//goland:noinspection GoUnusedConst
const minUint = 0
const maxInt = int(maxUint >> 1)

//goland:noinspection GoUnusedConst
const minInt = -maxInt - 1

//goland:noinspection GoUnusedType
type pair struct {
	fst, snd int
}

var reader = bufio.NewReader(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

//goland:noinspection GoUnusedFunction
func printf(f string, a ...interface{}) {
	if _, err := fmt.Fprintf(writer, f, a...); err != nil {
		panic(err)
	}
}

func scanf(f string, a ...interface{}) {
	if _, err := fmt.Fscanf(reader, f, a...); err != nil {
		panic(err)
	}
}

//goland:noinspection GoUnusedFunction
func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

//goland:noinspection GoUnusedFunction
func max(x, y int64) int64 {
	if x > y {
		return x
	}
	return y
}

//goland:noinspection GoUnusedFunction
func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

package main

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

/*
5
3
8 1 2
4
6 9 4 2
9
1 2 3 4 5 6 7 8 9
3
200 199 198
3
6 5 2
---
2
2 1
4
2 1 4 3
9
6 9 1 2 3 4 5 7 8
3
1 2 3
==========
1
3
6 5 2
---
1
3
*/

//goland:noinspection GoUnhandledErrorResult
func main() {
	defer writer.Flush()

	var t int
	scanf("%d\n", &t)

	bld := strings.Builder{}

	for i := 0; i < t; i++ {
		var n int
		scanf("%d\n", &n)

		a := make([]int, n)
		for j := 0; j < n; j++ {
			scanf("%d", &a[j])
		}
		scanf("\n")

		for j := 1; j < n; j++ {
			a[j] += a[j-1]
		}

		start := -1
		end := -2

		for j := 0; j < n; j++ {
			for k := j; k < n; k++ {
				snd := 0
				if j-1 >= 0 {
					snd = a[j-1]
				}
				sum := a[k] - snd
				if isComposite(sum) {
					if k-j > end-start {
						start = j
						end = k
					}
				}
			}
		}

		if start >= 0 {
			fmt.Fprintf(&bld, "%d\n", end-start+1)
			for j := start; j <= end; j++ {
				fmt.Fprintf(&bld, "%d ", j+1)
			}
			fmt.Fprintf(&bld, "\n")
		}
	}

	printf("%s", bld.String())
}

func isComposite(n int) bool {
	return (n%2 == 0 && n != 2) ||
		(n%3 == 0 && n != 3) ||
		(n%5 == 0 && n != 5) ||
		(n%7 == 0 && n != 7) ||
		(n%11 == 0 && n != 11) ||
		(n%13 == 0 && n != 13)
}

const maxUint = ^uint(0)

//goland:noinspection GoUnusedConst
const minUint = 0
const maxInt = int(maxUint >> 1)

//goland:noinspection GoUnusedConst
const minInt = -maxInt - 1

//goland:noinspection GoUnusedType
type pair struct {
	fst, snd int
}

var reader = bufio.NewReader(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

//goland:noinspection GoUnusedFunction
func printf(f string, a ...interface{}) {
	if _, err := fmt.Fprintf(writer, f, a...); err != nil {
		panic(err)
	}
}

func scanf(f string, a ...interface{}) {
	if _, err := fmt.Fscanf(reader, f, a...); err != nil {
		panic(err)
	}
}

//goland:noinspection GoUnusedFunction
func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

//goland:noinspection GoUnusedFunction
func max(x, y int64) int64 {
	if x > y {
		return x
	}
	return y
}

//goland:noinspection GoUnusedFunction
func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

package main

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

/*
5
3
8 1 2
4
6 9 4 2
9
1 2 3 4 5 6 7 8 9
3
200 199 198
3
1 1 1
---
2
2 1
4
2 1 4 3
9
6 9 1 2 3 4 5 7 8
3
1 2 3
==========
1
3
8 1 2
*/

//goland:noinspection GoUnhandledErrorResult
func main() {
	defer writer.Flush()

	var t int
	scanf("%d\n", &t)

	bld := strings.Builder{}

	for i := 0; i < t; i++ {
		var n int
		scanf("%d\n", &n)

		a := make([]int, n)
		for j := 0; j < n; j++ {
			scanf("%d", &a[j])
		}
		scanf("\n")

		for j := 1; j < n; j++ {
			a[j] += a[j-1]
		}

		start := -1
		end := -1

		for j := 0; j < n; j++ {
			for k := j + 1; k < n; k++ {
				snd := 0
				if j-1 >= 0 {
					snd = a[j-1]
				}
				sum := a[k] - snd
				if isComposite(sum) {
					if k-j > end-start {
						start = j
						end = k
					}
				}
			}
		}

		if start >= 0 {
			fmt.Fprintf(&bld, "%d\n", end-start+1)
			for j := start; j <= end; j++ {
				fmt.Fprintf(&bld, "%d ", j+1)
			}
			fmt.Fprintf(&bld, "\n")
		}
	}

	printf("%s", bld.String())
}

func isComposite(n int) bool {
	return (n%2 == 0 && n != 2) ||
		(n%3 == 0 && n != 3) ||
		(n%5 == 0 && n != 5) ||
		(n%7 == 0 && n != 7) ||
		(n%11 == 0 && n != 11) ||
		(n%13 == 0 && n != 13)
}

const maxUint = ^uint(0)

//goland:noinspection GoUnusedConst
const minUint = 0
const maxInt = int(maxUint >> 1)

//goland:noinspection GoUnusedConst
const minInt = -maxInt - 1

//goland:noinspection GoUnusedType
type pair struct {
	fst, snd int
}

var reader = bufio.NewReader(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

//goland:noinspection GoUnusedFunction
func printf(f string, a ...interface{}) {
	if _, err := fmt.Fprintf(writer, f, a...); err != nil {
		panic(err)
	}
}

func scanf(f string, a ...interface{}) {
	if _, err := fmt.Fscanf(reader, f, a...); err != nil {
		panic(err)
	}
}

//goland:noinspection GoUnusedFunction
func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

//goland:noinspection GoUnusedFunction
func max(x, y int64) int64 {
	if x > y {
		return x
	}
	return y
}

//goland:noinspection GoUnusedFunction
func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

package main

import (
	"fmt"
	"math"
	"os"
)

func main() {
	var t int
	_, _ = fmt.Scanf("%d\n", &t)

	for t > 0 {
		var n int
		_, _ = fmt.Scanf("%d\n", &n)

		var a = make([]int, n)
		_, _ = fmt.Fscan(os.Stdin, packAddrs(a)...)

		var sum int
		var idx int
		for i, v := range a {
			if v % 2 != 0 {
				idx = i
			}
			sum += v
		}

		var x = n - 1
		for s := 2; s <= int(math.Sqrt(float64(sum))) + 1; s++ {
			if sum % s == 0 {
				x = n
				break
			}
		}

		if x == n - 1 {
			fmt.Println(x)
			for i := 0; i < n; i++ {
				if i != idx {
					fmt.Print(i+1, " ")
				}
			}
		} else {
			fmt.Println(x)
			for i := 0; i < n; i++ {
				fmt.Print(i+1, " ")
			}
		}
		fmt.Println()

		t--
	}

}

func packAddrs(n []int) []interface{} {
	p := make([]interface{}, len(n))
	for i := range n {
		p[i] = &n[i]
	}
	return p
}

package main

import (
	"fmt"
	"math"
	"os"
)

func main() {
	var t int
	_, _ = fmt.Scanf("%d", &t)

	for t > 0 {
		var n int
		_, _ = fmt.Scanf("%d", &n)

		var a = make([]int, n)
		_, _ = fmt.Fscan(os.Stdin, packAddrs(a)...)

		var sum int
		var idx int
		for i, v := range a {
			if v % 2 != 0 {
				idx = i
			}
			sum += v
		}

		var x = n - 1
		for s := 2; s <= int(math.Sqrt(float64(sum))) + 1; s++ {
			if sum % s == 0 {
				x = n
				break
			}
		}

		if x == n - 1 {
			fmt.Println(x)
			for i := 0; i < n; i++ {
				if i != idx {
					fmt.Print(i+1, " ")
				}
			}
		} else {
			fmt.Println(x)
			for i := 0; i < n; i++ {
				fmt.Print(i+1, " ")
			}
		}
		fmt.Println()

		t--
	}

}

func packAddrs(n []int) []interface{} {
	p := make([]interface{}, len(n))
	for i := range n {
		p[i] = &n[i]
	}
	return p
}

package main

import (
	"fmt"
	"math"
	"os"
)

func main() {
	var t int
	_, _ = fmt.Scanf("%d", &t)

	for t > 0 {
		var n int
		_, _ = fmt.Scanf("%d", &n)

		var a = make([]int, n)
		_, _ = fmt.Fscan(os.Stdin, packAddrs(a)...)

		var sum int
		var idx int
		for i, v := range a {
			if v % 2 != 0 {
				idx = i
			}
			sum += v
		}

		var x = n
		for s := 2; s <= int(math.Sqrt(float64(sum))) + 1; s++ {
			if sum % s == 0 {
				x = n
				break
			}
		}

		if x == 0 {
			x--
			fmt.Println(x)
			for i := 0; i < n; i++ {
				if i != idx {
					fmt.Print(i+1, " ")
				}
			}
		} else {
			fmt.Println(x)
			for i := 0; i < n; i++ {
				fmt.Print(i+1, " ")
			}
		}
		fmt.Println()

		t--
	}

}

func packAddrs(n []int) []interface{} {
	p := make([]interface{}, len(n))
	for i := range n {
		p[i] = &n[i]
	}
	return p
}

package main

import (
	"fmt"
	"math"
	"os"
)

func main() {
	var t int
	_, _ = fmt.Scanf("%d", &t)

	for t > 0 {
		var n int
		_, _ = fmt.Scanf("%d", &n)

		var a = make([]int, n)
		_, _ = fmt.Fscan(os.Stdin, packAddrs(a)...)

		var sum int
		var idx int
		for i, v := range a {
			if v % 2 != 0 {
				idx = i
			}
			sum += v
		}

		var x int
		for s := 2; s <= int(math.Sqrt(float64(sum))) + 1; s++ {
			if sum % s == 0 {
				x = n
				break
			}
		}

		if x == 0 {
			x--
			fmt.Println(x)
			for i := 0; i < n; i++ {
				if i != idx {
					fmt.Print(i+1, " ")
				}
			}
		} else {
			fmt.Println(x)
			for i := 0; i < n; i++ {
				fmt.Print(i+1, " ")
			}
		}

		t--
	}

}

func packAddrs(n []int) []interface{} {
	p := make([]interface{}, len(n))
	for i := range n {
		p[i] = &n[i]
	}
	return p
}

package main

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

var (
	input = bufio.NewReader(os.Stdin)
	output = bufio.NewWriter(os.Stdout)
)

func assert(test bool) {
    if !test {panic("assert!")}
}

func main() {
    //solve()
    //return
	var t int
	fmt.Fscan(input, &t)
    for t > 0 {
        t--
        solve()
    }
	output.Flush()
}

func solve() {
    var n int
    fmt.Fscan(input, &n)
    a := make([]int, n)
    sum := 0
    for i := 0; i < n; i++ {
        fmt.Fscan(input, &a[i])
        sum += a[i]
    }
    if n % 2 == 0 || !isPrime(sum) {
        out(a)
        return
    }
    // find odd elem
    fmt.Fprintln(output, len(a) - 1)
    skipped := false
    for i := 0; i < len(a); i++ {
        if !skipped && a[i] % 2 == 1 {
            skipped = true
            continue
        }
        fmt.Fprint(output, i + 1, " ")
    }
    fmt.Fprintln(output)
}

func isPrime(x int) bool {
    for i := 2; i*i <= x; i++ {
        if x % i == 0 {
            return false
        }
    }
    return true
}
func out(a []int) {
    fmt.Fprintln(output, len(a))
    for i := 0; i < len(a); i++ {
        fmt.Fprint(output, i + 1, " ")
    }
    fmt.Fprintln(output)
}

package main

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

var (
	input = bufio.NewReader(os.Stdin)
	output = bufio.NewWriter(os.Stdout)
)

func assert(test bool) {
    if !test {panic("assert!")}
}

func main() {
    //solve()
    //return
	var t int
	fmt.Fscan(input, &t)
    for t > 0 {
        t--
        solve()
    }
	output.Flush()
}

func solve() {
    var n int
    fmt.Fscan(input, &n)
    a := make([]int, n)
    sum := 0
    for i := 0; i < n; i++ {
        fmt.Fscan(input, &a[i])
        sum += a[i]
    }
    if n % 2 == 0 || !isPrime(sum) {
        out(a)
        return
    }
    // find odd elem
    fmt.Fprintln(output, len(a) - 1)
    skipped := false
    for i := 0; i < len(a); i++ {
        if !skipped && a[i] % 2 == 1 {
            skipped = true
            continue
        }
        fmt.Fprint(output, i + 1, " ")
    }
    fmt.Fprintln(output)
}

func isPrime(x int) bool {
    for i := 2; i*i <= x; i++ {
        if x % i == 0 {
            return false
        }
    }
    return true
}
func out(a []int) {
    fmt.Fprintln(output, len(a))
    for i := 0; i < len(a); i++ {
        fmt.Fprint(output, a[i], " ")
    }
    fmt.Fprintln(output)
}

package main

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

var (
	input = bufio.NewReader(os.Stdin)
	output = bufio.NewWriter(os.Stdout)
)

func assert(test bool) {
    if !test {panic("assert!")}
}

func main() {
    //solve()
    //return
	var t int
	fmt.Fscan(input, &t)
    for t > 0 {
        t--
        solve()
    }
	output.Flush()
}

func solve() {
    var n int
    fmt.Fscan(input, &n)
    a := make([]int, n)
    sum := 0
    for i := 0; i < n; i++ {
        fmt.Fscan(input, &a[i])
        sum += a[i]
    }
    if n % 2 == 0 || !isPrime(sum) {
        out(a)
        return
    }
    // find odd elem
    for i := 0; i < len(a); i++ {
        if a[i] % 2 == 1 {
            a[0], a[i] = a[i], a[0]
            out(a[1:])
        }
    }
}

func isPrime(x int) bool {
    for i := 2; i*i <= x; i++ {
        if x % i == 0 {
            return false
        }
    }
    return true
}
func out(a []int) {
    fmt.Fprintln(output, len(a))
    for i := 0; i < len(a); i++ {
        fmt.Fprint(output, a[i], " ")
    }
    fmt.Fprintln(output)
}

package main

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

func main() {

	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in, &t)
	for ; t > 0; t-- {
		var n int
		fmt.Fscan(in, &n)
		a := make([]int, n)
		b := make([]int, n)
		var sum int = 0
		for _, value := range a {
			fmt.Fscan(in, &value)
			sum += value
		}
		for i := 0; i < len(b); i++ {
			b[i] = i
		}
		sort.Slice(b, func(l, r int) bool {
			return a[l]%2 < a[r]%2
		})
		var flag int = 1
		for i := 2; i*i <= sum; i++ {
			if sum%i == 0 {
				flag -= 1
			}
		}
		var n_len int = n
		if flag == 1 {
			n_len--
		}
		fmt.Fprint(out, n_len, "\n")
		for i := 0; i < n_len; i++ {
			fmt.Fprint(out, b[i]+1, " ")
		}
		fmt.Fprintln(out)
	}
}

package main

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

func main() {

	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in, &t)
	for ; t > 0; t-- {
		var n int
		fmt.Fscan(in, &n)
		a := make([]int, n)
		b := make([]int, n)
		var sum int = 0
		for _, value := range a {
			fmt.Fscan(in, &value)
			sum += value
		}
		for i := 0; i < len(b); i++ {
			b[i] = i
		}
		sort.Slice(b, func(l, r int) bool {
			return a[l]%2 < a[r]%2
		})
		var flag int = 1
		for i := 2; i*i <= sum; i++ {
			if sum%i == 0 {
				flag = 0
			}
		}
		var n_len int = n - flag
		fmt.Fprint(out, n_len, "\n")
		for i := 0; i < n_len; i++ {
			fmt.Fprint(out, b[i]+1, " ")
		}
		fmt.Fprintln(out)
	}
}


package main

import (
	"fmt"
)

func main(){
	var n int
	fmt.Scan(&n)
	var s string
	fmt.Scan(&s)
	var a[10] int
	var i,x int
	for i = 1;i <= 9 ; i++{
		fmt.Scan(&x)
		a[i] = x
	}

	temp := []byte(s)
	var ok bool
	for index,chr := range temp{
		if(int(chr) - 48 < int(a[int(chr - 48)]) && !ok ){
			ok = true
			temp[index]  = byte(a[chr-48]) + 48
		}else if (ok && int(chr) - 48 < int(a[int(chr - 48)]) ){
			temp[index] = byte(a[chr - 48]) + 48
		} else if(ok && int(chr) - 48 > int(a[int(chr - 48)])){
			break;
		}
	}
	fmt.Print(string(temp))

}

package main

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

var reader = bufio.NewReader(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func print(a ...interface{})            { fmt.Fprint(writer, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }
func scan(a ...interface{})             { fmt.Fscan(reader, a...) }

func min(a ...int) int {
	min := -1
	for _, val := range a {
		if val < min {
			min = val
		}
	}
	return min
}

func max(a ...int) int {
	max := -1
	for _, val := range a {
		if val > max {
			max = val
		}
	}
	return max
}

func tr(n int) int {
	for n%10 == 0 {
		n = n / 10
	}
	return n
}

func main() {
	defer writer.Flush() // STDOUT MUST BE FLUSHED MANUALLY!!!
	var n int
	var s string
	m := [10]int{}
	scan(&n, &s)
	for i := 1; i < 10; i++ {
		scan(&m[i])
	}

	ns := ""
	con := false

	for idx := range s {
		dg, _ := strconv.Atoi(string(s[idx]))

		// start conv
		if m[dg] > dg {
			con = true
			ns += strconv.Itoa(m[dg])
			continue
		}

		// end conv
		if m[dg] < dg && con {
			con = false
			ns += s[idx:]
			break
		}

		ns += strconv.Itoa(dg)
	}
	print(ns)
}

package main

import (
	"fmt"
)

func main(){
	var n int
	fmt.Scan(&n)
	var s string
	fmt.Scan(&s)
	var a[10] int
	var i,x int
	for i = 1;i <= 9 ; i++{
		fmt.Scan(&x)
		a[i] = x
	}

	temp := []byte(s)
	var ok bool
	for index,chr := range temp{
		if(int(chr)  < int(a[int(chr - 48)] + 48) && !ok ){
			ok = true
			temp[index]  = byte(a[chr-48]) + 48
		}else if (ok && int(chr) < int(a[int(chr - 48)] + 48) ){
			temp[index] = byte(a[chr - 48]) + 48
		} else if(ok && int(chr) - 48 > int(a[int(chr - 48)])){
			break;
		}
	}
	fmt.Print(string(temp))

}

package main

import (
    "fmt"
    "strings"
    "strconv"
)

var f [10]int

func main() {
    var N int
    fmt.Scan(&N)
    var in string
    fmt.Scan(&in)
    a := make([]int, N)

    for i, c := range strings.Split(in, "") {
        a[i], _ = strconv.Atoi(c)
    }

    for i := 1; i <= 9; i++ {
        fmt.Scan(&f[i])
    }

    for i := 0; i < N; i++ {
        if f[a[i]] <= a[i] {
            continue
        }
        for i < N && f[a[i]] >= a[i] {
            a[i] = f[a[i]]
            i++
        }
        break
    }
    for _, x := range a{
        fmt.Print(x)
    }
    fmt.Println()
}

package main

import (
	"fmt"
	"strconv"
	"strings"
)

//noinspection GoUnhandledErrorResult
func main() {
	var n int
	fmt.Scan(&n)

	var in string
	fmt.Scan(&in)
	a := make([]int, n)
	for i, c := range strings.Split(in, "") {
		a[i], _ = strconv.Atoi(c)
	}

	var f [10]int
	for i := 1; i <= 9; i++ {
		fmt.Scan(&f[i])
	}

	for i := 0; i < n; i++ {
		if a[i] >= f[a[i]] {
			continue
		}

		for i < n && a[i] <= f[a[i]] {
			a[i] = f[a[i]]
			i++
		}

		break
	}

	for _, c := range a {
		fmt.Print(c)
	}
}

package main

import (
	"fmt"
	"strconv"
)

var n int
var tmp, num string
var f []int

func main() {
	f = make([]int, 10)

	fmt.Scanln(&tmp)
	n, _ = strconv.Atoi(tmp)

	fmt.Scanln(&num)

	for i := 1; i <= 9; i++ {
		fmt.Scanf("%d", &f[i])
	}

	num2 := []byte(num)

	flag := true

	for i := 0; i < n; i++ {
		old, _ := strconv.Atoi(string(num2[i]))
		new, _ := strconv.Atoi(string(num2[i]))

		new = f[old]

		if old > new {
			if flag == false {
				break
			}

			continue
		}

		if old < new {
			flag = false
		}

		b := []byte(strconv.Itoa(new))[0]
		num2[i] = b
	}

	fmt.Println(string(num2))
}

package main

import (
	"fmt"
)

func solve(a []uint8, f [10]uint8) []uint8 {
	started := false
	for i, cur := range a {
		if f[cur] < cur {
			if started {
				break
			}
			continue
		}

		if f[cur] > cur {
			a[i] = f[cur]
			started = true
		}
	}
	return a
}

func main() {
	var n int

	fmt.Scanln(&n)

	a := make([]uint8, n)
	s := ""
	fmt.Scanln(&s)
	for i := range a {
		a[i] = s[i] - '0'
	}

	f := [10]uint8{}
	for i := 1; i < 10; i++ {
		fmt.Scan(&f[i])
	}

	ans := solve(a, f)
	for _, cur := range ans {
		fmt.Print(cur)
	}
	fmt.Println()
}

package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanf("%d\n", &n)
	var s []byte
	fmt.Scanf("%s\n", &s)
	// fmt.Printf("%d\n%s\n", n, s)
	arr := make([]int, 9, 9)
	for i, _ := range arr {
		fmt.Scanf("%d", &arr[i])
	}
	str := []byte(s)
	// fmt.Println(arr)
	ind := int(-1)
	for i, _ := range s {
		// fmt.Printf("%q ", s[i])
		if int(s[i]-'0') < arr[int(s[i]-'1')] {
			ind = i
			break
		}
	}
	if ind != -1 {
		for ind < len(s) && (int(s[ind]-'0') <= arr[int(s[ind]-'1')]) {
			str[ind] = byte(arr[int(s[ind]-'1')] + '0')
			ind += 1
		}
	}
	for _, kek := range str {
		fmt.Printf("%d", int(kek-'0'))
	}
	fmt.Printf("\n")
}

package main

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

func readInt(reader *bufio.Scanner) int {
	var result int
	reader.Scan()
	result,_ = strconv.Atoi(reader.Text())
	return result
}
func main() {

	var n int
	var number string
	reader:=bufio.NewScanner(os.Stdin)
	buf := make([]byte, 2)
	reader.Buffer(buf, 200001)
	reader.Split(bufio.ScanWords)
	var f [9]int
	n = readInt(reader)
	reader.Scan()
	number = reader.Text()
	numChars := []rune(number)
	for i:=0;i<9;i++ {
		f[i] = readInt(reader)
	}
	progress:=0
	for i:=0;i<n;i++ {
		num := (int) (numChars[i]-'0')
		if progress==0 && num < f[num-1]{
			progress = 1
		}
		if progress == 1 && num > f[num-1]{
			break
		}
		if progress == 1 {
			numChars[i] = (rune)(f[num-1] +'0')
		}
	}
	fmt.Println(string(numChars))
}

package main

import (
    "fmt"
    "strings"
    "strconv"
)

var f [10]int

func main() {
    var N int
    fmt.Scan(&N)
    var in string
    fmt.Scan(&in)
    a := make([]int, N)

    for i, c := range strings.Split(in, "") {
        a[i], _ = strconv.Atoi(c)
    }

    for i := 1; i <= 9; i++ {
        fmt.Scan(&f[i])
    }

    for i := 0; i < N; i++ {
        if f[a[i]] <= a[i] {
            continue
        }
        for i < N && f[a[i]] > a[i] {
            a[i] = f[a[i]]
            i++
        }
        break
    }
    for _, x := range a{
        fmt.Print(x)
    }
    fmt.Println()
}

package main

import (
	"fmt"
	"strconv"
)

var n int
var tmp, num string
var f []int

func main() {
	f = make([]int, 10)

	fmt.Scanln(&tmp)
	n, _ = strconv.Atoi(tmp)

	fmt.Scanln(&num)

	for i := 1; i <= 9; i++ {
		fmt.Scanf("%d", &f[i])
	}

	num2 := []byte(num)

	for i := 0; i < n; i++ {
		old, _ := strconv.Atoi(string(num2[i]))
		new, _ := strconv.Atoi(string(num2[i]))

		new = f[old]

		if old > new {
			break
		}

		b := []byte(strconv.Itoa(new))[0]
		num2[i] = b
	}

	fmt.Println(string(num2))
}

package main

import (
	"fmt"
	"strconv"
)

var n int
var num, t string
var f []int

func main() {
	f = make([]int, 10)

	fmt.Scanf("%d", &n)
	fmt.Scanln(&t)
	fmt.Scanln(&num)

	for i := 1; i <= 9; i++ {
		fmt.Scanf("%d", &f[i])
	}

	num2 := []byte(num)

	for i := 0; i < n; i++ {
		old, _ := strconv.Atoi(string(num2[i]))
		new, _ := strconv.Atoi(string(num2[i]))

		new = f[old]

		if old > new {
			break
		}

		b := []byte(strconv.Itoa(new))[0]
		num2[i] = b
	}

	fmt.Println(string(num2))
}

package main

import (
	"fmt"
)

func solve(a []uint8, f [10]uint8) []uint8 {
	started := true
	for i, cur := range a {
		if f[cur] < cur {
			if started {
				break
			}
			continue
		}

		a[i] = f[cur]
		started = true
	}
	return a
}

func main() {
	var n int

	fmt.Scanln(&n)

	a := make([]uint8, n)
	s := ""
	fmt.Scanln(&s)
	for i := range a {
		a[i] = s[i] - '0'
	}

	f := [10]uint8{}
	for i := 1; i < 10; i++ {
		fmt.Scan(&f[i])
	}

	ans := solve(a, f)
	for _, cur := range ans {
		fmt.Print(cur)
	}
	fmt.Println()
}

package main

import (
	"fmt"
)

func solve(a []uint8, f [10]uint8) []uint8 {
	for i, cur := range a {
		if f[cur] > cur {
			a[i] = f[cur]
		}
	}
	return a
}

func main() {
	var n int

	fmt.Scanln(&n)

	a := make([]uint8, n)
	s := ""
	fmt.Scanln(&s)
	for i := range a {
		a[i] = s[i] - '0'
	}

	f := [10]uint8{}
	for i := 1; i < 10; i++ {
		fmt.Scan(&f[i])
	}

	ans := solve(a, f)
	for _, cur := range ans {
		fmt.Print(cur)
	}
	fmt.Println()
}

package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanf("%d\n", &n)
	var s []byte
	fmt.Scanf("%s\n", &s)
	// fmt.Printf("%d\n%s\n", n, s)
	arr := make([]int, 9, 9)
	for i, _ := range arr {
		fmt.Scanf("%d", &arr[i])
	}
	str := []byte(s)
	// fmt.Println(arr)
	ind := int(-1)
	for i, _ := range s {
		// fmt.Printf("%q ", s[i])
		if int(s[i]-'0') < arr[int(s[i]-'1')] {
			ind = i
			break
		}
	}
	if ind != -1 {
		for ind < len(s) && (int(s[ind]-'0') < arr[int(s[ind]-'1')]) {
			str[ind] = byte(arr[int(s[ind]-'1')] + '0')
			ind += 1
		}
	}
	for _, kek := range str {
		fmt.Printf("%d", int(kek-'0'))
	}
	fmt.Printf("\n")
}

package main

import (
	"fmt"
)

func main() {

	var n int
	var number string

	var f int
	fmt.Scanf("%d", &n)
	replaced := make([]bool,n)
	fmt.Scanf("%s", &number)
	numChars := []rune(number)
	for i:=0;i<9;i++{
		fmt.Scanf("%d", &f)
		if f > i+1{
			for index, c := range numChars {
				if (int)(c-'0') == i+1 && !replaced[index]{
					numChars[index] = (rune)('0'+f)
					replaced[index] = true
				}
			}
		}
	}
		fmt.Println(string(numChars))
}

package main

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

func readInt(reader *bufio.Scanner) int {
	var result int
	reader.Scan()
	result,_ = strconv.Atoi(reader.Text())
	return result
}
func main() {

	var n int
	var number string
	reader:=bufio.NewScanner(os.Stdin)
	buf := make([]byte, 2)
	reader.Buffer(buf, 200001)
	reader.Split(bufio.ScanWords)
	var f int
	n = readInt(reader)
	replaced := make([]bool,n)
	reader.Scan()
	number = reader.Text()
	numChars := []rune(number)
	for i:=0;i<9;i++{
		f = readInt(reader)
		if f > i+1{
			for index, c := range numChars {
				if (int)(c-'0') == i+1 && !replaced[index]{
					numChars[index] = (rune)('0'+f)
					replaced[index] = true
				}
			}
		}
	}
		fmt.Println(string(numChars))
}

package main

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

func readInt(reader *bufio.Scanner) int {
	var result int
	reader.Scan()
	result,_ = strconv.Atoi(reader.Text())
	return result
}
func main() {

	var n int
	var number string
	reader:=bufio.NewScanner(os.Stdin)
	reader.Split(bufio.ScanWords)
	var f int
	n = readInt(reader)
	replaced := make([]bool,n)
	reader.Scan()
	number = reader.Text()
	numChars := []rune(number)
	for i:=0;i<9;i++{
		f = readInt(reader)
		if f > i+1{
			for index, c := range numChars {
				if (int)(c-'0') == i+1 && !replaced[index]{
					numChars[index] = (rune)('0'+f)
					replaced[index] = true
				}
			}
		}
	}
		fmt.Println(string(numChars))
}

package main

import (
	"fmt"
)

func main() {

	var n int
	var number string

	var f int
	fmt.Scanf("%d", &n)
	replaced := make([]bool,n)
	fmt.Scanf("%s", &number)
	numChars := []rune(number)
	for i:=0;i<9;i++{
		fmt.Scanf("%d", &f)
		if f > i+1{
			for index, c := range numChars {
				if (int)(c-'0') == i+1 && !replaced[index]{
					numChars[index] = (rune)('0'+f)
					replaced[index] = true
				}
			}
		}
	}
		fmt.Print(string(numChars))
}

package main

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

var reader = bufio.NewReader(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func print(a ...interface{})            { fmt.Fprint(writer, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }
func scan(a ...interface{})             { fmt.Fscan(reader, a...) }

func min(a ...int) int {
	min := -1
	for _, val := range a {
		if val < min {
			min = val
		}
	}
	return min
}

func max(a ...int) int {
	max := -1
	for _, val := range a {
		if val > max {
			max = val
		}
	}
	return max
}

func tr(n int) int {
	for n%10 == 0 {
		n = n / 10
	}
	return n
}

func main() {
	defer writer.Flush() // STDOUT MUST BE FLUSHED MANUALLY!!!
	var n int
	var s string
	m := [10]int{}
	scan(&n, &s)
	for i := 1; i < 10; i++ {
		scan(&m[i])
	}

	ns := ""
	convd := -1

	for idx := range s {
		dg, _ := strconv.Atoi(string(s[idx]))

		if m[dg] > dg && convd == -1 {
			convd = dg
		}

		if convd == -1 {
			ns += strconv.Itoa(dg)
			continue
		}

		if dg == convd {
			ns += strconv.Itoa(m[dg])
		} else {
			ns += s[idx:]
			break
		}
	}
	print(ns)
}

package main

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

var input, inputerr = os.Open("./input")
var output, outputerr = os.Create("./output")
var reader = bufio.NewReader(input)
var writer = bufio.NewWriter(output)

// var reader = bufio.NewReader(os.Stdin)
// var writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func print(a ...interface{})            { fmt.Fprint(writer, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }
func scan(a ...interface{})             { fmt.Fscan(reader, a...) }

func min(a ...int) int {
	min := -1
	for _, val := range a {
		if val < min {
			min = val
		}
	}
	return min
}

func max(a ...int) int {
	max := -1
	for _, val := range a {
		if val > max {
			max = val
		}
	}
	return max
}

func tr(n int) int {
	for n%10 == 0 {
		n = n / 10
	}
	return n
}

func main() {
	defer writer.Flush() // STDOUT MUST BE FLUSHED MANUALLY!!!
	var n int
	var s string
	m := [10]int{}
	scan(&n, &s)
	for i := 1; i < 10; i++ {
		scan(&m[i])
	}

	ns := ""
	con := false

	for idx := range s {
		dg, _ := strconv.Atoi(string(s[idx]))

		// start conv
		if m[dg] > dg {
			con = true
			ns += strconv.Itoa(m[dg])
			continue
		}

		// end conv
		if m[dg] < dg && con {
			con = false
			ns += s[idx:]
			break
		}

		ns += strconv.Itoa(dg)
	}
	print(ns)
}

package main

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

var reader = bufio.NewReader(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func print(a ...interface{})            { fmt.Fprint(writer, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }
func scan(a ...interface{})             { fmt.Fscan(reader, a...) }

func min(a ...int) int {
	min := -1
	for _, val := range a {
		if val < min {
			min = val
		}
	}
	return min
}

func max(a ...int) int {
	max := -1
	for _, val := range a {
		if val > max {
			max = val
		}
	}
	return max
}

func tr(n int) int {
	for n%10 == 0 {
		n = n / 10
	}
	return n
}

func main() {
	defer writer.Flush() // STDOUT MUST BE FLUSHED MANUALLY!!!
	var n int
	var s string
	m := [10]int{}
	scan(&n, &s)
	for i := 1; i < 10; i++ {
		scan(&m[i])
	}

	ns := ""
	con := true

	for idx := range s {
		dg, _ := strconv.Atoi(string(s[idx]))

		// start conv
		if m[dg] > dg {
			con = true
			ns += strconv.Itoa(m[dg])
			continue
		}

		// end conv
		if m[dg] < dg && con {
			con = false
			ns += s[idx:]
			break
		}

		ns += strconv.Itoa(dg)
	}
	print(ns)
}


package main

import "bufio"
import "fmt"
import "os"
import "strconv"

type MyScanner struct {
	in *bufio.Scanner
}

var in = MyScanner{bufio.NewScanner(os.Stdin)}

func ScanInts(data []byte, atEOF bool) (advance int, token []byte, err error) {
	advance, token, err = bufio.ScanWords(data, atEOF)
	if err == nil && token != nil {
		_, err = strconv.Atoi(string(token))
	}
	return
}

func (m *MyScanner) innerNext(f bufio.SplitFunc) bool {
	m.in.Split(f)
	return m.in.Scan()
}

func (m *MyScanner) NextInt() (int, error) {
	if !m.innerNext(ScanInts) {
		return 0, m.in.Err()
	}
	return strconv.Atoi(m.in.Text())
}

func main() {
	n, _ := in.NextInt()
	a := make([]int, n)
	for i := range a {
		a[i], _ = in.NextInt()
	}
	r := 0
	for i := 1; i < n; i++ {
		if a[i-1] > a[i] {
			if r != 0 {
				fmt.Println("-1")
				return
			}
			r = i
		}
	}
	if r == 0 {
		fmt.Println("0")
	} else if a[0] < a[n-1] {
		fmt.Println("-1")
	} else {
		fmt.Println(n - r)
	}
}

package main

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

func main() {
	var n int
	if _, err := fmt.Scanf("%d\n", &n); err != nil {
		return
	}

	s1 := -1
	e1p := 0
	s2 := -1
	e2 := -1
	has_s3 := false

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	for i := 0; i < n && scanner.Scan(); i++ {
		a, err := strconv.Atoi(scanner.Text())
		if err != nil {
			return
		}

		if has_s3 {
			continue
		}

		if i == 0 {
			s1 = a
		} else {
			if e2 > a {
				if s2 < 0 {
					e1p = i
					s2 = a
				} else {
					has_s3 = true
				}
			}
		}
		e2 = a
	}

	if s2 < 0 {
		fmt.Println(0)
	} else if has_s3 || e2 > s1 {
		fmt.Println(-1)
	} else {
		fmt.Println(n - e1p)
	}
}