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, k int
		fmt.Fscan(r, &n, &k)

		s := make([]int, k)
		for i := range s { fmt.Fscan(r, &s[i]) }

		res := "YES"
		if k > 1 && (n-k+1)*s[1] < (n-k+2)*s[0] {
			res = "NO"
		} else if k > 2 {
			for j := 2; j < k; j++ {
				if s[j-2] + s[j] < 2*s[j-1] {
					res = "NO"
					break
				}
			}
		}

		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, k int
		fmt.Fscan(in, &n, &k)

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

		d := aa[0] / (n - k + 1)
		if aa[0] > 0 && d >= 0 && aa[0]%(n-k+1) != 0 {
			d++
		}

		// fmt.Println(d)
		f := true
		for i := 1; i < k; i++ {
			if aa[i]-aa[i-1] < d {
				f = false
				break
			}
			d = aa[i] - aa[i-1]
		}
		if !f {
			fmt.Fprintln(out, "No")
		} else {
			fmt.Fprintln(out, "Yes")
		}
	}
}

package main

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

var (
	in  = bufio.NewReader(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
)

func scan(a ...interface{}) {
	fmt.Fscan(in, a...)
}
func printf(f string, a ...interface{}) {
	fmt.Fprintf(out, f, a...)
}

func solve() {
	var n, k int
	scan(&n, &k)
	a := make([]int, k)
	for i := 0; i < k; i++ {
		scan(&a[i])
	}
	if k == 1 {
		printf("Yes\n")
		return
	}
	first := a[1] - a[0]
	last := first
	for i := 1; i < k; i++ {
		if a[i]-a[i-1] < last {
			printf("No\n")
			return
		} else {
			last = a[i] - a[i-1]
		}
	}
	s := a[0]
	m := n - k + 1
	var ave float64 = float64(s) / float64(m)
	var f float64 = float64(first)
	if ave <= f {
		printf("Yes\n")
	} else {
		printf("No\n")
		// printf("No2 %f %f\n", ave, f)
	}
	// printf("%d\n")
}
func main() {
	defer out.Flush()
	n := 0
	scan(&n)
	for i := 0; i < n; i++ {
		solve()
	}
}

package main

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

const cf = true

func solve() {
	var n, k int
	fmt.Fscan(in, &n, &k)
	arr := make([]int, k)
	for i := range arr {
		fmt.Fscan(in, &arr[i])
	}
	if n == 1 || k == 1 {
		fmt.Fprintln(out, "Yes")
		return
	}
	firstSum := arr[0]
	var cur int = arr[k-1] - arr[k-2]
	for i := k - 2; i >= 1; i-- {
		diff := arr[i] - arr[i-1]
		if diff > cur {
			fmt.Fprintln(out, "No")
			return
		}
		cur = diff
	}

	cnt := n - k + 1
	sum := firstSum / cnt
	if firstSum > 0 {
		sum += min(1, firstSum%cnt)
	}
	if sum > cur {
		fmt.Fprintln(out, "No")
		return
	}
	fmt.Fprintln(out, "Yes")
}

func main() {
	defer out.Flush()
	t := 1
	fmt.Fscan(in, &t)
	for ; t > 0; t-- {
		solve()
	}
}

func ConvertInt(val string, base, toBase int) (string, error) {
	i, err := strconv.ParseInt(val, base, 64)
	if err != nil {
		return "", err
	}
	return strconv.FormatInt(i, toBase), nil
}

type set[T Ordered] struct {
	itms map[T]struct{}
}

func (s *set[T]) init() {
	if s.itms == nil {
		s.itms = make(map[T]struct{})
	}
}

func (s *set[T]) add(item T) *set[T] {
	s.init()
	s.itms[item] = exists
	return s
}

func (s *set[T]) remove(item T) *set[T] {
	s.init()
	delete(s.itms, item)
	return s
}

func (s *set[T]) has(item T) bool {
	s.init()
	_, c := s.itms[item]
	return c
}

func (s *set[T]) sortedItems() []T {
	s.init()
	items := make([]T, 0, s.size())
	for item := range s.itms {
		items = append(items, item)
	}
	sort.Slice(items, func(i, j int) bool {
		return items[i] < items[j]
	})
	return items
}

func (s *set[T]) items() []T {
	s.init()
	items := make([]T, 0, s.size())
	for item := range s.itms {
		items = append(items, item)
	}
	return items
}

func (s *set[T]) size() int {
	s.init()
	return len(s.itms)
}

var exists = struct{}{}

const MaxUint = ^uint(0)
const MinUint = 0
const MaxInt = int(MaxUint >> 1)
const MinInt = -MaxInt - 1

func reverseStr(s string) string {
	r := []rune(s)
	for i, j := 0, len(r)-1; i < len(r)/2; i, j = i+1, j-1 {
		r[i], r[j] = r[j], r[i]
	}
	return string(r)
}

type Float interface {
	~float32 | ~float64
}

type Integer interface {
	Signed | Unsigned
}

type Signed interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64
}

type Unsigned interface {
	~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr
}

type Ordered interface {
	Integer | Float | ~string
}

func abs[T Signed](x T) T {
	if x < 0 {
		return -x
	}
	return x
}

func min[T Ordered](x, y T) T {
	if x < y {
		return x
	}
	return y
}

func max[T Ordered](x, y T) T {
	if x > y {
		return x
	}
	return y
}

var (
	in  = getReader()
	out = getWriter()
)

func getReader() *bufio.Reader {
	if cf {
		return bufio.NewReader(os.Stdin)
	} else {
		in, _ := os.Open("input.txt")
		return bufio.NewReader(in)
	}
}

func getWriter() *bufio.Writer {
	if cf {
		return bufio.NewWriter(os.Stdout)
	} else {
		out, _ := os.Create("output.txt")
		return bufio.NewWriter(out)
	}
}

package main

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

// https://codeforces.com/problemset/problem/1738/B
func P1738b(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var numCases int
	fmt.Fscan(in, &numCases)

	for iCase := 0; iCase < numCases; iCase++ {
		//fmt.Printf("### Test #%d\n", iCase)
		var n int
		fmt.Fscan(in, &n)
		var k int
		fmt.Fscan(in, &k)

		var e int
		fmt.Fscan(in, &e)
		var minNext int
		if k == n {
			minNext = e
		} else {
			var idx = n - k + 1
			//fmt.Printf("### e=%d, idx=%d\n", e, idx)
			if e%idx == 0 {
				minNext = e / idx
			} else {
				minNext = int(math.Ceil(float64(e) / float64(idx)))
			}
		}
		//fmt.Printf("### MinNext after 1: %d\n", minNext)
		var prevSum = e

		var iK int = 1
		var res = "Yes"
		for iK < k {
			iK++
			fmt.Fscan(in, &e)
			var elt = e - prevSum
			if elt < minNext {
				res = "No"
				break
			}
			minNext = elt
			prevSum = e
		}
		fmt.Fprintf(out, "%s\n", res)
		for iK < k {
			var _e int
			fmt.Fscan(in, &_e)
			iK++
		}
	}
}

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

package main

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

// https://codeforces.com/problemset/problem/1738/B
func P1738b(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var numCases int
	fmt.Fscan(in, &numCases)

	for iCase := 0; iCase < numCases; iCase++ {
		var n int
		fmt.Fscan(in, &n)
		var k int
		fmt.Fscan(in, &k)

		var e int
		fmt.Fscan(in, &e)
		var minNext int
		if k == n {
			minNext = e
		} else {
			var idx = n - k + 1
			if e%idx == 0 {
				minNext = e / idx
			} else {
				minNext = e/idx + 1
			}
		}
		var prevSum = e

		var iK int = 1
		var res = "Yes"
		for iK < k {
			iK++
			fmt.Fscan(in, &e)
			var elt = e - prevSum
			if elt < minNext {
				res = "No"
				break
			}
			minNext = elt
			prevSum = e
		}
		fmt.Fprintf(out, "%s\n", res)
		for iK < k {
			var _e int
			fmt.Fscan(in, &_e)
			iK++
		}
	}
}

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

package main

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

// https://codeforces.com/problemset/problem/1738/B
func P1738b(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var numCases int
	fmt.Fscan(in, &numCases)

	for iCase := 0; iCase < numCases; iCase++ {
		var n int
		fmt.Fscan(in, &n)
		var k int
		fmt.Fscan(in, &k)

		var e int
		fmt.Fscan(in, &e)
		var minNext int
		if k == n {
			minNext = e
		} else {
			var idx = n - k
			if e%idx == 0 {
				minNext = e / idx
			} else {
				minNext = e/idx + 1
			}
		}
		var prevSum = e

		var iK int = 1
		var res = "Yes"
		for iK < k {
			iK++
			fmt.Fscan(in, &e)
			var elt = e - prevSum
			if elt < minNext {
				res = "No"
				break
			}
			minNext = elt
			prevSum = e
		}
		fmt.Fprintf(out, "%s\n", res)
		for iK < k {
			var _e int
			fmt.Fscan(in, &_e)
			iK++
		}
	}
}

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

package main

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

// https://codeforces.com/problemset/problem/1738/B
func P1738b(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var numCases int
	fmt.Fscan(in, &numCases)

	for iCase := 0; iCase < numCases; iCase++ {
		var n int
		fmt.Fscan(in, &n)
		var k int
		fmt.Fscan(in, &k)

		var e int
		fmt.Fscan(in, &e)
		var minNext int
		if k == n {
			minNext = e
		} else {
			var idx = n - k
			if e%idx == 0 {
				minNext = e / idx
			} else {
				minNext = e/idx + 1
			}
		}
		var prevSum = e

		var iK int = 1
		var res = "Yes"
		for iK < k {
			iK++
			fmt.Fscan(in, &e)
			fmt.Printf("%d\n", e)
			var elt = e - prevSum
			if elt < minNext {
				res = "No"
				break
			}
			minNext = elt
			prevSum = e
		}
		fmt.Fprintf(out, "%s\n", res)
		for iK < k {
			var _e int
			fmt.Fscan(in, &_e)
			iK++
		}
	}
}

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

package main

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

// https://codeforces.com/problemset/problem/1738/B
func P1738b(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var numCases int
	fmt.Fscan(in, &numCases)

	for iCase := 0; iCase < numCases; iCase++ {
		var n int
		fmt.Fscan(in, &n)
		var k int
		fmt.Fscan(in, &k)

		var e int
		fmt.Fscan(in, &e)
		var minNext int
		if k == n {
			minNext = e
		} else {
			var idx = n - k
			if e%idx == 0 {
				minNext = e / idx
			} else {
				minNext = e/idx + 1
			}
		}
		var prevSum = e

		var iK int = 1
		var res = "Yes"
		for iK < k {
			iK++
			fmt.Fscan(in, &e)
			fmt.Printf("%d\n", e)
			var elt = e - prevSum
			if elt < minNext {
				res = "No"
				break
			}
			minNext = elt
			prevSum = e
		}
		fmt.Fprintf(out, "%s\n", res)
		for iK < k {
			var _e int
			fmt.Fscan(in, &_e)
			fmt.Printf("%d\n", _e)
			iK++
		}
	}
}

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

package main

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

// https://codeforces.com/problemset/problem/1738/B
func P1738b(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var numCases int
	fmt.Fscan(in, &numCases)

	for iCase := 0; iCase < numCases; iCase++ {
		var n int
		fmt.Fscan(in, &n)
		var k int
		fmt.Fscan(in, &k)

		var e int
		fmt.Fscan(in, &e)
		var minNext int
		if k == n {
			minNext = e
		} else {
			var idx = n - k
			if e%idx == 0 {
				minNext = e / idx
			} else {
				minNext = e/idx + 1
			}
		}
		var prevSum = e

		var iK int = 1
		var res = "Yes"
		for iK < k {
			iK++
			fmt.Fscan(in, &e)
			var elt = e - prevSum
			if elt < minNext {
				res = "No"
				break
			}
			minNext = elt
			prevSum = e
		}
		fmt.Fprintf(out, "%s\n", res)
		for ; iK < k; iK++ {
			var _e int
			fmt.Fscan(in, &_e)
			iK++
		}
	}
}

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

package main

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

// https://codeforces.com/problemset/problem/1738/B
func P1738b(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var numCases int
	fmt.Fscan(in, &numCases)

	for iCase := 0; iCase < numCases; iCase++ {
		var n int
		fmt.Fscan(in, &n)
		var k int
		fmt.Fscan(in, &k)

		var e int
		fmt.Fscan(in, &e)
		var minNext int
		if k == n {
			minNext = e
		} else {
			var idx = n - k
			if e%idx == 0 {
				minNext = e / idx
			} else {
				minNext = e/idx + 1
			}
		}
		var prevSum = e

		var iK int
		var res = "Yes"
		for iK = 1; iK < k; iK++ {
			fmt.Fscan(in, &e)
			var elt = e - prevSum
			if elt < minNext {
				res = "No"
				iK++
				break
			}
			minNext = elt
			prevSum = e
		}
		fmt.Fprintf(out, "%s\n", res)
		for ; iK < k; iK++ {
			var _e int
			fmt.Fscan(in, &_e)
			iK++
		}
	}
}

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

package main

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

const cf = true

func solve() {
	var n, k int
	fmt.Fscan(in, &n, &k)
	arr := make([]int, k)
	for i := range arr {
		fmt.Fscan(in, &arr[i])
	}
	if n == 1 || k == 1 {
		fmt.Fprintln(out, "Yes")
		return
	}
	firstSum := arr[0]
	var cur int = arr[k-1] - arr[k-2]
	for i := k - 2; i >= 1; i-- {
		diff := arr[i] - arr[i-1]
		if diff > cur {
			fmt.Fprintln(out, "No")
			return
		}
		cur = diff
	}

	cnt := n - k + 1
	if firstSum < 0 && -firstSum < cnt {
		fmt.Fprintln(out, "No")
		return
	}
	fmt.Fprintln(out, "Yes")
}

func main() {
	defer out.Flush()
	t := 1
	fmt.Fscan(in, &t)
	for ; t > 0; t-- {
		solve()
	}
}

func ConvertInt(val string, base, toBase int) (string, error) {
	i, err := strconv.ParseInt(val, base, 64)
	if err != nil {
		return "", err
	}
	return strconv.FormatInt(i, toBase), nil
}

type set[T Ordered] struct {
	itms map[T]struct{}
}

func (s *set[T]) init() {
	if s.itms == nil {
		s.itms = make(map[T]struct{})
	}
}

func (s *set[T]) add(item T) *set[T] {
	s.init()
	s.itms[item] = exists
	return s
}

func (s *set[T]) remove(item T) *set[T] {
	s.init()
	delete(s.itms, item)
	return s
}

func (s *set[T]) has(item T) bool {
	s.init()
	_, c := s.itms[item]
	return c
}

func (s *set[T]) sortedItems() []T {
	s.init()
	items := make([]T, 0, s.size())
	for item := range s.itms {
		items = append(items, item)
	}
	sort.Slice(items, func(i, j int) bool {
		return items[i] < items[j]
	})
	return items
}

func (s *set[T]) items() []T {
	s.init()
	items := make([]T, 0, s.size())
	for item := range s.itms {
		items = append(items, item)
	}
	return items
}

func (s *set[T]) size() int {
	s.init()
	return len(s.itms)
}

var exists = struct{}{}

const MaxUint = ^uint(0)
const MinUint = 0
const MaxInt = int(MaxUint >> 1)
const MinInt = -MaxInt - 1

func reverseStr(s string) string {
	r := []rune(s)
	for i, j := 0, len(r)-1; i < len(r)/2; i, j = i+1, j-1 {
		r[i], r[j] = r[j], r[i]
	}
	return string(r)
}

type Float interface {
	~float32 | ~float64
}

type Integer interface {
	Signed | Unsigned
}

type Signed interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64
}

type Unsigned interface {
	~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr
}

type Ordered interface {
	Integer | Float | ~string
}

func abs[T Signed](x T) T {
	if x < 0 {
		return -x
	}
	return x
}

func min[T Ordered](x, y T) T {
	if x < y {
		return x
	}
	return y
}

func max[T Ordered](x, y T) T {
	if x > y {
		return x
	}
	return y
}

var (
	in  = getReader()
	out = getWriter()
)

func getReader() *bufio.Reader {
	if cf {
		return bufio.NewReader(os.Stdin)
	} else {
		in, _ := os.Open("input.txt")
		return bufio.NewReader(in)
	}
}

func getWriter() *bufio.Writer {
	if cf {
		return bufio.NewWriter(os.Stdout)
	} else {
		out, _ := os.Create("output.txt")
		return bufio.NewWriter(out)
	}
}

package main

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

const cf = true

func solve() {
	var n, k int
	fmt.Fscan(in, &n, &k)
	arr := make([]int, k)
	for i := range arr {
		fmt.Fscan(in, &arr[i])
	}
	if n == 1 || k == 1 {
		fmt.Fprintln(out, "Yes")
		return
	}
	firstSum := arr[0]
	var cur int = arr[k-1] - arr[k-2]
	for i := k - 2; i >= 1; i-- {
		diff := arr[i] - arr[i-1]
		if diff > cur {
			fmt.Fprintln(out, "No")
			return
		}
		cur = diff
	}

	cnt := n - k + 1
	firstSum = firstSum / cnt
	if firstSum < 0 {
		firstSum += max(-1, firstSum%cnt)
	}
	if firstSum > 0 {
		firstSum += min(1, firstSum%cnt)
	}
	if firstSum > cur {
		fmt.Fprintln(out, "No")
		return
	}
	fmt.Fprintln(out, "Yes")
}

func main() {
	defer out.Flush()
	t := 1
	fmt.Fscan(in, &t)
	for ; t > 0; t-- {
		solve()
	}
}

func ConvertInt(val string, base, toBase int) (string, error) {
	i, err := strconv.ParseInt(val, base, 64)
	if err != nil {
		return "", err
	}
	return strconv.FormatInt(i, toBase), nil
}

type set[T Ordered] struct {
	itms map[T]struct{}
}

func (s *set[T]) init() {
	if s.itms == nil {
		s.itms = make(map[T]struct{})
	}
}

func (s *set[T]) add(item T) *set[T] {
	s.init()
	s.itms[item] = exists
	return s
}

func (s *set[T]) remove(item T) *set[T] {
	s.init()
	delete(s.itms, item)
	return s
}

func (s *set[T]) has(item T) bool {
	s.init()
	_, c := s.itms[item]
	return c
}

func (s *set[T]) sortedItems() []T {
	s.init()
	items := make([]T, 0, s.size())
	for item := range s.itms {
		items = append(items, item)
	}
	sort.Slice(items, func(i, j int) bool {
		return items[i] < items[j]
	})
	return items
}

func (s *set[T]) items() []T {
	s.init()
	items := make([]T, 0, s.size())
	for item := range s.itms {
		items = append(items, item)
	}
	return items
}

func (s *set[T]) size() int {
	s.init()
	return len(s.itms)
}

var exists = struct{}{}

const MaxUint = ^uint(0)
const MinUint = 0
const MaxInt = int(MaxUint >> 1)
const MinInt = -MaxInt - 1

func reverseStr(s string) string {
	r := []rune(s)
	for i, j := 0, len(r)-1; i < len(r)/2; i, j = i+1, j-1 {
		r[i], r[j] = r[j], r[i]
	}
	return string(r)
}

type Float interface {
	~float32 | ~float64
}

type Integer interface {
	Signed | Unsigned
}

type Signed interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64
}

type Unsigned interface {
	~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr
}

type Ordered interface {
	Integer | Float | ~string
}

func abs[T Signed](x T) T {
	if x < 0 {
		return -x
	}
	return x
}

func min[T Ordered](x, y T) T {
	if x < y {
		return x
	}
	return y
}

func max[T Ordered](x, y T) T {
	if x > y {
		return x
	}
	return y
}

var (
	in  = getReader()
	out = getWriter()
)

func getReader() *bufio.Reader {
	if cf {
		return bufio.NewReader(os.Stdin)
	} else {
		in, _ := os.Open("input.txt")
		return bufio.NewReader(in)
	}
}

func getWriter() *bufio.Writer {
	if cf {
		return bufio.NewWriter(os.Stdout)
	} else {
		out, _ := os.Create("output.txt")
		return bufio.NewWriter(out)
	}
}

package main

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

const cf = true

func solve() {
	var n, k int
	fmt.Fscan(in, &n, &k)
	arr := make([]int, k)
	for i := range arr {
		fmt.Fscan(in, &arr[i])
	}
	if n == 1 {
		fmt.Fprintln(out, "Yes")
		return
	}
	firstSum := arr[0]
	var cur int = 1e12
	if k > 1 {
		cur = arr[k-1] - arr[k-2]
		for i := k - 2; i >= 1; i-- {
			diff := arr[i] - arr[i-1]
			if diff > cur {
				fmt.Fprintln(out, "No")
				return
			}
			cur = diff
		}
	}
	cnt := n - k
	if cnt != 0 {
		firstSum = firstSum / cnt
		if firstSum < 0 {
			firstSum += max(-1, firstSum%cnt)
		}
		if firstSum > 0 {
			firstSum += min(1, firstSum%cnt)
		}
	}
	if k > 1 {
		if firstSum > cur {
			fmt.Fprintln(out, "No")
			return
		}
	}
	fmt.Fprintln(out, "Yes")
}

func main() {
	defer out.Flush()
	t := 1
	fmt.Fscan(in, &t)
	for ; t > 0; t-- {
		solve()
	}
}

func ConvertInt(val string, base, toBase int) (string, error) {
	i, err := strconv.ParseInt(val, base, 64)
	if err != nil {
		return "", err
	}
	return strconv.FormatInt(i, toBase), nil
}

type set[T Ordered] struct {
	itms map[T]struct{}
}

func (s *set[T]) init() {
	if s.itms == nil {
		s.itms = make(map[T]struct{})
	}
}

func (s *set[T]) add(item T) *set[T] {
	s.init()
	s.itms[item] = exists
	return s
}

func (s *set[T]) remove(item T) *set[T] {
	s.init()
	delete(s.itms, item)
	return s
}

func (s *set[T]) has(item T) bool {
	s.init()
	_, c := s.itms[item]
	return c
}

func (s *set[T]) sortedItems() []T {
	s.init()
	items := make([]T, 0, s.size())
	for item := range s.itms {
		items = append(items, item)
	}
	sort.Slice(items, func(i, j int) bool {
		return items[i] < items[j]
	})
	return items
}

func (s *set[T]) items() []T {
	s.init()
	items := make([]T, 0, s.size())
	for item := range s.itms {
		items = append(items, item)
	}
	return items
}

func (s *set[T]) size() int {
	s.init()
	return len(s.itms)
}

var exists = struct{}{}

const MaxUint = ^uint(0)
const MinUint = 0
const MaxInt = int(MaxUint >> 1)
const MinInt = -MaxInt - 1

func reverseStr(s string) string {
	r := []rune(s)
	for i, j := 0, len(r)-1; i < len(r)/2; i, j = i+1, j-1 {
		r[i], r[j] = r[j], r[i]
	}
	return string(r)
}

type Float interface {
	~float32 | ~float64
}

type Integer interface {
	Signed | Unsigned
}

type Signed interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64
}

type Unsigned interface {
	~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr
}

type Ordered interface {
	Integer | Float | ~string
}

func abs[T Signed](x T) T {
	if x < 0 {
		return -x
	}
	return x
}

func min[T Ordered](x, y T) T {
	if x < y {
		return x
	}
	return y
}

func max[T Ordered](x, y T) T {
	if x > y {
		return x
	}
	return y
}

var (
	in  = getReader()
	out = getWriter()
)

func getReader() *bufio.Reader {
	if cf {
		return bufio.NewReader(os.Stdin)
	} else {
		in, _ := os.Open("input.txt")
		return bufio.NewReader(in)
	}
}

func getWriter() *bufio.Writer {
	if cf {
		return bufio.NewWriter(os.Stdout)
	} else {
		out, _ := os.Create("output.txt")
		return bufio.NewWriter(out)
	}
}

package main

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

const cf = true

func solve() {
	var n, k int
	fmt.Fscan(in, &n, &k)
	arr := make([]int, k)
	for i := range arr {
		fmt.Fscan(in, &arr[i])
	}
	firstSum := arr[0]
	var cur int = 1e12
	if k > 1 {
		cur = arr[k-1] - arr[k-2]
		for i := k - 2; i >= 1; i-- {
			diff := arr[i] - arr[i-1]
			if diff > cur {
				fmt.Fprintln(out, "No")
				return
			}
			cur = diff
		}
	}
	cnt := n - k
	if cnt != 0 {
		firstSum = firstSum/cnt + min(1, firstSum%cnt)
	}
	if k > 1 {
		if firstSum > cur {
			fmt.Fprintln(out, "No")
			return
		}
	}
	fmt.Fprintln(out, "Yes")
}

func main() {
	defer out.Flush()
	t := 1
	fmt.Fscan(in, &t)
	for ; t > 0; t-- {
		solve()
	}
}

func ConvertInt(val string, base, toBase int) (string, error) {
	i, err := strconv.ParseInt(val, base, 64)
	if err != nil {
		return "", err
	}
	return strconv.FormatInt(i, toBase), nil
}

type set[T Ordered] struct {
	itms map[T]struct{}
}

func (s *set[T]) init() {
	if s.itms == nil {
		s.itms = make(map[T]struct{})
	}
}

func (s *set[T]) add(item T) *set[T] {
	s.init()
	s.itms[item] = exists
	return s
}

func (s *set[T]) remove(item T) *set[T] {
	s.init()
	delete(s.itms, item)
	return s
}

func (s *set[T]) has(item T) bool {
	s.init()
	_, c := s.itms[item]
	return c
}

func (s *set[T]) sortedItems() []T {
	s.init()
	items := make([]T, 0, s.size())
	for item := range s.itms {
		items = append(items, item)
	}
	sort.Slice(items, func(i, j int) bool {
		return items[i] < items[j]
	})
	return items
}

func (s *set[T]) items() []T {
	s.init()
	items := make([]T, 0, s.size())
	for item := range s.itms {
		items = append(items, item)
	}
	return items
}

func (s *set[T]) size() int {
	s.init()
	return len(s.itms)
}

var exists = struct{}{}

const MaxUint = ^uint(0)
const MinUint = 0
const MaxInt = int(MaxUint >> 1)
const MinInt = -MaxInt - 1

func reverseStr(s string) string {
	r := []rune(s)
	for i, j := 0, len(r)-1; i < len(r)/2; i, j = i+1, j-1 {
		r[i], r[j] = r[j], r[i]
	}
	return string(r)
}

type Float interface {
	~float32 | ~float64
}

type Integer interface {
	Signed | Unsigned
}

type Signed interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64
}

type Unsigned interface {
	~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr
}

type Ordered interface {
	Integer | Float | ~string
}

func abs[T Signed](x T) T {
	if x < 0 {
		return -x
	}
	return x
}

func min[T Ordered](x, y T) T {
	if x < y {
		return x
	}
	return y
}

func max[T Ordered](x, y T) T {
	if x > y {
		return x
	}
	return y
}

var (
	in  = getReader()
	out = getWriter()
)

func getReader() *bufio.Reader {
	if cf {
		return bufio.NewReader(os.Stdin)
	} else {
		in, _ := os.Open("input.txt")
		return bufio.NewReader(in)
	}
}

func getWriter() *bufio.Writer {
	if cf {
		return bufio.NewWriter(os.Stdout)
	} else {
		out, _ := os.Create("output.txt")
		return bufio.NewWriter(out)
	}
}


package main

import "fmt"

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

func count(query *string, low, high int, char byte) int {
	var counter int
	for i := low; i <= high; i++ {
		if (*query)[i] != char {
			counter++
		}
	}
	return counter
}

func solve(query *string, low, high int, char byte) int {
	if low == high {
		if (*query)[low] == char {
			return 0
		} else {
			return 1
		}
	}
	mid := (low + high) / 2
	leftRec := solve(query, low, mid, char+1) + count(query, mid+1, high, char)
	rightRec := solve(query, mid+1, high, char+1) + count(query, low, mid, char)
	return min(leftRec, rightRec)
}

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

	for TC != 0 {
		var query string
		var n int
		fmt.Scanf("%d\n", &n)
		fmt.Scanf("%s\n", &query)
		fmt.Println(solve(&query, 0, len(query)-1, 'a'))
		TC--
	}
}

package main

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

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

var s string

func calc(L, R int, c byte) int {
	if L == R {
		if s[L] == c {
			return 0
		}
		return 1
	}

	m := (L+R) >> 1
	cntL, cntR := 0, 0
	for i := L; i <= R; i++ {
		if s[i] != c {
			if i <= m {
				cntL++
			} else {
				cntR++
			}
		}
	}
	return min(calc(L, m, c+1) + cntR, calc(m+1, R, c+1) + cntL)
}

func main() {
	defer writer.Flush()
	t := NextInt()
	for t > 0 {
		t--
		n := NextInt()
		s = Next()
		Println(calc(0, n-1, 'a'))
	}
}

var writer = bufio.NewWriter(os.Stdout)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer(make([]byte, 256), 1e9)
	sc.Split(bufio.ScanWords)
}

func Println(data interface{}) {
	writer.WriteString(fmt.Sprintf("%v\n", data))
}

func Print(data interface{}) {
	writer.WriteString(fmt.Sprintf("%v", data))
}

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

func NextInt() int {
	i, err := strconv.Atoi(Next())
	if err != nil {
		panic(err)
	}
	return i
}

func NextInt64() int64 {
	i64, err := strconv.ParseInt(Next(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i64
}

func NextFloat64() float64 {
	f, err := strconv.ParseFloat(Next(), 64)
	if err != nil {
		panic(err)
	}
	return f
}

package main

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

var in = bufio.NewReader(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	defer out.Flush()
	var nTest int
	fmt.Fscanf(in, "%d\n", &nTest)
	for i := 0; i < nTest; i++ {
		solveCase()
	}
}

var a [26][140000]int

func calc(c, l, r int) int {
	if r-l == 1 {
		return 1 - a[c][r] + a[c][l]
	}
	m := l + ((r - l) >> 1)
	one := calc(c+1, l, m) + r - m - (a[c][r] - a[c][m])
	two := calc(c+1, m, r) + m - l - (a[c][m] - a[c][l])
	if one < two {
		return one
	}
	return two
}
func solveCase() {
	var n int
	var s string
	fmt.Fscanf(in, "%d\n%s\n", &n, &s)
	for i := 1; i <= n; i++ {
		for j := 0; j < 26; j++ {
			a[j][i] = a[j][i-1]
		}
		a[s[i-1]-'a'][i]++
	}
	fmt.Fprintf(out, "%d\n", calc(0, 0, n))
}

package main

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

var reader *bufio.Reader
var writer *bufio.Writer

func main() {
	//ioutil.WriteFile("input.txt", []byte(generateInput()), os.ModeExclusive)

	debug := 1
	filename := "input.txt"
	if  debug != 0 && len(os.Args)>1 && os.Args[1] == "debug" {
		file, _ := os.Open(filename)
		reader = bufio.NewReaderSize(file, 1024*1024)
	} else {
		reader = bufio.NewReaderSize(os.Stdin, 1024*1024)
	}
	writer = bufio.NewWriterSize(os.Stdout, 1024 * 1024)

	var T int
	fmt.Fscanf(reader, "%d\n", &T)

	for _case := 1; _case <= T; _case++ {
		n := readInt()
		s := readLine()
		ans := makeGood(s, 0, n, 'a')
		fmt.Println(ans)
	}

	writer.Flush()
}

func makeGood(s string, l, r int, target byte) int {
	if r-1 == l {
		if s[l] == target {
			return 0
		}
		return 1
	}

	ans1 := 0
	mid := (l+r+1)>>1
	for i:=l; i<mid; i++ {
		if s[i]!=target{
			ans1++
		}
	}
	ans1 += makeGood(s,mid,r,target+1)

	ans2 := 0
	for i:=mid; i<r; i++ {
		if s[i]!=target{
			ans2++
		}
	}
	ans2 += makeGood(s,l,mid,target+1)

	return getMin(ans1, ans2)
}

func readInts() []int {
	line := readLine()
	fields := strings.Fields(line)
	res := make([]int, len(fields))
	for i := range fields {
		v, _ := strconv.ParseInt(fields[i], 10, 64)
		res[i] = int(v)
	}
	return res
}

func readInt() int {
	line := readLine()
	n, _ := strconv.ParseInt(line, 10, 64)
	return int(n)
}

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

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

func printInts(arr []int, sep string) {
	n := len(arr)
	if n == 0 { panic("printInts empty") }
	fmt.Printf("%d", arr[0])
	for i := 1; i < n; i++ {
		fmt.Printf("%s%d", sep, arr[i])
	}
}

func getMin(arr ...int) int {
	if len(arr) == 0 { panic("length arr == 0") }

	var ans = arr[0]
	for _, v := range arr {
		if v < ans { ans = v }
	}
	return ans
}

package main

import (
	"fmt"
)
// https://codeforces.com/contest/1367/submission/84588408

const abc = "abcdefghijklmnopqrstuvwxyz"

func toCharStrConst(i int) string {
    return abc[i : i+1]
}

func rp(s string, c int) (int){
	n:=len(s)
	var ans int
	d:=toCharStrConst(c)
	for i:=0;i<n;i++ {
		if s[i:i+1]!=d {
			ans++
		}
	}
	// fmt.Println(s,d,ans)
	return ans
}

func solve(s string , c int) (int){
	n:=len(s)
	if n==1 {
		return rp(s,c)
	}
	a,b:= rp(s[:n/2],c) + solve(s[n/2:],c+1) , rp(s[n/2:],c) + solve(s[:n/2],c+1)
	if a>b {
		return b
	} else {
		return a
	}
}

func main(){
	//r := bufio.NewReader(os.Stdin)
	//w := bufio.NewWriter(os.Stdout)
	var t int
	fmt.Scan(&t)
	for ; t > 0 ; t--{
		var s string
		var n int
		fmt.Scan(&n)
		fmt.Scan(&s)
		fmt.Println(solve(s,0))
	}
}

package main

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

const lg = 17

func main() {
	io := newFastIO(os.Stdin, os.Stdout)
	defer io.Flush()

	for t := io.nextInt(); t > 0; t-- {
		n := io.nextInt()
		s := io.next()
		a := make([]int, n+1)
		for i, c := range s {
			a[i+1] = int(c) - 'a'
		}
		cnts := make([][]int, lg)
		for c := 0; c < lg; c++ {
			cnts[c] = make([]int, n+1)
			for i := 1; i <= n; i++ {
				cnts[c][i] = cnts[c][i-1]
				if a[i] == c {
					cnts[c][i]++
				}
			}
		}

		cost := func(l, r, c int) int {
			return r - l + 1 - (cnts[c][r] - cnts[c][l-1])
		}

		var rec func(l, r, c int) int
		rec = func(l, r, c int) int {
			if l == r {
				if a[l] == c {
					return 0
				}
				return 1
			}
			m := (l + r) / 2
			ans1 := cost(l, m, c) + rec(m+1, r, c+1)
			ans2 := rec(l, m, c+1) + cost(m+1, r, c)
			if ans1 < ans2 {
				return ans1
			}
			return ans2
		}

		ans := rec(1, n, 0)
		io.println(ans)
	}
}

type fastIO struct {
	*bufio.Reader
	*bufio.Writer
	p []byte
}

func newFastIO(r io.Reader, w io.Writer) fastIO {
	return fastIO{bufio.NewReader(r), bufio.NewWriter(w), make([]byte, 1)}
}

func (f *fastIO) nextInt() int {
	f.Read(f.p)
	for !('0' <= f.p[0] && f.p[0] <= '9') {
		f.Read(f.p)
	}
	n := 0
	for '0' <= f.p[0] && f.p[0] <= '9' {
		n = n*10 + int(f.p[0]) - '0'
		f.Read(f.p)
	}
	return n
}

func (f *fastIO) next() string {
	f.Read(f.p)
	for f.p[0] <= ' ' {
		f.Read(f.p)
	}
	var s []byte
	for f.p[0] > ' ' {
		s = append(s, f.p[0])
		f.Read(f.p)
	}
	return string(s)
}

func (f *fastIO) println(a ...interface{}) {
	fmt.Fprintln(f.Writer, a...)
}

func (f *fastIO) print(a ...interface{}) {
	fmt.Fprint(f.Writer, a...)
}

// https://codeforces.com/contest/x/problem/A
package main

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

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)
var input *bufio.Reader

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

func main() {
	var T int

	//f, _ := os.Open("input.txt")
	//input := bufio.NewReader(f)
	input = bufio.NewReader(os.Stdin)
	fmt.Fscanln(input, &T)
	for i := 0; i < T; i++ {
		solver()
	}
}

func solver() {
	var (
		n int
		s string
	)
	fmt.Fscanln(input, &n)
	fmt.Fscanln(input, &s)
	if n == 1 {
		if s == "a" {
			fmt.Println(0)
		} else {
			fmt.Println(1)
		}
		return
	}
	fmt.Println(calc(s, 'a'))
}

func calc(s string, c byte) int {
	n := len(s) / 2
	p1, p2 := s[:n], s[n:]
	return min(rec(p1, p2, c), rec(p2, p1, c))
}

func rec(a, b string, c byte) int {
	changes := 0
	if len(a) == 1 {
		if a[0] != c {
			changes++
		}
		if b[0] != c+1 {
			changes++
		}
		return changes
	}

	for i := 0; i < len(a); i++ {
		if a[i] != c {
			changes++
		}
	}
	return changes + calc(b, c+1)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

package main

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

func checkIfGood(s string, c byte) int {
	n := len(s)
	if n == 1 {
		if s[0] == c {
			return 0
		}

		return 1
	}

	changes1 := 0
	changes2 := 0

	for i := n / 2; i < n; i++ {
		if s[i] != c {
			changes1++
		}
	}

	for i := 0; i < n/2; i++ {
		if s[i] != c {
			changes2++
		}
	}

	val1 := changes1 + checkIfGood(s[0:n/2], c+1)
	val2 := changes2 + checkIfGood(s[n/2:n], c+1)

	if val1 < val2 {
		return val1
	}

	return val2
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	buffer := make([]byte, 1024*1024*10)
	scanner.Buffer(buffer, 50*1024*1024)
	scanner.Split(bufio.ScanWords)

	inputInt := func() int {
		scanner.Scan()
		i, _ := strconv.Atoi(scanner.Text())
		return i
	}

	inputStr := func() string {
		scanner.Scan()
		return scanner.Text()
	}

	for t := inputInt(); t > 0; t-- {
		n := inputInt()

		str := inputStr()

		fmt.Println(checkIfGood(str[0:n], 'a'))
	}
}

package main

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

func goodCorrect(str string, c byte, l, r int) int {
	if r-l == 1 {
		if str[l] == c {
			return 0
		} else {
			return 1
		}
	}

	diff1 := 0
	diff2 := 0
	for i := l; i < (l+r)/2; i++ {
		if str[i] != c {
			diff1++
		}
	}

	for i := (l + r) / 2; i < r; i++ {
		if str[i] != c {
			diff2++
		}
	}
	diff := 0
	diff1 += goodCorrect(str, c+1, (l+r)/2, r)
	diff2 += goodCorrect(str, c+1, l, (l+r)/2)

	if diff1 <= diff2 {
		diff = diff1
	} else {
		diff = diff2
	}
	return diff
}

func main() {
	in := bufio.NewReader(os.Stdin)
	var t int
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		var n int
		fmt.Fscan(in, &n)
		var str string
		fmt.Fscan(in, &str)
		fmt.Println(goodCorrect(str, 'a', 0, n))
	}
}

package main

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

func main() {
	var cases int
	fmt.Scanf("%d\n", &cases)
	reader := bufio.NewReader(os.Stdin)
	for i := 0; i < cases; i++ {
		readLine(reader)
		line := readLine(reader)
		fmt.Println(findMin(string(line), 'a'))
	}
}

func findMin(str string, target byte) int {
	if len(str) == 0 {
		return 0
	}
	if len(str) == 1 && str[0] == target {
		return 0
	} else if len(str) == 1 {
		return 1
	}
	l := len(str)
	left := minMatch(str[0:l/2], target) + findMin(str[l/2:], target+1)
	right := minMatch(str[l/2:], target) + findMin(str[:l/2], target+1)
	if left < right {
		return left
	}
	return right
}

func minMatch(str string, target byte) int {
	count := 0
	for i := 0; i < len(str); i++ {
		if str[i] != target {
			count++
		}
	}
	return count
}

func readLine(reader *bufio.Reader) []byte {
	result := make([]byte, 0)
	for {
		s, isPrefix, err := reader.ReadLine()
		if err != nil {
			fmt.Printf("error=%+v\n", err)
			break
		}
		result = append(result, s...)
		if !isPrefix {
			break
		}
	}
	return result
}

package main

import "fmt"

const MaxInt = int(^uint(0) >> 1)

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

func count(low, high int, query *string, char byte) int {
	var counter int
	for i := low; i <= high; i++ {
		if (*query)[i] != char {
			counter++
		}
	}
	return counter
}

// high = n-1
// low = 0
func solve(low, high int, query *string, char byte) int {
	if low == high {
		if (*query)[low] == char {
			return 0
		} else {
			return 1
		}
	} else {
		var minCount = MaxInt
		mid := (low + high) / 2
		leftCount := solve(low, mid, query, char+1) + count(mid+1, high, query, char)
		minCount = min(leftCount, minCount)
		rightCount := solve(mid+1, high, query, char+1) + count(low, mid, query, char)
		minCount = min(rightCount, minCount)
		return minCount
	}
}

func main() {
	var TC, N int
	var query string
	fmt.Scan(&TC)

	for TC != 0 {
		fmt.Scan(&N)
		fmt.Scan(&query)

		fmt.Println(solve(0, N-1, &query, 'a'))
		TC--
	}
}

package main

import "fmt"

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

func count(low, high int, query *string, char byte) int {
	var counter int
	for i := low; i <= high; i++ {
		if (*query)[i] != char {
			counter++
		}
	}
	return counter
}

func solve(low, high int, query *string, char byte) int {
	if low == high {
		if char == (*query)[low] {
			return 0
		} else {
			return 1
		}
	} else {
		mid := (low + high) / 2
		leftRec := solve(low, mid, query, char+1) + count(mid+1, high, query, char)
		rightRec := solve(mid+1, high, query, char+1) + count(low, mid, query, char)
		return min(leftRec, rightRec)
	}
}

func main() {
	var TC int
	fmt.Scan(&TC)

	for TC != 0 {
		var n int
		var query string
		fmt.Scan(&n)
		fmt.Scan(&query)

		fmt.Println(solve(0, n-1, &query, 'a'))
		TC--
	}
}

package main

import "fmt"

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

func count(low, high int, char byte, query *string) int {
	var counter int
	for i := low; i <= high; i++ {
		if (*query)[i] != char {
			counter++
		}
	}
	return counter
}

func solve(low, high int, char byte, query *string) int {
	if low == high {
		if (*query)[low] == char {
			return 0
		} else {
			return 1
		}
	} else {
		mid := (low + high) / 2
		// [0-mid] is all c && [mid+1, high] is c+1 good
		left := count(low, mid, char, query) + solve(mid+1, high, char+1, query)

		// [0-mid] is c+1 good && [mid+1, high] is c+1 good
		right := count(mid+1, high, char, query) + solve(low, mid, char+1, query)
		return min(left, right)
	}
}

func main() {
	var TC int
	fmt.Scan(&TC)
	for TC != 0 {
		var n int
		var query string
		fmt.Scan(&n)
		fmt.Scan(&query)

		fmt.Println(solve(0, n-1, 'a', &query))
		TC--
	}
}

package main

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

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func f(s string, b byte) int {
	n := len(s)
	if n == 1 {
		if s[0] == b {
			return 0
		}
		return 1
	}
	n >>= 1
	return n + min(f(s[n:], b+1)-strings.Count(s[:n], string(b)), f(s[:n], b+1)-strings.Count(s[n:], string(b)))
}

// github.com/EndlessCheng/codeforces-go
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	t, n, s := 0, 0, ""
	for Fscan(in, &t); t > 0; t-- {
		Fscan(in, &n, &s)
		Fprintln(out, f(s, 'a'))
	}
}

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1385D(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	min := func(a, b int) int {
		if a < b {
			return a
		}
		return b
	}

	var t, n int
	var s string
	var f func(s string, b byte) int
	f = func(s string, b byte) int {
		n := len(s)
		if n == 1 {
			if s[0] == b {
				return 0
			}
			return 1
		}
		n >>= 1
		return n + min(f(s[n:], b+1)-strings.Count(s[:n], string(b)), f(s[:n], b+1)-strings.Count(s[n:], string(b)))
	}
	for Fscan(in, &t); t > 0; t-- {
		Fscan(in, &n, &s)
		Fprintln(out, f(s, 'a'))
	}
}

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

package main

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

func goodCorrect(str string, c byte, l, r int) int {
	if r-l == 1 {
		if str[l] == c {
			return 0
		} else {
			return 1
		}
	}

	diff1 := 0
	diff2 := 0
	for i := l; i < (l+r)/2; i++ {
		if str[i] != c {
			diff1++
		}
	}

	for i := (l + r) / 2; i < r; i++ {
		if str[i] != c {
			diff2++
		}
	}
	diff := 0
	if diff1 <= diff2 {
		diff = diff1
		diff += goodCorrect(str, c+1, (l+r)/2, r)
	} else {
		diff = diff2
		diff += goodCorrect(str, c+1, l, (l+r)/2)
	}

	return diff
}

func main() {
	in := bufio.NewReader(os.Stdin)
	var t int
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		var n int
		fmt.Fscan(in, &n)
		var str string
		fmt.Fscan(in, &str)
		fmt.Println(goodCorrect(str, 'a', 0, n))
	}
}


// 56A
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var n int
	var y int
	var c int = 0
	var x string
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		fmt.Scan(&x)
		y, _ = strconv.Atoi(x)
		if y < 18 && y != 0 || x == "0" || x == "ABSINTH" || x == "BEER" || x == "BRANDY" || x == "CHAMPAGNE" || x == "GIN" || x == "RUM" || x == "SAKE" || x == "TEQUILA" || x == "VODKA" || x == "WHISKEY" || x == "WINE" {
			c++
		}
	}
	fmt.Println(c)
}

// 56A
package main

import (
	"fmt"
	"strconv"
)

func a(b int) int {
	var n string
	var ans int
	for i := 0; i < b; i++ {
		fmt.Scan(&n)
		if n == "ABSINTH" || n == "BEER" || n == "BRANDY" || n == "CHAMPAGNE" || n == "GIN" || n == "RUM" || n == "SAKE" || n == "TEQUILA" || n == "VODKA" || n == "WHISKEY" || n == "WINE" {
			ans++
		} else if n[0] == '1' || n[0] == '2' || n[0] == '3' || n[0] == '4' || n[0] == '5' || n[0] == '6' || n[0] == '7' || n[0] == '8' || n[0] == '9' || n[0] == '0' {
			c, _ := strconv.Atoi(n)
			if c < 18 {
				ans++
			}
		}
	}
	return ans
}

func main() {
	var n int
	fmt.Scan(&n)
	fmt.Println(a(n))
}

package main

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

func main(){
	var n int
	r := bufio.NewScanner(os.Stdin)
	r.Split(bufio.ScanWords)
	w := bufio.NewWriter(os.Stdout)
	r.Scan()
	n, _ = strconv.Atoi(r.Text())
	tot := 0
	var temp string
	for i:=0; i<n; i++ {
		r.Scan()
		temp = r.Text()
		if string(temp) == "ABSINTH" || string(temp) == "BEER" || string(temp) == "BRANDY" || string(temp) == "CHAMPAGNE" || string(temp) == "GIN" || string(temp) == "RUM" || string(temp) == "SAKE" || string(temp) == "TEQUILA" || string(temp) == "VODKA" || string(temp) == "WHISKEY" || string(temp) == "WINE" || string(temp) == "0"|| string(temp) == "1"|| string(temp) == "2"|| string(temp) == "3"|| string(temp) == "4"|| string(temp) == "5"|| string(temp) == "6"|| string(temp) == "7"|| string(temp) == "8"|| string(temp) == "9"|| string(temp) == "10"|| string(temp) == "11"|| string(temp) == "12"|| string(temp) == "13"|| string(temp) == "14"|| string(temp) == "15"|| string(temp) == "16"|| string(temp) == "17" {
			tot += 1
		}
	}
	w.WriteString(strconv.Itoa(tot)+"\n")
	w.Flush()
}

// 56A
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var n, y int
	var c int = 0
	var x string
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		fmt.Scan(&x)
		y, _ = strconv.Atoi(x)
		if y < 19 && x != "ABSINTH" && x != "BEER" && x != "BRANDY" && x != "CHAMPAGNE" && x != "GIN" && x != "RUM" && x != "SAKE" && x != "TEQUILA" && x != "VODKA" && x != "WHISKEY" && x != "WINE" {
			c++
		}
	}
	fmt.Println(c)
}

package main

import (
	"fmt"
	"strconv"
)

func main() {
	var n int
	var y int
	var c int = 0
	var x string
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		fmt.Scan(&x)
		y, _ = strconv.Atoi(x)
		if y < 18 && y != 0 && len(x) < 101 || x == "ABSINTH" || x == "BEER" || x == "BRANDY" || x == "CHAMPAGNE" || x == "GIN" || x == "RUM" || x == "SAKE" || x == "TEQUILA" || x == "VODKA" || x == "WHISKEY" || x == "WINE" {
			c++
		}
	}
	fmt.Println(c)
}

// 56A
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var n int
	var y int
	var c int = 0
	var x string
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		fmt.Scan(&x)
		y, _ = strconv.Atoi(x)
		if y < 18 && y != 0 || x == "ABSINTH" || x == "BEER" || x == "BRANDY" || x == "CHAMPAGNE" || x == "GIN" || x == "RUM" || x == "SAKE" || x == "TEQUILA" || x == "VODKA" || x == "WHISKEY" || x == "WINE" {
			c++
		}
	}
	fmt.Println(c)
}

package main

import (
	"fmt"
	"strconv"
)

func main() {
	var n int
	var y int
	var c int = 0
	var x string
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		fmt.Scan(&x)
		y, _ = strconv.Atoi(x)
		if y < 18 || x == "ABSINTH" || x == "BEER" || x == "BRANDY" || x == "CHAMPAGNE" || x == "GIN" || x == "RUM" || x == "SAKE" || x == "TEQUILA" || x == "VODKA" || x == "WHISKEY" || x == "WINE" {
			c++
		}
	}
	fmt.Println(c)
}

// 56A
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var n, y int
	var c int = 0
	var x string
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		fmt.Scan(&x)
		y, _ = strconv.Atoi(x)
		if y < 18 && x != "ABSINTH" && x != "BEER" && x != "BRANDY" && x != "CHAMPAGNE" && x != "GIN" && x != "RUM" && x != "SAKE" && x != "TEQUILA" && x != "VODKA" && x != "WHISKEY" && x != "WINE" {
			c++
		}
	}
	fmt.Println(c)
}

// 56A
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var n int
	var y int
	var c int = 0
	var x string
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		fmt.Scan(&x)
		y, _ = strconv.Atoi(x)
		if y < 18 && y != 0 && len(x) < 100 || x == "ABSINTH" || x == "BEER" || x == "BRANDY" || x == "CHAMPAGNE" || x == "GIN" || x == "RUM" || x == "SAKE" || x == "TEQUILA" || x == "VODKA" || x == "WHISKEY" || x == "WINE" {
			c++
		}
	}
	fmt.Println(c)
}

// 56A
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var n, y int
	var c int = 0
	var x string
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		fmt.Scan(&x)
		y, _ = strconv.Atoi(x)
		if y < 18 && x != "ABSINTH" && x != "BEER" && x != "BRANDY" && x != "CHAMPAGNE" && x != "SAKE" && x != "TEQUILA" && x != "VODKA" && x != "WINE" {
			c++
		}
	}
	fmt.Println(c)
}

package main

import (
	"fmt"
	"strconv"
)

func main() {
	var n int
	var y int
	var c int = 0
	var x string
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		fmt.Scan(&x)
		y, _ = strconv.Atoi(x)
		if y < 18 && y > 0 && len(x) < 101 || x == "ABSINTH" || x == "BEER" || x == "BRANDY" || x == "CHAMPAGNE" || x == "GIN" || x == "RUM" || x == "SAKE" || x == "TEQUILA" || x == "VODKA" || x == "WHISKEY" || x == "WINE" {
			c++
		}
	}
	fmt.Println(c)
}

// 56A
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var n, y int
	var c int = 0
	var x string
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		fmt.Scan(&x)
		y, _ = strconv.Atoi(x)
		if y < 18 && x != "ABSINTH" && x != "BEER" && x != "BRANDY" && x != "CHAMPAGNE" && x != "RUM" && x != "SAKE" && x != "TEQUILA" && x != "VODKA" && x != "WHISKEY" && x != "WINE" {
			c++
		}
	}
	fmt.Println(c)
}

package main

import (
	"fmt"
	"strconv"
)

func main() {
	var n int
	var y int
	var c int = 0
	var x string
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		fmt.Scan(&x)
		y, _ = strconv.Atoi(x)
		if y < 18 && y != 0 && len(x) < 101 || x == "ABSINTH" || x == "BEER" || x == "BRANDY" || x == "CHAMPAGNE" || x == "GIN" || x == "RUM" || x == "SAKE" || x == "TEQUILA" || x == "VODKA" || x == "WHISKEY" || x == "WINE" {
			c++
			fmt.Println(len(x))
		}
	}
	fmt.Println(c)
}

// 56A
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var n, y int
	var c int = 0
	var x string
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		fmt.Scan(&x)
		y, _ = strconv.Atoi(x)
		if y < 18 && x != "ABSINTH" && x != "BEER" && x != "BRANDY" && x != "CHAMPAGNE" && x != "RUM" && x != "SAKE" && x != "TEQUILA" && x != "VODKA" && x != "WINE" {
			c++
		}
	}
	fmt.Println(c)
}


package main

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

type shift struct {
	b, e, d int
}

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

	var T int
	fmt.Fscanf(r, "%d\n", &T)

	for t := 0; t < T; t++ {
		var n int
		fmt.Fscanf(r, "%d\n", &n)
		arr := make([]int, n)
		tmp := make([]int, n)

		for i := 0; i < n; i++ {
			fmt.Fscanf(r, "%d", &arr[i])
		}
		fmt.Fscanf(r, "\n")

		res := []shift{}
		for i := 0; i < n; i++ {
			k := i
			for j := i; j < n; j++ {
				if arr[j] < arr[k] {
					k = j
				}
			}

			//	fmt.Println(arr, "-", i, k)

			if k-i != 0 {
				d := k - i
				res = append(res, shift{i + 1, k + 1, d})
				x := arr[i : k+1]
				for j := i; j <= k; j++ {
					tmp[j] = x[(j-i+d)%(d+1)]
				}
				copy(arr[i:k+1], tmp[i:k+1])
			}
		}

		fmt.Println(len(res))
		for _, s := range res {
			fmt.Println(s.b, s.e, s.d)
		}
	}
}

package main

import "fmt"

type Shift struct {
	From int
	To   int
	N    int
}

func main() {
	var iterations int
	fmt.Scan(&iterations)
	for ; iterations > 0; iterations-- {
		var n int
		fmt.Scan(&n)
		var arr []int
		for ; n > 0; n-- {
			var v int
			fmt.Scan(&v)
			arr = append(arr, v)
		}

		var result []Shift
		for i := range arr {
			m := imin(arr, i)
			if m == i {
				continue
			}
			item := arr[m]
			// shift
			for j := m; j > i; j-- {
				arr[j] = arr[j-1]
			}
			arr[i] = item
			result = append(result, Shift{From: i + 1, To: m + 1, N: m - i})
		}
		fmt.Println(len(result))
		for _, x := range result {
			fmt.Printf("%d %d %d\n", x.From, x.To, x.N)
		}
	}

}

func imin(arr []int, from int) int {
	result := from
	for i := from; i < len(arr); i++ {
		if arr[i] < arr[result] {
			result = i
		}
	}
	return result
}

package main

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

var n int

var a[]int

func main() {

	r := bufio.NewReader(os.Stdin)

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

	for i := 0; i < t; i++ {
		fmt.Fscan(r, &n)

		a = make([]int, n)

		for j := 0; j < n; j++ {
			fmt.Fscan(r, &a[j])
		}

		solve()
	}
}

type pair struct {
	v int
	idx int
}

type byV []*pair

func (a byV) Len() int           { return len(a) }
func (a byV) Less(i, j int) bool { return a[i].v < a[j].v }
func (a byV) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func solve() {

	//2 4 4 1 1 5 2 4 3

	//1 2 4 4 1 5 2 4 3

	//1 1 2 4 4 5 2 4 3

	//

	start := 0

	var ans [][3]int

	for i := 0; i < n - 1; i++ {

		var min int = 1e9 + 5
		var minidx int

		for j := start; j < n; j++ {
			if a[j] < min {
				min = a[j]
				minidx = j
			}
		}
		if minidx == start {
			start++
			continue
		}

		ans = append(ans, [3]int{start + 1, minidx + 1, minidx - start})

		nums := minidx - start + 1

		target := start
		elemToPut := a[target]

		a[target] = a[minidx]

		count := 0

		for ;count < nums - 1; {
			target = target - start

			p := target - minidx + start

			if p < 0 {
				p += nums
			}
			p += start
			temp := a[p]

			a[p] = elemToPut

			elemToPut = temp
			target = p

			count++
		}
		start++
	}

	fmt.Println(len(ans))

	for j := 0; j < len(ans); j++ {
		a := ans[j]
		fmt.Printf("%d %d %d", a[0], a[1], a[2])
		fmt.Println()
	}
}

package main

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

type node struct {
	val,id int
}
type sc struct {
	l,r,d int
}

func main()  {
	var t,n,s int
	in:=bufio.NewReader(os.Stdin)
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		fmt.Fscan(in,&n)
		a:=make([]node,n)
		s=0
		for i:=0;i<n;i++{
			fmt.Fscan(in,&a[i].val)
			a[i].id=i
		}
		sort.Slice(a,func(x,y int) bool {
			if a[x].val==a[y].val{
				return a[x].id<a[y].id
			}
			return a[x].val<a[y].val
		})
		cc:=[]sc{}
		for k:=0;k<n;k++{
			if a[k].id-k!=0{
				s++
				cc=append(cc,sc{k+1,a[k].id+1,a[k].id-k})
			}
			for j:=0;j<n;j++{
				if k==j{
					continue
				}
				if a[j].id<a[k].id && a[j].id>=k{
					a[j].id-=k+a[k].id-k
					if a[j].id<0{
						a[j].id+=a[k].id+1
					}
				}
			}
		}
		fmt.Println(s)
		for w:=0;w<s;w++{
			fmt.Println(cc[w].l,cc[w].r,cc[w].d)
		}
	}

}
func max(x,y int) int {
	if x>y{
		return x
	}else{
		return y
	}
}

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)

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

		shifts := [][]int{}
		for i := 0; i < n; i++ {
			low := i
			for j := i + 1; j < n; j++ {
				if arr[j] < arr[low] {
					low = j
				}
			}

			if low != i {
				// misplaced
				shifts = append(shifts, []int{i + 1, low + 1, low - i})
				temp := make([]int, n)
				copy(temp, arr)
				arr[i] = arr[low]
				for x := i; x < low; x++ {
					arr[x+1] = temp[x]
				}
			}
		}

		fmt.Fprintln(out, len(shifts))
		for _, z := range shifts {
			fmt.Fprintln(out, z[0], z[1], z[2])
		}
	}
}

package main

import (
	"bytes"
	"fmt"
)

func print_shifts(slice []int) (n int, ans string) {
	n = 0
	buf := bytes.NewBufferString(ans)

	for i, val := range slice {
		j := i - 1
		for j >= 0 {
			// fmt.Println(slice[j], j)
			if val < slice[j] {
				slice[j+1] = slice[j]
				slice[j] = val
			} else {

				break
			}
			j--
		}
		l := j + 2
		r := i + 1

		if (l - r) != 0 {
			n++
			fmt.Fprintln(buf, l, r, r-l)
			// fmt.Println(l, r, r-l)
		}
	}

	ans = buf.String()
	return
}

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

	for i := 0; i < n; i++ {
		l := 0
		fmt.Scan(&l)

		arr := make([]int, l)
		for j := 0; j < l; j++ {
			fmt.Scan(&arr[j])
		}

		n, ans := print_shifts(arr)
		fmt.Println(n)
		fmt.Print(ans)
	}
}

package main

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

type Action struct {
	left, right, shift int
}

func (a Action) String() string {
	return fmt.Sprintf("%d %d %d", a.left, a.right, a.shift)
}

var (
	reader = bufio.NewReader(os.Stdin)
	// writer  = bufio.NewWriter(os.Stdout)
	t, n int
)

func main() {
	fmt.Fscan(reader, &t)
	for ; t > 0; t-- {
		fmt.Fscan(reader, &n)
		a := make([]int, n)
		var r []Action
		for i := 0; i < n; i++ {
			fmt.Fscan(reader, &a[i])
		}
		for i := 0; i < n-1; i++ {
			minp := i
			for j := i + 1; j < n; j++ {
				if a[j] < a[minp] {
					minp = j
				}
			}
			if minp > i {
				x := a[minp]
				for j := minp; j > i; j-- {
					a[j] = a[j-1]
				}
				a[i] = x
				r = append(r, Action{i + 1, minp + 1, minp - i})
			}
		}
		fmt.Println(len(r))
		for _, x := range r {
			fmt.Println(x)
		}
	}
}

package main

import "fmt"

type Shift struct {
	From int
	To   int
	N    int
}

func main() {
	var iterations int
	fmt.Scan(&iterations)
	for ; iterations > 0; iterations-- {
		var n int
		fmt.Scan(&n)
		var arr []int
		for ; n > 0; n-- {
			var v int
			fmt.Scan(&v)
			arr = append(arr, v)
		}

		var result []Shift
		for i := range arr {
			m := imin(arr, i)
			if m == i {
				continue
			}
			for j := 0; j < m-i; j++ {
				arr[i+j], arr[m-j] = arr[m-j], arr[i+j]
			}
			result = append(result, Shift{From: i + 1, To: m + 1, N: m - i})
		}
		fmt.Println(len(result))
		for _, x := range result {
			fmt.Printf("%d %d %d\n", x.From, x.To, x.N)
		}
	}

}

func imin(arr []int, from int) int {
	result := from
	for i := from; i < len(arr); i++ {
		if arr[i] < arr[result] {
			result = i
		}
	}
	return result
}

package main

import "fmt"

type Shift struct {
	From int
	To   int
	N    int
}

func main() {
	var iterations int
	fmt.Scanf("%d", &iterations)
	for ; iterations > 0; iterations-- {
		var n int
		fmt.Scanf("%d", &n)
		var arr []int
		for ; n > 0; n-- {
			var v int
			fmt.Scanf("%d", &v)
			arr = append(arr, v)
		}

		var result []Shift
		for i := range arr {
			m := imin(arr, i)
			if m == i {
				continue
			}
			for j := 0; j < m-i; j++ {
				arr[i+j], arr[m-j] = arr[m-j], arr[i+j]
			}
			result = append(result, Shift{From: i + 1, To: m + 1, N: m - i})
		}
		fmt.Println(len(result))
		for _, x := range result {
			fmt.Printf("%d %d %d\n", x.From, x.To, x.N)
		}
	}

}

func imin(arr []int, from int) int {
	result := from
	for i := from; i < len(arr); i++ {
		if arr[i] < arr[result] {
			result = i
		}
	}
	return result
}

package main

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

var n int

var a[]int

func main() {

	r := bufio.NewReader(os.Stdin)

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

	for i := 0; i < t; i++ {
		fmt.Fscan(r, &n)

		a = make([]int, n)

		for j := 0; j < n; j++ {
			fmt.Fscan(r, &a[j])
		}

		solve()
	}
}

type pair struct {
	v int
	idx int
}

type byV []*pair

func (a byV) Len() int           { return len(a) }
func (a byV) Less(i, j int) bool { return a[i].v < a[j].v }
func (a byV) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func solve() {

	//2 4 4 1 1 5 2 4 3

	//1 2 4 4 1 5 2 4 3

	//1 1 2 4 4 5 2 4 3

	//

	start := 0

	fmt.Println(n - 1)

	for i := 0; i < n - 1; i++ {

		var min int = 1e9 + 5
		var minidx int

		for j := start; j < n; j++ {
			if a[j] < min {
				min = a[j]
				minidx = j
			}
		}

		fmt.Printf("%d %d %d", start + 1, minidx + 1, minidx - start)
		fmt.Println()

		nums := minidx - start + 1

		target := start
		elemToPut := a[target]

		a[target] = a[minidx]

		count := 0

		for ;count < nums - 1; {
			target = target - start

			p := target - minidx + start

			if p < 0 {
				p += nums
			}
			p += start
			temp := a[p]

			a[p] = elemToPut

			elemToPut = temp
			target = p

			count++
		}
		start++
	}
}

package main

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

var n int

var a[]int

func main() {

	r := bufio.NewReader(os.Stdin)

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

	for i := 0; i < t; i++ {
		fmt.Fscan(r, &n)

		a = make([]int, n)

		for j := 0; j < n; j++ {
			fmt.Fscan(r, &a[j])
		}

		solve()
	}
}

type pair struct {
	v int
	idx int
}

type byV []*pair

func (a byV) Len() int           { return len(a) }
func (a byV) Less(i, j int) bool { return a[i].v < a[j].v }
func (a byV) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func solve() {

	//2 4 4 1 1 5 2 4 3

	//1 2 4 4 1 5 2 4 3

	//1 1 2 4 4 5 2 4 3

	//

	start := 0

	for i := 0; i < n; i++ {

		var min int = 1e9 + 5
		var minidx int

		for j := start; j < n; j++ {
			if a[j] < min {
				min = a[j]
				minidx = j
			}
		}

		fmt.Printf("%d %d %d", start + 1, minidx + 1, minidx - start)
		fmt.Println()

		nums := minidx - start + 1

		target := start
		elemToPut := a[target]

		a[target] = a[minidx]

		count := 0

		for ;count < nums - 1; {
			target = target - start

			p := target - minidx + start

			if p < 0 {
				p += nums
			}
			p += start
			temp := a[p]

			a[p] = elemToPut

			elemToPut = temp
			target = p

			count++
		}
		start++
	}
}

package main

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

type node struct {
	val,id int
}

func main()  {
	var t,n int
	in:=bufio.NewReader(os.Stdin)
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		fmt.Fscan(in,&n)
		a:=make([]node,n)
		for i:=0;i<n;i++{
			fmt.Fscan(in,&a[i].val)
			a[i].id=i
		}
		sort.Slice(a,func(x,y int) bool {
			if a[x].val==a[y].val{
				return a[x].id<a[y].id
			}
			return a[x].val<a[y].val
		})
		fmt.Println(n)
		for k:=0;k<n;k++{
			fmt.Println(k+1,a[k].id+1,a[k].id-k)
			for j:=0;j<n;j++{
				if k==j{
					continue
				}
				if a[j].id<a[k].id && a[j].id>=k{
					//fmt.Println(a[j].val,a[j].id)
					a[j].id-=k+a[k].id-k
					//fmt.Println(j,a[j].val,a[j].id)
					if a[j].id<0{
						a[j].id+=a[k].id+1
					}
				}
			}
		}
	}

}
func max(x,y int) int {
	if x>y{
		return x
	}else{
		return y
	}
}


package main

import (
	"fmt"
	"os"
)

const maxn int = 100100

var g [maxn][]int
var vis [maxn]bool

func good() {
	fmt.Println("FHTAGN!")
	os.Exit(0)
}

func bad() {
	fmt.Println("NO")
	os.Exit(0)
}

func dfs(v int) (cnt int) {
	cnt = 1
	vis[v] = true
	for _, u := range g[v] {
		if !vis[u] {
			cnt += dfs(u)
		}
	}
	return
}

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	if n != m {
		bad()
	}
	for i := 0; i < m; i ++ {
		var v, u int
		fmt.Scan(&v, & u)
		v --
		u --
		g[v] = append(g[v], u)
		g[u] = append(g[u], v)
	}
	if dfs(0) != n {
		bad()
	}
	good()
	return
}

package main

import (
	"fmt"
)

type Graph struct {
	n int
	adj [][]int
}
func build(g *Graph, n int) {
	g.n = n
	g.adj = make([][]int, n)
}
func add(g *Graph, v, u int) {
	g.adj[v] = append(g.adj[v], u)
	g.adj[u] = append(g.adj[u], v)
}

var n, m int
var g Graph
var used []bool

func dfs(v int) {
	used[v] = true
	for _, u := range g.adj[v] {
		if used[u] {
			continue
		}
		dfs(u)
	}
}

func main() {
	fmt.Scanf("%d %d\n", &n, &m)
	build(&g, n)
	for i := 0; i < m; i++ {
		var v, u int
		fmt.Scanf("%d %d\n", &v, &u)
		v--
		u--
		add(&g, v, u)
	}
	used = make([]bool, n)
	dfs(0)
	ok := true
	for v := 0; v < n; v++ {
		if !used[v] {
			ok = false
			break
		}
	}
	ans := (n == m) && ok
	if ans {
		fmt.Println("FHTAGN!")
	} else {
		fmt.Println("NO")
	}
}

package main

import "fmt"

type Graph struct {
	n int
	adj [][]int
}
func build(g *Graph, n int) {
	g.n = n
	g.adj = make([][]int, n)
}
func add(g *Graph, v, u int) {
	g.adj[v] = append(g.adj[v], u)
	g.adj[u] = append(g.adj[u], v)
}

var n, m int
var g Graph
var used []bool

func dfs(v int) {
	used[v] = true
	for i := 0; i < len(g.adj[v]); i++ {
		u := g.adj[v][i]
		if used[u] {
			continue
		}
		dfs(u)
	}
}

func main() {
	fmt.Scanf("%d %d\n", &n, &m)
	build(&g, n)
	for i := 0; i < m; i++ {
		var v, u int
		fmt.Scanf("%d %d\n", &v, &u)
		v--
		u--
		add(&g, v, u)
	}
	used = make([]bool, n)
	dfs(0)
	ok := true
	for v := 0; v < n; v++ {
		if !used[v] {
			ok = false
			break
		}
	}
	ans := (n == m) && ok
	if ans {
		fmt.Println("FHTAGN!")
	} else {
		fmt.Println("NO")
	}
}

package main

import "fmt"

type Graph struct {
	n int
	adj [][]int
}
func build(g *Graph, n int) {
	g.n = n
	g.adj = make([][]int, n)
}
func add(g *Graph, v, u int) {
	g.adj[v] = append(g.adj[v], u)
	g.adj[u] = append(g.adj[u], v)
}

var n, m int
var g Graph
var used []bool

func dfs(v int) {
	used[v] = true
	for i := 0; i < len(g.adj[v]); i++ {
		cool := make([]int, 0)
		for j := 0; j < len(g.adj[v]); j++ {
			cool = append(cool, g.adj[v][j])
		}
		u := cool[i]
		if used[u] {
			continue
		}
		dfs(u)
	}
}

func main() {
	fmt.Scanf("%d %d\n", &n, &m)
	build(&g, n)
	for i := 0; i < m; i++ {
		var v, u int
		fmt.Scanf("%d %d\n", &v, &u)
		v--
		u--
		add(&g, v, u)
	}
	used = make([]bool, n)
	dfs(0)
	ok := true
	for v := 0; v < n; v++ {
		if !used[v] {
			ok = false
			break
		}
	}
	ans := (n == m) && ok
	if ans {
		fmt.Println("FHTAGN!")
	} else {
		fmt.Println("NO")
	}
}

package main

import (
	"fmt"
)

type Graph struct {
	n int
	adj [][]int
}
func (g *Graph) build(n int) {
	g.n = n
	g.adj = make([][]int, n)
}
func (g *Graph) add(v, u int) {
	g.adj[v] = append(g.adj[v], u)
	g.adj[u] = append(g.adj[u], v)
}

var n, m int
var g Graph
var used []bool

func dfs(v int) {
	used[v] = true
	for _, u := range g.adj[v] {
		if used[u] {
			continue
		}
		dfs(u)
	}
}

func main() {
	fmt.Scanf("%d %d\n", &n, &m)
	g.build(n)
	for i := 0; i < m; i++ {
		var v, u int
		fmt.Scanf("%d %d\n", &v, &u)
		v--
		u--
		g.add(v, u)
	}
	used = make([]bool, n)
	dfs(0)
	ok := true
	for v := 0; v < n; v++ {
		if !used[v] {
			ok = false
			break
		}
	}
	ans := (n == m) && ok
	if ans {
		fmt.Println("FHTAGN!")
	} else {
		fmt.Println("NO")
	}
}

package main

import "fmt"

type Graph struct {
	n int
	adj [][]int
}
func build(g *Graph, n int) {
	g.n = n
	g.adj = make([][]int, n)
}
func add(g *Graph, v, u int) {
	g.adj[v] = append(g.adj[v], u)
	g.adj[u] = append(g.adj[u], v)
}

var n, m int
var g Graph
var used []bool

func dfs(v int) {
	used[v] = true
	for i := 0; i < len(g.adj[v]); i++ {
		cool := g.adj[v]
		u := cool[i]
		if used[u] {
			continue
		}
		dfs(u)
	}
}

func main() {
	fmt.Scanf("%d %d\n", &n, &m)
	build(&g, n)
	for i := 0; i < m; i++ {
		var v, u int
		fmt.Scanf("%d %d\n", &v, &u)
		v--
		u--
		add(&g, v, u)
	}
	used = make([]bool, n)
	dfs(0)
	ok := true
	for v := 0; v < n; v++ {
		if !used[v] {
			ok = false
			break
		}
	}
	ans := (n == m) && ok
	if ans {
		fmt.Println("FHTAGN!")
	} else {
		fmt.Println("NO")
	}
}


// Codeforces 140 C not done, need faster structures
package main

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

type RCnt struct {
	r   int
	cnt int
}
type RCnts []RCnt

func (s RCnts) Len() int {
	return len(s)
}
func (s RCnts) Less(i, j int) bool {
	return s[i].cnt < s[j].cnt
}
func (s RCnts) Swap(i, j int) {
	s[i], s[j] = s[j], s[i]
}
func (s RCnts) UpHeap(i int) {
	for i>0 {
		ih := i/2
		if !s.Less(ih,i) {
			break
		}
		s.Swap(ih,i)
		i = ih
	}
}

type Snowman struct {
	a, b, c int
}

func (s *Snowman) newSnow(aa,ba,ca int) {
	s.a = aa
	s.b = ba
	s.c = ca
	// fmt.Printf("new snow %d %d %d\n", s.a, s.b, s.c)
}

func (s *Snowman) printSnow() {
	// sort to a > b > c
	// fmt.Printf("bef sort %d %d %d\n", s.a, s.b, s.c)
	if s.a < s.b {
		s.b, s.a = s.a, s.b
	}
	if s.b < s.c {
		s.b, s.c = s.c, s.b
		if s.a < s.b {
			s.b, s.a = s.a, s.b
		}
	}
	fmt.Printf("%d %d %d\n", s.a, s.b, s.c)
}

var ra RCnts
var nra,nLeft int

func (s RCnts) DownHeap(i int) {
	ra[i].cnt--
	for i<nra {
		a := ra[i].cnt
		i0 := 2*i
		i1 := 2*i+1
		if i0 >= nra {
			break
		} else if i1 < nra {
			if ra[i1].cnt > ra[i0].cnt {
				i0 = i1
			}
		}
		b := ra[i0].cnt
		if b > a {
			ra.Swap(i,i0)
			i = i0
		} else {
			break
		}
	}
	if ra[i].cnt==0 {
		nLeft--
	}
}

func next3Vals() (int,int,int) {
	if ra[0].cnt==0 || ra[1].cnt==0 || ra[2].cnt==0 {
		sort.Sort(sort.Reverse(ra))
	}
	a := ra[0].r
	b := ra[1].r
	c := ra[2].r
	ra.DownHeap(2)
	ra.DownHeap(1)
	ra.DownHeap(0)
	printRa()
	return a,b,c
}

func printRa() {
	return
	for i:=0; i<nra; i++ {
		fmt.Printf("(%d, %d) ", ra[i].cnt, ra[i].r);
	}
	fmt.Println();
}

func main() {
	// reading n
	in := bufio.NewReader(os.Stdin)
	s, err := in.ReadString('\n')
	if err != nil {
		fmt.Println("first read failure", err)
		return
	}
	ss := strings.Split(strings.Trim(s, " \n\r"), " ")
	n, err1 := strconv.Atoi(ss[0])
	if err1 != nil {
		fmt.Println("n atoi failure", err1)
		return
	}
	// reading radiuses
	s, err = in.ReadString('\n')
	if err != nil {
		fmt.Println("second read failure", err)
		return
	}
	ss = strings.Split(strings.Trim(s, " \n\r"), " ")
	rmap := make(map[int]int)
	for i := 0; i < n; i++ {
		r, err2 := strconv.Atoi(ss[i])
		if err2 != nil {
			fmt.Println("r atoi failure", err1)
			return
		}
		c, ok := rmap[r]
		if ok {
			rmap[r] = c + 1
		} else {
			rmap[r] = 1
		}
	}
	nra = len(rmap)
	ra = RCnts(make([]RCnt, nra))
	ir := 0
	for r, c := range rmap {
		ra[ir].r = r
		ra[ir].cnt = c
		ir++
	}
	sort.Sort(sort.Reverse(ra))
	nLeft = nra
	printRa()

	// calculating
	maxSna := n / 3
	sna := make([]Snowman, maxSna)
	nSna := 0
	for nLeft >= 3 {
		a,b,c := next3Vals()
		sna[nSna].newSnow(a,b,c)
		nSna++
	}

	// print result
	fmt.Printf("%d\n", nSna)
	for i := 0; i < nSna; i++ {
		sna[i].printSnow()
	}
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
	. "container/heap"
	"sort"
)

type pair struct {
	r, cnt int
}
type pairHeap []pair

func (h pairHeap) Len() int              { return len(h) }
func (h pairHeap) Less(i, j int) bool    { return h[i].cnt > h[j].cnt }
func (h pairHeap) Swap(i, j int)         { h[i], h[j] = h[j], h[i] }
func (h *pairHeap) Push(v interface{})   { *h = append(*h, v.(pair)) }
func (h *pairHeap) Pop() (v interface{}) { n := len(*h); *h, v = (*h)[:n-1], (*h)[n-1]; return }

// github.com/EndlessCheng/codeforces-go
func Sol140C(reader io.Reader, writer io.Writer) {
	in := bufio.NewReader(reader)
	out := bufio.NewWriter(writer)
	defer out.Flush()

	rCnt := map[int]int{}
	var n, r int
	for Fscan(in, &n); n > 0; n-- {
		Fscan(in, &r)
		rCnt[r]++
	}

	_h := make(pairHeap, 0, len(rCnt))
	for r, cnt := range rCnt {
		_h = append(_h, pair{r, cnt})
	}
	h := &_h
	Init(h)

	ans := [][3]int{}
	for len(_h) >= 3 {
		ps := [3]pair{Pop(h).(pair), Pop(h).(pair), Pop(h).(pair)}
		ans = append(ans, [3]int{ps[0].r, ps[1].r, ps[2].r})
		for _, p := range ps {
			p.cnt--
			if p.cnt > 0 {
				Push(h, p)
			}
		}
	}
	Fprintln(out, len(ans))
	for _, rs := range ans {
		balls := rs[:]
		sort.Ints(balls)
		Fprintln(out, balls[2], balls[1], balls[0])
	}
}

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

package main

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

func main() {
	in := bufio.NewReaderSize(os.Stdin, 1<<16)
	var n int
	fmt.Fscan(in, &n)
	cnt := make(map[int]int)
	for i := 0; i < n; i++ {
		var r int
		fmt.Fscan(in, &r)
		cnt[r]++
	}
	ans := sort.Search(n/3+1, func(ans int) bool {
		got := 0
		for _, v := range cnt {
			if v > ans {
				v = ans
			}
			got += v
			if got >= ans*3 {
				return false
			}
		}
		return true
	}) - 1
	snowmen := make([][]int, ans)
	i := 0
	for k, v := range cnt {
		if i == ans*3 {
			break
		}
		if v > ans {
			v = ans
		}
		for i < ans*3 && v > 0 {
			snowmen[i%ans] = append(snowmen[i%ans], k)
			v--
			i++
		}
	}

	out := bufio.NewWriterSize(os.Stdout, 1<<16)
	defer out.Flush()
	fmt.Fprintln(out, ans)
	for _, sm := range snowmen {
		sort.Ints(sm)
		fmt.Fprintln(out, sm[2], sm[1], sm[0])
	}
}

package main

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

func main() {
	in := bufio.NewReaderSize(os.Stdin, 1<<16)
	var n int
	fmt.Fscan(in, &n)
	r := make([]int, n)
	for i := range r {
		fmt.Fscan(in, &r[i])
	}
	sort.Ints(r)
	var snowmen [][]int
	full := 0
	for i := n - 1; i >= 0; i-- {
		cur := r[i]
		j := i-1
		for j >= 0 && r[j] == cur {
			j--
		}
		prevFull := full
		for k := 0; k < i - j; k++ {
			if prevFull + k >= len(snowmen) {
				snowmen = append(snowmen, make([]int, 0, 3))
			}
			snowmen[prevFull+k] = append(snowmen[prevFull+k], cur)
			if len(snowmen[prevFull+k]) == 3 {
				full++
			}
		}
		i = j+1
	}

	out := bufio.NewWriterSize(os.Stdout, 1<<16)
	defer out.Flush()
	fmt.Fprintln(out, full)
	for _, sm := range snowmen[:full] {
		fmt.Fprintln(out, sm[0], sm[1], sm[2])
	}
}


package main

import (
	"fmt"
	"os"
)

func ReadInput() []string {
	var t int
	fmt.Fscan(os.Stdin, &t)
	var res []string = make([]string, 0, t)
	for i := 0; i < t; i++ {
		var l int
		fmt.Fscan(os.Stdin, &l)
		var s string
		fmt.Fscan(os.Stdin, &s)
		res = append(res, s)
	}
	return res
}

func main() {
	Sslice := ReadInput()
	//fmt.Println(Sslice)
	for i := 0; i < len(Sslice); i++ {
		var s string
		OtherRow := Sslice[i]
		for j := 0; j < len(OtherRow); j++ {
			switch OtherRow[j] {
			case 'U':
				s += "D"
			case 'D':
				s += "U"
			default:
				s += string(OtherRow[j])
			}
		}
		fmt.Println(s)
	}
}

package main

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

var r *bufio.Reader = bufio.NewReader(os.Stdin)
var w *bufio.Writer = bufio.NewWriter(os.Stdout)

func solve() {
	var n int
	var s string
	fmt.Fscanf(r, "%d\n%s\n", &n, &s)

	var ans string
	for _, v := range s {
		if v == 'U' {
			ans += "D"
		} else if v == 'D' {
			ans += "U"
		} else if v == 'L' || v == 'R' {
			ans += string(v)
		}
	}

	fmt.Fprintln(w, ans)
}

func main() {
	defer w.Flush()

	var n int
	fmt.Fscanf(r, "%d\n", &n)
	for i := 0; i < n; i++ {
		solve()
	}
}

package main

import "fmt"

func solve() {
	var n int
	var s string
	fmt.Scanf("%d\n%s\n", &n, &s)

	var ans string
	for _, v := range s {
		if v == 'U' {
			ans += "D"
		} else if v == 'D' {
			ans += "U"
		} else if v == 'L' || v == 'R' {
			ans += string(v)
		}
	}

	fmt.Println(ans)
}

func main() {
	var n int
	fmt.Scanf("%d\n", &n)
	for i := 0; i < n; i++ {
		solve()
	}
}

package main
import(
    "fmt"
    "bufio"
    "os"
)
func main() {
	var t int
	var in = bufio.NewReader(os.Stdin)
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var n int
		fmt.Fscan(in,&n)
		var word string
		fmt.Fscan(in,&word)
		for j:=0;j<n;j++{
			if string(word[j]) == "L" {
				fmt.Printf("%s",string(word[j:j+2]))
				j++
			} else {
				if string(word[j]) == "U" {
					fmt.Printf("D")
				} else {
					fmt.Printf("U")
				}
			}
		}
		fmt.Println()
	}
}

// https://codeforces.com/problemset/problem/1567/A

package main

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

// Domino Disaster
// Alice has a grid with 2 rows and n columns. She fully covers the grid using n dominoes of size 1×2 — Alice may place them vertically or horizontally, and each cell should be covered by exactly one domino.
// Now, she decided to show one row of the grid to Bob. Help Bob and figure out what the other row of the grid looks like!

// Input
// The input consists of multiple test cases. The first line contains an integer t (1≤t≤5000) — the number of test cases. The description of the test cases follows.
// The first line of each test case contains an integer n (1≤n≤100) — the width of the grid.
// The second line of each test case contains a string s consisting of n characters, each of which is either L, R, U, or D, representing the left, right, top, or bottom half of a domino, respectively (see notes for better understanding). This string represents one of the rows of the grid.
// Additional constraint on the input: each input corresponds to at least one valid tiling.

// Output
// For each test case, output one string — the other row of the grid, using the same format as the input string. If there are multiple answers, print any.

func main() {
	var reader = bufio.NewReader(os.Stdin)
	var writer = bufio.NewWriter(os.Stdout)
	var c, t, n, i int
	var s, ans string

	for c, _ = fmt.Fscan(reader, &t); c == 1; c, _ = fmt.Fscan(reader, &t) {
		for ; t > 0; t-- {
			fmt.Fscan(reader, &n, &s)
			ans = s

			for i = 0; i < n; i++ {
				if s[i] == 'U' {
					ans = ans[:i] + "D" + ans[i+1:]
				} else if s[i] == 'D' {
					ans = ans[:i] + "U" + ans[i+1:]
				}
			}

			fmt.Fprintln(writer, ans)
		}
	}

	writer.Flush()
}

// https://codeforces.com/problemset/problem/1567/A

package main

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

// Domino Disaster
// Alice has a grid with 2 rows and n columns. She fully covers the grid using n dominoes of size 1×2 — Alice may place them vertically or horizontally, and each cell should be covered by exactly one domino.
// Now, she decided to show one row of the grid to Bob. Help Bob and figure out what the other row of the grid looks like!

// Input
// The input consists of multiple test cases. The first line contains an integer t (1≤t≤5000) — the number of test cases. The description of the test cases follows.
// The first line of each test case contains an integer n (1≤n≤100) — the width of the grid.
// The second line of each test case contains a string s consisting of n characters, each of which is either L, R, U, or D, representing the left, right, top, or bottom half of a domino, respectively (see notes for better understanding). This string represents one of the rows of the grid.
// Additional constraint on the input: each input corresponds to at least one valid tiling.

// Output
// For each test case, output one string — the other row of the grid, using the same format as the input string. If there are multiple answers, print any.

func main() {
	var reader = bufio.NewReader(os.Stdin)
	var c, t, n, i int
	var s, ans string

	for c, _ = fmt.Fscan(reader, &t); c == 1; c, _ = fmt.Fscan(reader, &t) {
		for ; t > 0; t-- {
			fmt.Fscan(reader, &n, &s)
			ans = s

			for i = 0; i < n; i++ {
				if s[i] == 'U' {
					ans = ans[:i] + "D" + ans[i+1:]
				} else if s[i] == 'D' {
					ans = ans[:i] + "U" + ans[i+1:]
				}
			}

			fmt.Println(ans)
		}
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	tc := readInt(in)

	for i := 0; i < tc; i++ {
        _ = readInt(in)
        line := readLine(in)
        for _, r := range line {
            if r == 'D' {
                fmt.Printf("%s", "U")
            } else if r == 'U' {
                fmt.Printf("%s", "D")
            } else {
                fmt.Printf("%s", string(r))
            }
        }
        fmt.Println()
	}
}

func readInt(in *bufio.Reader) int {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.Atoi(nStr)
	return n
}

func readLine(in *bufio.Reader) string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")
	return line
}

func readLineNumbs(in *bufio.Reader) []string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")
	numbs := strings.Split(line, " ")
	return numbs
}

func readArrInt(in *bufio.Reader) []int {
	numbs := readLineNumbs(in)
	arr := make([]int, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.Atoi(n)
		arr[i] = val
	}
	return arr
}

func readArrInt64(in *bufio.Reader) []int64 {
	numbs := readLineNumbs(in)
	arr := make([]int64, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.ParseInt(n, 10, 64)
		arr[i] = val
	}
	return arr
}

func max(a, b int) int {
    if a > b {
        return a
    }
    return b
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	tc := readInt(in)

	for i := 0; i < tc; i++ {
        _ = readInt(in)
        line := readLine(in)
        opp := map[rune]rune{
            'D': 'U',
            'U': 'D',
            'L': 'L',
            'R': 'R',
        }
        for _, r := range line {
            fmt.Printf("%s", string(opp[r]))
        }
        fmt.Println()
	}
}

func readInt(in *bufio.Reader) int {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.Atoi(nStr)
	return n
}

func readLine(in *bufio.Reader) string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")
	return line
}

func readLineNumbs(in *bufio.Reader) []string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")
	numbs := strings.Split(line, " ")
	return numbs
}

func readArrInt(in *bufio.Reader) []int {
	numbs := readLineNumbs(in)
	arr := make([]int, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.Atoi(n)
		arr[i] = val
	}
	return arr
}

func readArrInt64(in *bufio.Reader) []int64 {
	numbs := readLineNumbs(in)
	arr := make([]int64, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.ParseInt(n, 10, 64)
		arr[i] = val
	}
	return arr
}

func max(a, b int) int {
    if a > b {
        return a
    }
    return b
}

package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	t, _ := strconv.Atoi(scanner.Text())
	for i := 0; i < t; i++ {
		scanner.Scan()
		n, _ := strconv.Atoi(scanner.Text())
		scanner.Scan()
		sl := strings.Split(scanner.Text(), "")
		for j := 0; j < n; j++ {
			if sl[j] == "U" {
				fmt.Print("D")
			} else if sl[j] == "D" {
				fmt.Print("U")
			} else {
				fmt.Print(sl[j])
			}
		}
		fmt.Print("\n")
	}
}

package main

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

func solve() {
	f := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	N, n, s := 0, 0, ""
	fmt.Fscan(f, &N)
	for i := 0; i < N; i++ {
		fmt.Fscan(f, &n, &s)
		ans := ""
		for j := 0; j < n; j++ {
			if string(s[j]) == "U" {
				ans += "D"
			} else if string(s[j]) == "D" {
				ans += "U"
			} else {
				ans += string(s[j])
			}
		}
		fmt.Fprintln(w, ans)
	}
	w.Flush()
}

func main() {
	solve()
}

package main

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

type CF1567A struct {
	sc        *bufio.Reader
	split     []string
	index     int
	separator string
}

func (in *CF1567A) GetLine() string {
	line, err := in.sc.ReadString('\n')
	if err != nil {
		fmt.Println("error line:", line, " err: ", err)
	}
	in.split = []string{}
	in.index = 0
	return line
}
func (in *CF1567A) load() {
	if len(in.split) <= in.index {
		in.split = strings.Split(in.GetLine(), in.separator)
		in.index = 0
	}
}

func (in *CF1567A) NextInt() int {
	in.load()
	val, _ := strconv.Atoi(strings.TrimSpace(in.split[in.index]))
	in.index++
	return val
}

func (in *CF1567A) NextInt64() int64 {
	in.load()
	val, _ := strconv.ParseInt(strings.TrimSpace(in.split[in.index]), 10, 64)
	in.index++
	return val
}

func (in *CF1567A) NextString() string {
	in.load()
	val := strings.TrimSpace(in.split[in.index])
	in.index++
	return val
}

/**
Run solve the problem CF1567A
Date: 19/10/21
User: pepradere
URL: https://codeforces.com/problemset/problem/1567/A
Problem: CF1567A
**/
func (in *CF1567A) Run() {
	t := in.NextInt()
	for ; t > 0; t-- {
		n := in.NextInt()
		str := in.NextString()
		sol := ""
		for i := 0; i < n; i++ {
			if str[i] == 'L' || str[i] == 'R' {
				sol += string(str[i])
			} else if str[i] == 'U'{
				sol += "D"
			} else {
				sol += "U"
			}
		}
		fmt.Println(sol)
	}
}

func NewCF1567A(r *bufio.Reader) *CF1567A {
	return &CF1567A{
		sc:        r,
		split:     []string{},
		index:     0,
		separator: " ",
	}
}

func main() {
	NewCF1567A(bufio.NewReader(os.Stdin)).Run()
}

package main

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

func solve(n int, s []byte) string {
	r := make([]byte, n)
	for i, c := range s {
		r[i] = c
		if c == 'D' {
			r[i] = 'U'
		} else if c == 'U' {
			r[i] = 'D'
		}
	}
	return string(r)
}

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

func main() {
	fmt.Fscan(reader, &t)
	for ; t > 0; t-- {
		fmt.Fscan(reader, &n)
		s := make([]byte, n)
		fmt.Fscan(reader, &s)
		fmt.Println(solve(n, s))
	}
}

package main

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

func main() {
	stdin := bufio.NewReader(os.Stdin)
	stdout := bufio.NewWriter(os.Stdout)
	defer stdout.Flush()
	var tc int
	fmt.Fscanf(stdin, "%d\n", &tc)
	for ; tc > 0; tc-- {
		var dummy int
		var dom string
		fmt.Fscanf(stdin, "%d\n%s\n", &dummy, &dom)
		for i := 0; i < len(dom); i++ {
			switch dom[i] {
			case 'U':
				stdout.WriteByte('D')
			case 'D':
				stdout.WriteByte('U')
			default:
				stdout.WriteByte('L')
				stdout.WriteByte('R')
				i++
			}
		}
		stdout.WriteByte('\n')
	}
}

package main

import "fmt"

func main() {
	var t int64

	_, err := fmt.Scan(&t)
	if err != nil {
		return
	}
	for i := int64(0); i < t; i++ {
		var c int64
		fmt.Scan(&c)
		var str string
		fmt.Scan(&str)
		var otherStr string
		for _, char := range str {
			if char == 'L' || char == 'R' {
				otherStr += string(char)
			} else {
				switch char {
				case 'U':
					otherStr += string('D')
				case 'D':
					otherStr += string('U')
				}
			}
		}
		fmt.Println(otherStr)

	}
}

package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	for n > 0 {
		var cnt int
		var str string
		fmt.Scan(&cnt, &str)
		ans := ""
		for i := 0; i < cnt; i++ {
			if str[i] == 'U' {
				ans += "D"
			} else if str[i] == 'D' {
				ans += "U"
			} else {
				ans += string(str[i])
			}
		}
		fmt.Println(ans)
		n--
	}
}

package main

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

var r = bufio.NewReader(os.Stdin)
var w = bufio.NewWriter(os.Stdout)

func main() {
	var T, n int
	var s string
	for Fscan(r, &T); T > 0; T-- {
		Fscan(r, &n)
		Fscan(r, &s)
		res := make([]byte, n)
		for i := 0; i < n; i++ {
			if s[i] == 'U' {
				res[i] = 'D'
			} else if s[i] == 'D' {
				res[i] = 'U'
			} else {
				res[i] = s[i]
			}
		}
		Fprintln(w, string(res))
	}
	_ = w.Flush()
}

package main

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

// var m []int
// err = json.Unmarshal([]byte(r.FormValue("example")), &m)

// for i := 0; i < len(m); i++ {
// 	fmt.Println(m[i])
// }

// sort.Slice(arr, func(i, j int) bool {
// 	return arr[i] > arr[j]
// })

func MIN(x, y int64) int64 {
	if x > y {
		return y
	} else {
		return x
	}
}

func MINN(x, y int) int {
	if x > y {
		return y
	} else {
		return x
	}
}

func MKO(x, y int64) int64 {
	if x < y {
		return 0
	} else {
		return x - y + 1
	}
}

func MAX(x, y int64) int64 {
	if x > y {
		return x
	} else {
		return y
	}
}

func MAXX(x, y int) int {
	if x > y {
		return x
	} else {
		return y
	}
}

func LCM(x, y int) int {
	if x >= y {
		initial := x
		for i := 1; i < y+2; i++ {
			if initial%y == 0 {
				break
			} else {
				initial = initial + x
			}

		}
		return initial
	} else {
		initial := y
		for i := 1; i < x+2; i++ {
			if initial%x == 0 {
				break
			} else {
				initial = initial + y
			}

		}
		return initial
	}
}

func GCD(x, y int64) int64 {
	if x*y == 0 {
		return MAX(x, y)
	} else {
		var l, q int64
		l = MAX(x, y)
		q = MIN(x, y)
		var m int64
		for l*q > 0 {
			a := l % q
			b := l - a
			cc := int64(b / q)
			remain := l - cc*q
			l = MAX(remain, q)
			q = MIN(remain, q)
			if l*q == 0 {
				m = l + q
				break
			}

		}
		return m
	}
}

func IsItPrime(x int) bool {
	if x < 10 {
		if x == 2 || x == 3 || x == 5 || x == 7 {
			return true
		} else {
			return false
		}
	} else {
		j := 0
		k := math.Sqrt(float64(x))
		for m := 3; m <= int(k); {
			if x%m == 0 {
				j = 1
				break
			}
			m = m + 2
		}
		if j == 1 {
			return false
		} else {
			return true
		}
	}
}

func PrimeFactorization(n int) (pfs map[int]int) {
	pfs = make(map[int]int)

	// Get the number of 2s that divide n
	for n%2 == 0 {
		if _, ok := pfs[2]; ok {
			pfs[2] += 1
		} else {
			pfs[2] = 1
		}
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			if _, ok := pfs[i]; ok {
				pfs[i] += 1
			} else {
				pfs[i] = 1
			}
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs[n] = 1
	}

	return
}

func NumberOfDivisors(n int) int {
	pfs := PrimeFactorization(n)

	num := 1
	for _, exponents := range pfs {
		num *= (exponents + 1)
	}

	return num
}

func KthPrime(x int) (y int) {
	if x == 1 {
		y = 2
	}
	if x == 2 {
		y = 3
	}
	if x > 2 {
		var sum int = 2
		begin := 5
		for sum < x+1 {
			if IsItPrime(begin) == true {
				sum++
			}
			if sum == x {
				y = begin
				break
			} else {
				if begin%6 == 1 {
					begin = begin + 4
				} else {
					begin = begin + 2
				}
			}
		}
	}
	return
}

func MODULE(x, y int) int {
	if x > y {
		return x - y
	} else {
		return y - x
	}
}

func BITAND(x, y int64) int64 {
	var ans int64
	begin := x
	sec := y
	var count int64 = 1
	for 1 == 1 {
		if (begin%2)*(sec%2) == 1 {
			ans = ans + count
			count = count * 2
			begin = int64(begin / 2)
			sec = int64(sec / 2)
			if begin*sec == 0 {
				break
			}

		} else {
			count = count * 2
			begin = int64(begin / 2)
			sec = int64(sec / 2)
			if begin*sec == 0 {
				break
			}
		}
	}
	return ans
}

func Sum(n, m int) int {
	var ans int

	if n == 1 {
		return 0
	} else {
		for i := 2; i < n; i++ {
			ans = (ans + Sum(i, m)) % m
		}
		for j := 2; j < n+1; j++ {
			ans = (ans + Sum(n/j, m)) % m
		}
		return ans
	}
}

var t int

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &t)
	for o := 0; o < t; o++ {
		var n int
		fmt.Fscan(input, &n)

		STRING := make([]byte, 0)
		fmt.Fscan(input, &STRING)
		for i := 0; i < n; i++ {
			if STRING[i] == 68 {
				STRING[i] = 85
			} else {
				if STRING[i] == 85 {
					STRING[i] = 68
				}
			}

		}
		fmt.Println(string(STRING))

	}
}

package main

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

var input io.Reader = bufio.NewReader(os.Stdin)

//fmt.Fscan(input,&x)
//fmt.Println(x)
func main() {
	var T int
	for fmt.Fscan(input, &T); T > 0; T-- {
		var n int
		var s string
		fmt.Fscan(input, &n, &s)
		c := []byte(s)
		for i := 0; i < n; i++ {
			if s[i] == 'U' {
				c[i] = 'D'
			} else if s[i] == 'D' {
				c[i] = 'U'
			}
		}
		s = string(c)
		fmt.Println(s)
	}
}

package main

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

func tr(s string, t, r rune) (q string) {
	for _, c := range s {
		switch c {
		case t:
			c = r
		case r:
			c = t
		}
		q = q + string(c)
	}
	return
}

func main() {
	s := bufio.NewScanner(os.Stdin)

	s.Scan() // discard number of test cases
	for s.Scan() {
		s.Scan() // discard width of the grid
		fmt.Println(tr(s.Text(), 'U', 'D'))
	}
}

package main

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

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

	var T int
	fmt.Fscanf(r, "%d\n", &T)

	for t := 0; t < T; t++ {
		var n int
		var s string

		fmt.Fscanf(r, "%d\n", &n)
		fmt.Fscanf(r, "%s\n", &s)

		res := make([]byte, n)

		for i := 0; i < n; i++ {
			if s[i] == 'L' || s[i] == 'R' {
				res[i] = s[i]
			} else if s[i] == 'U' {
				res[i] = 'D'
			} else if s[i] == 'D' {
				res[i] = 'U'
			}
		}

		fmt.Println(string(res))
	}
}

package main

import "fmt"

func main() {
	var t,n int
	var s string
	fmt.Scanln(&t)
	for l := 0; l < t; l++ {
		fmt.Scanln(&n)
		fmt.Scanln(&s)
		tmp := ""
		for _, v := range s {
			if v == 'U' {
				tmp = tmp + "D"
			} else if v == 'D' {
				tmp = tmp + "U"
			} else {
				tmp = tmp + string(v)
			}
		}
		fmt.Println(tmp)
 	}
}

package main

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

type Scanner struct {
	*bufio.Scanner
}

func NewWordScanner(reader io.Reader) *Scanner {
	scanner := bufio.NewScanner(reader)
	scanner.Split(bufio.ScanWords)
	return &Scanner{scanner}
}

func (s *Scanner) Word() string {
	s.Scan()
	return s.Text()
}

func (s *Scanner) Int() int {
	s.Scan()
	n, _ := strconv.Atoi(s.Text())
	return n
}

func (s *Scanner) Int64() int64 {
	s.Scan()
	n, _ := strconv.ParseInt(s.Text(), 10, 64)
	return n
}

func (s *Scanner) Words(count int) []string {
	words := make([]string, count)
	for i := range words {
		words[i] = s.Word()
	}
	return words
}

func (s *Scanner) Ints(count int) []int {
	ints := make([]int, count)
	for i := range ints {
		ints[i] = s.Int()
	}
	return ints
}

func (s *Scanner) Int64s(count int) []int64 {
	int64s := make([]int64, count)
	for i := range int64s {
		int64s[i] = s.Int64()
	}
	return int64s
}

func solve(s string) string {
	other := map[byte]byte {
		'U': 'D',
		'D': 'U',
		'L': 'L',
		'R': 'R',
	}

	b := []byte(s)
	for i := range b {
		b[i] = other[b[i]]
	}
	return string(b)
}

func main() {
	stdin := NewWordScanner(os.Stdin)
	tests := stdin.Int()

	for i := 0; i < tests; i++ {
		_, s := stdin.Int(), stdin.Word()
		fmt.Println(solve(s))
	}
}

package main

import "fmt"

func fillDominoRow(row1 string) (row2 string) {
	row2 = ""
	i := 0
	for i < len(row1) {
		if row1[i] == 'L' {
			row2 += "LR"
			i++
		}
		if row1[i] == 'U' {
			row2 += "D"
		}
		if row1[i] == 'D' {
			row2 += "U"
		}
		i++
	}
	return row2
}

func main() {
	var k, n int
	var row string
	fmt.Scanf("%d\n", &k)
	res := make([]string, k)
	for i := 0; i < k; i++ {
		fmt.Scanf("%d\n %s\n", &n, &row)
		res[i] = fillDominoRow(row)
	}
	for i := 0; i < k; i++ {
		fmt.Println(res[i])
	}
}

package main

import "fmt"

func fillDominoRow(row1 string) (row2 string) {
	row2 = ""
	i := 0
	for i < len(row1) {
		if row1[i] == 'L' {
			row2 += "LR"
			i++
		}
		if row1[i] == 'U' {
			row2 += "D"
		}
		if row1[i] == 'D' {
			row2 += "U"
		}
		i++
	}
	return row2
}

func main() {
	var k, n int
	var row string
	fmt.Scanf("%d", &k)
	res := make([]string, k)
	for i := 0; i < k; i++ {
		fmt.Scanf("%d", &n)
		fmt.Scanf("%s", &row)
		res[i] = fillDominoRow(row)
	}
	for i := 0; i < k; i++ {
		fmt.Println(res[i])
	}
}

package main

import "fmt"

func fillDominoRow(row1 string) (row2 string) {
	row2 = ""
	i := 0
	for i < len(row1) {
		if row1[i] == 'L' {
			row2 += "LR"
			i++
		}
		if row1[i] == 'U' {
			row2 += "D"
		}
		if row1[i] == 'D' {
			row2 += "U"
		}
		i++
	}
	return row2
}

func main() {
	var k, n int
	var row string
	fmt.Scanf("%d", &k)
	res := make([]string, k)
	for i := 0; i < k; i++ {
		fmt.Scanf("%d", &n)
		fmt.Scanf("%s", &row)
		res[i] = fillDominoRow(row)
	}
	for i := 0; i < k; i++ {
		println(res[i])
	}
}

package main

import "fmt"

func fillDominoRow(row1 string) (row2 string) {
	row2 = ""
	i := 0
	for i < len(row1) {
		if row1[i] == 'L' {
			row2 += "LR"
			i++
		}
		if row1[i] == 'U' {
			row2 += "D"
		}
		if row1[i] == 'D' {
			row2 += "U"
		}
		i++
	}
	return row2
}

func main() {
	var k, n int
	var row string
	fmt.Scanf("%d", &k)
	for i := 0; i < k; i++ {
		fmt.Scanf("%d", &n)
		fmt.Scanf("%s", &row)
		res := fillDominoRow(row)
		fmt.Print(res)
	}
}

package main

import "fmt"

func fillDominoRow(row1 string) (row2 string) {
	row2 = ""
	i := 0
	for i < len(row1) {
		if row1[i] == 'L' {
			row2 += "LR"
			i++
		}
		if row1[i] == 'U' {
			row2 += "D"
		}
		if row1[i] == 'D' {
			row2 += "U"
		}
		i++
	}
	return row2
}

func main() {
	var k, n int
	var row string
	fmt.Scanf("%d", &k)
	for i := 0; i < k; i++ {
		fmt.Scanf("%d", &n)
		fmt.Scanf("%s", &row)
		res := fillDominoRow(row)
		fmt.Println(res)
	}
}

package main

import "fmt"

func solve() {
	var n int
	var s string
	fmt.Scanf("%d\n%s", &n, &s)

	ans := ""
	for _, v := range s {
		if v == 'U' {
			ans += "D"
		} else if v == 'D' {
			ans += "U"
		} else if v == 'L' {
			ans += "LR"
		}
	}

	fmt.Println(ans)
}

func main() {
	var n int
	fmt.Scanf("%d\n", &n)
	for i := 0; i < n; i++ {
		solve()
	}
}

package main

import "fmt"

func solve() {
	var n int
	var s string
	fmt.Scanf("%d", &n)
	fmt.Scanf("%s", &s)

	ans := ""
	for _, v := range s {
		if v == 'U' {
			ans += "D"
		} else if v == 'D' {
			ans += "U"
		} else if v == 'L' {
			ans += "LR"
		}
	}

	fmt.Println(ans)
}

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

	for i := 0; i < n; i++ {
		solve()
	}
}

package main

import (
	"fmt"
	"os"
)

func ReadInput() []string {
	var t int
	fmt.Fscan(os.Stdin, &t)
	var res []string = make([]string, 0, t)
	for i := 0; i < t; i++ {
		var l int
		fmt.Fscanln(os.Stdin, &l)
		var s string
		fmt.Fscanln(os.Stdin, &s)
		res = append(res, s)
	}
	return res
}

func main() {
	Sslice := ReadInput()
	//fmt.Println(Sslice)
	for i := 0; i < len(Sslice); i++ {
		var s string
		OtherRow := Sslice[i]
		for j := 0; j < len(OtherRow); j++ {
			switch OtherRow[j] {
			case 'U':
				s += "D"
			case 'D':
				s += "U"
			default:
				s += string(OtherRow[j])
			}
		}
		fmt.Println(s)
	}
}