Bob is playing with $$$6$$$-sided dice. A net of such standard cube is shown below.He has an unlimited supply of these dice and wants to build a tower by stacking multiple dice on top of each other, while choosing the orientation of each dice. Then he counts the number of visible pips on the faces of the dice.For example, the number of visible pips on the tower below is $$$29$$$ — the number visible on the top is $$$1$$$, from the south $$$5$$$ and $$$3$$$, from the west $$$4$$$ and $$$2$$$, from the north $$$2$$$ and $$$4$$$ and from the east $$$3$$$ and $$$5$$$.The one at the bottom and the two sixes by which the dice are touching are not visible, so they are not counted towards total.Bob also has $$$t$$$ favourite integers $$$x_i$$$, and for every such integer his goal is to build such a tower that the number of visible pips is exactly $$$x_i$$$. For each of Bob's favourite integers determine whether it is possible to build a tower that has exactly that many visible pips.

The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 1000$$$) — the number of favourite integers of Bob.  The second line contains $$$t$$$ space-separated integers $$$x_i$$$ ($$$1 \leq x_i \leq 10^{18}$$$) — Bob's favourite integers.

For each of Bob's favourite integers, output "YES" if it is possible to build the tower, or "NO" otherwise (quotes for clarity).

NoteThe first example is mentioned in the problem statement.In the second example, one can build the tower by flipping the top dice from the previous tower.In the third example, one can use a single die that has $$$5$$$ on top.The fourth example is impossible.

package main

import (
	"bufio"
	"fmt"
	"math/big"
	"os"
	"strings"
)

func main() {
	var n int
	_, _ = fmt.Scanf("%d\n", &n)
	numberSlice := make([]big.Int, 0)

	reader := bufio.NewReader(os.Stdin)
	inputString, _ := reader.ReadString('\n')

	numberStringSlice := strings.Fields(inputString)
	for _, numberString := range numberStringSlice {
		var bigNumber big.Int
		bigNumber.SetString(numberString, 10)
		numberSlice = append(numberSlice, bigNumber)
	}

	for _, number := range numberSlice {
		if number.Cmp(big.NewInt(7))<0 {
			fmt.Print("NO\n")
			continue
		}
		var modRes big.Int
		modRes.Mod(&number, big.NewInt(14))
		if modRes.Cmp(big.NewInt(0)) == 0 {
			fmt.Print("NO\n")
			continue
		}
		cmpRes := modRes.Cmp(big.NewInt(7))
		if cmpRes < 0 {
			fmt.Print("YES\n")
		} else {
			fmt.Print("NO\n")
		}
	}
}

package main

import (
	"fmt"
	"strconv"
)

func div7Val(num string) int {
	val := 0

	for _, ch := range num {
		val = (val*3 + int(ch-'0')) % 7
	}

	return val
}

func main() {
	var n int
	fmt.Scanf("%d\n", &n)
	for i := 0; i < n; i++ {
		yes := false
		var num string
		fmt.Scanf("%s", &num)
		if len(num) <= 2 {
			num2, _ := strconv.Atoi(num)
			if num2 <= 14 {
				fmt.Println("NO")
				continue
			}
		}
		val := div7Val(num)
		for j := 1; j <= 6; j++ {
			if (val-j)%7 == 0 && int(num[len(num)-1]-'0')%2 == j%2 {
				yes = true
				break
			}
		}
		if yes {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

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

	var t, n int64
	for Fscan(in, &t); t > 0; t-- {
		Fscan(in, &n)
		n, k := n%14, n/14
		if k > 0 && 1 <= n && n <= 6 {
			Fprintln(out, "YES")
		} else {
			Fprintln(out, "NO")
		}
	}
}

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

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	n := 0
	fmt.Fscanf(in, "%d\n", &n)
	for i := 0; i < n; i++ {
		q := int64(0)
		fmt.Fscanf(in, "%d", &q)
		if q < 15 {
			fmt.Fprintf(out, "NO\n")
			continue
		}
		if q%14 >= 1 && q%14 <= 6 {
			fmt.Fprintf(out, "YES\n")
		} else {
			fmt.Fprintf(out, "NO\n")
		}
	}
	fmt.Fscanf(in, "\n")
	return
}

// first index in b >= a
func find(a int, b []int) int {
	n := len(b)
	if n == 0 {
		return -1
	}
	if b[n-1] < a {
		return -1
	}
	l := 0
	r := n - 1
	for l < r {
		mid := (l + r) / 2
		if b[mid] >= a {
			r = mid
		} else {
			l = mid + 1
		}
	}
	return l
}

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

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

package main

import "fmt"

func main(){
	var n int
	var arr []int64
	fmt.Scanln(&n)
	for i := 0; i < n; i++ {
		var num int64
		fmt.Scanf("%d", &num)
		arr = append(arr, num)
	}

	for i := 0; i < n; i++ {
		if(judge(arr[i])){
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

func judge(num int64) bool {
	if num < 14 {
		return false
	}
	i := num % 14
	if i <= 6 && i >= 1 {
		return true
	}
	return false
}

package main

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

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

	testCount := 0
	fmt.Fscanf(in, "%d\n", &testCount)

	for i := 0; i < testCount; i++ {
		x := int64(0)
		fmt.Fscanf(in, "%d", &x)

		r := x % 14
		if r >= 1 && r <= 6 && x > 14 {
			fmt.Fprintln(out, "YES")
		} else {
			fmt.Fprintln(out, "NO")
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"math/big"
	"os"
	"strconv"
	"strings"
)

func main() {
	var n int
	_, _ = fmt.Scanf("%d\n", &n)
	numberSlice := make([]big.Int, 0)

	reader := bufio.NewReader(os.Stdin)
	inputString, _ := reader.ReadString('\n')

	numberStringSlice := strings.Fields(inputString)
	for _, numberString := range numberStringSlice {
		number, _ := strconv.Atoi(numberString)
		numberSlice = append(numberSlice, *big.NewInt(int64(number)))
	}

	for _, number := range numberSlice {
		if number.Cmp(big.NewInt(7))<0 {
			fmt.Print("NO\n")
			continue
		}
		var modRes big.Int
		modRes.Mod(&number, big.NewInt(14))
		if modRes.Cmp(big.NewInt(0)) == 0 {
			fmt.Print("NO\n")
			continue
		}
		cmpRes := modRes.Cmp(big.NewInt(7))
		if cmpRes < 0 {
			fmt.Print("YES\n")
		} else {
			fmt.Print("NO\n")
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"math/big"
	"os"
	"strconv"
	"strings"
)

func main() {
	var n int
	_, _ = fmt.Scanf("%d\n", &n)
	numberSlice := make([]big.Int, 0)

	reader := bufio.NewReader(os.Stdin)
	inputString, _ := reader.ReadString('\n')

	numberStringSlice := strings.Fields(inputString)
	for _, numberString := range numberStringSlice {
		number, _ := strconv.Atoi(numberString)
		numberSlice = append(numberSlice, *big.NewInt(int64(number)))
	}

	for _, number := range numberSlice {
		if number.Cmp(big.NewInt(15))<0 {
			fmt.Print("NO\n")
			continue
		}
		var modRes big.Int
		modRes.Mod(&number, big.NewInt(14))
		cmpRes := modRes.Cmp(big.NewInt(7))
		if cmpRes < 0 {
			fmt.Print("YES\n")
		} else {
			fmt.Print("NO\n")
		}
	}
}

package main

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

func main() {
	var n int
	_, _ = fmt.Scanf("%d\n", &n)
	numberSlice := make([]int, 0)

	reader := bufio.NewReader(os.Stdin)
	inputString, _ := reader.ReadString('\n')

	numberStringSlice := strings.Fields(inputString)
	for _, numberString := range numberStringSlice {
		number, _ := strconv.Atoi(numberString)
		numberSlice = append(numberSlice, number)
	}

	for _, number := range numberSlice {
		if number < 7 {
			fmt.Print("NO\n")
			continue
		}
		if number%14 > 0 && number%14 < 7 {
			fmt.Print("YES\n")
		} else {
			fmt.Print("NO\n")
		}
	}
}

package main

import (
	"fmt"
)

func main() {
	var n int
	_, _ = fmt.Scanf("%d\n", &n)
	for i := 0; i < n; i++ {
		var number int
		_, _ = fmt.Scanf("%d\n", &number)
		if number%14 > 0 && number%14 < 7 {
			fmt.Print("YES\n")
		} else {
			fmt.Print("NO\n")
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"math/big"
	"os"
	"strconv"
	"strings"
)

func main() {
	var n int
	_, _ = fmt.Scanf("%d\n", &n)
	numberSlice := make([]big.Int, 0)

	reader := bufio.NewReader(os.Stdin)
	inputString, _ := reader.ReadString('\n')

	numberStringSlice := strings.Fields(inputString)
	for _, numberString := range numberStringSlice {
		number, _ := strconv.Atoi(numberString)
		numberSlice = append(numberSlice, *big.NewInt(int64(number)))
	}

	for _, number := range numberSlice {
		if number.Cmp(big.NewInt(7))<0 {
			fmt.Print("NO\n")
			continue
		}
		var modRes big.Int
		modRes.Mod(&number, big.NewInt(14))
		cmpRes := modRes.Cmp(big.NewInt(7))
		if cmpRes < 0 {
			fmt.Print("YES\n")
		} else {
			fmt.Print("NO\n")
		}
	}
}

package main

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

func main() {
	var n int
	_, _ = fmt.Scanf("%d\n", &n)
	numberSlice := make([]int, 0)

	reader := bufio.NewReader(os.Stdin)
	inputString, _ := reader.ReadString('\n')
	fmt.Print(inputString)

	numberStringSlice := strings.Fields(inputString)
	for _, numberString := range numberStringSlice {
		number, _ := strconv.Atoi(numberString)
		numberSlice = append(numberSlice, number)
	}

	for _, number := range numberSlice {
		if number%14 > 0 && number%14 < 7 {
			fmt.Print("YES\n")
		} else {
			fmt.Print("NO\n")
		}
	}
}

package main

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

func main() {
	var n int
	_, _ = fmt.Scanf("%d\n", &n)
	numberSlice := make([]int, 0)

	reader := bufio.NewReader(os.Stdin)
	inputString, _ := reader.ReadString('\n')

	numberStringSlice := strings.Fields(inputString)
	for _, numberString := range numberStringSlice {
		number, _ := strconv.Atoi(numberString)
		numberSlice = append(numberSlice, number)
	}

	for _, number := range numberSlice {
		if number%14 > 0 && number%14 < 7 {
			fmt.Print("YES\n")
		} else {
			fmt.Print("NO\n")
		}
	}
}

package main

import "fmt"

func div7Val(num string) int {
	val := 0

	for _, ch := range num {
		val = (val*3 + int(ch-'0')) % 7
	}

	return val
}

func main() {
	var n int
	fmt.Scanf("%d\n", &n)
	for i := 0; i < n; i++ {
		yes := false
		var num string
		fmt.Scanf("%s", &num)
		val := div7Val(num)
		for j := 1; j <= 6; j++ {
			if (val-j)%7 == 0 && int(num[len(num)-1]-'0')%2 == j%2 {
				yes = true
				break
			}
		}
		if yes {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import "fmt"

func div7Val(num string) int {
	val := 0

	for _, ch := range num {
		val = (val*3 + int(ch-'0')) % 7
	}

	return val
}

func main() {
	var n int
	fmt.Scanf("%d\n", &n)
	for i := 0; i < n; i++ {
		yes := false
		var num string
		fmt.Scanf("%s\n", &num)
		val := div7Val(num)
		for j := 1; j <= 6; j++ {
			if (val-j)%7 == 0 && int(num[len(num)-1]-'0')%2 == j%2 {
				yes = true
				break
			}
		}
		if yes {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

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

	var t, n int64
	for Fscan(in, &t); t > 0; t-- {
		Fscan(in, &n)
		n %= 14
		if 1 <= n && n <= 6 {
			Fprintln(out, "YES")
		} else {
			Fprintln(out, "NO")
		}
	}
}

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

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	n := 0
	fmt.Fscanf(in, "%d\n", &n)
	for i := 0; i < n; i++ {
		q := int64(0)
		fmt.Fscanf(in, "%d", &q)
		if q%14 >= 1 && q%14 <= 6 {
			fmt.Fprintf(out, "YES\n")
		} else {
			fmt.Fprintf(out, "NO\n")
		}
	}
	return
}

// first index in b >= a
func find(a int, b []int) int {
	n := len(b)
	if n == 0 {
		return -1
	}
	if b[n-1] < a {
		return -1
	}
	l := 0
	r := n - 1
	for l < r {
		mid := (l + r) / 2
		if b[mid] >= a {
			r = mid
		} else {
			l = mid + 1
		}
	}
	return l
}

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

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	n := 0
	fmt.Fscanf(in, "%d\n", &n)
	for i := 0; i < n; i++ {
		q := int64(0)
		fmt.Fscanf(in, "%d", &q)
		if q%14 >= 1 && q%14 <= 6 {
			fmt.Fprintf(out, "YES\n")
		} else {
			fmt.Fprintf(out, "NO\n")
		}
	}
	fmt.Fscanf(in, "\n")
	return
}

// first index in b >= a
func find(a int, b []int) int {
	n := len(b)
	if n == 0 {
		return -1
	}
	if b[n-1] < a {
		return -1
	}
	l := 0
	r := n - 1
	for l < r {
		mid := (l + r) / 2
		if b[mid] >= a {
			r = mid
		} else {
			l = mid + 1
		}
	}
	return l
}

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

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	n := 0
	fmt.Fscanf(in, "%d\n", &n)
	for i := 0; i < n; i++ {
		q := int64(0)
		fmt.Fscanf(in, "%d\n", &q)
		if q%14 >= 1 && q%14 <= 6 {
			fmt.Fprintf(out, "YES\n")
		} else {
			fmt.Fprintf(out, "NO\n")
		}
	}
	return
}

// first index in b >= a
func find(a int, b []int) int {
	n := len(b)
	if n == 0 {
		return -1
	}
	if b[n-1] < a {
		return -1
	}
	l := 0
	r := n - 1
	for l < r {
		mid := (l + r) / 2
		if b[mid] >= a {
			r = mid
		} else {
			l = mid + 1
		}
	}
	return l
}

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

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

package main

import "fmt"

func main(){
	var n int
	var arr []int
	fmt.Scanln(&n)
	for i := 0; i < n; i++ {
		var num int
		fmt.Scanf("%d", &num)
		arr = append(arr, num)
	}

	for i := 0; i < n; i++ {
		if(judge(arr[i])){
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

func judge(num int) bool {
	if num < 14 {
		return false
	}
	i := num % 14
	if i <= 6 && i >= 1 {
		return true
	}
	return false
}

package main

import "fmt"

func main(){
	var n int
	var arr []int
	fmt.Scanln(&n)
	for i := 0; i < n; i++ {
		var num int
		fmt.Scanf("%d", &num)
		arr = append(arr, num)
	}

	for i := 0; i < n; i++ {
		if(judge(arr[i])){
			println("YES")
		} else {
			println("NO")
		}
	}
}

func judge(num int) bool {
	if num < 14 {
		return false
	}
	i := num % 14
	if i <= 6 && i >= 1 {
		return true
	}
	return false
}

package main

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

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

	testCount := 0
	fmt.Fscanf(in, "%d\n", &testCount)

	for i := 0; i < testCount; i++ {
		n := 0
		fmt.Fscanf(in, "%d", &n)

		r := n % 14
		if r >= 1 && r <= 6 {
			fmt.Fprintln(out, "YES")
		} else {
			fmt.Fprintln(out, "NO")
		}
	}
}


A string is called diverse if it contains consecutive (adjacent) letters of the Latin alphabet and each letter occurs exactly once. For example, the following strings are diverse: "fced", "xyz", "r" and "dabcef". The following string are not diverse: "az", "aa", "bad" and "babc". Note that the letters 'a' and 'z' are not adjacent.Formally, consider positions of all letters in the string in the alphabet. These positions should form contiguous segment, i.e. they should come one by one without any gaps. And all letters in the string should be distinct (duplicates are not allowed).You are given a sequence of strings. For each string, if it is diverse, print "Yes". Otherwise, print "No".

The first line contains integer $$$n$$$ ($$$1 \le n \le 100$$$), denoting the number of strings to process. The following $$$n$$$ lines contains strings, one string per line. Each string contains only lowercase Latin letters, its length is between $$$1$$$ and $$$100$$$, inclusive.

Print $$$n$$$ lines, one line per a string in the input. The line should contain "Yes" if the corresponding string is diverse and "No" if the corresponding string is not diverse. You can print each letter in any case (upper or lower). For example, "YeS", "no" and "yES" are all acceptable.

package main

import (
	"fmt"
	"sort"
	"strings"
)

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

	for i := 0; i < n; i++ {
		ans := true
		var s string
		fmt.Scanf("%s\n", &s)
		split := strings.Split(s, "")
		sort.Strings(split)
		for j := 1; j < len(split); j++ {
			if []byte(split[j])[0] - []byte(split[j-1])[0] != 1 {
				ans = false
			}
		}

		if ans {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	}
}

package main

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

func main() {
	var n, last, flag int
	scr := bufio.NewReader(os.Stdin)
	// ocr := bufio.NewWriter(os.Stdout)

	var st string

	fmt.Fscanln(scr, &n)

	for i := 0; i < n; i++ {
		fmt.Fscanln(scr, &st)
		l := make([]int, 0)
		for _, y := range st {
			l = append(l, int(y))
		}
		sort.Sort(sort.IntSlice(l))
		for x, y := range l {
			if x == 0 {
				last = y
			} else {
				if y != last+1 {
					flag = 2
					break
				}
				last = y
			}
		}
		if flag == 2 {
			fmt.Println("NO")
		} else {
			fmt.Println("YES")
		}
		flag = 0
	}

}

package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	for ; n > 0; n-- {
		var s []byte
		fmt.Scan(&s)
		sort.Slice(s, func(i int, j int) bool { return s[i] < s[j] })
		various := true
		for i := 1; i < len(s); i++ {
			if s[i]-s[i-1] != 1 {
				various = false
				break
			}
		}
		if various {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	}
}

package main

import (
. "fmt"
. "sort"
. "strings"
)

func main() {
    var N int
    Scan(&N)

    for i := 0; i < N; i++ {
        var str string
        Scan(&str)
        arr := Split(str, "")
        Strings(arr)
        bisa := true
        for j := 1; j < len(str); j++ {
            if arr[j-1][0]+1 != arr[j][0] {
                bisa = false
                break
            }
        }
        if bisa {
            Println("Yes")
        } else {
            Println("No")
        }
    }
}

package main

import "fmt"

func sortStringWithBuble(s string) string  {
	b := []byte(s)
	for i := 0 ;i  < len(s);i++{
		for j := i + 1 ;j < len(s)  ;j++{
			if(b[i] > b[j]){
				temp := b[j];
				b[j] = b[i]
				b[i] = temp
			}
		}
	}
	rt := string(b)
	return rt
}

func main(){
	var n int
	fmt.Scan(&n)
	for i := 0 ; i < n;i ++{
		var s string
		fmt.Scan(&s)
		s = sortStringWithBuble(s)
		yes := true
		for j := 1 ; j < len(s);j++{
			if(s[j]  == s[j - 1] + 1){
				yes = true;
			}else{
				yes = false
				break;
			}
		}
		if(yes){
			fmt.Println("Yes")
		}else{
			fmt.Println("No")
		}
	}

}

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 getLine() string {
	s, _ := reader.ReadString('\n')
	for len(s) > 0 && (s[len(s)-1] == '\n' || s[len(s)-1] == '\r') {
		s = s[:len(s)-1]
	}
	return s
}

func main() {
	// STDOUT MUST BE FLUSHED MANUALLY!!!
	defer writer.Flush()

	var n int
	scanf("%d\n", &n)
	for ; n >= 1; n-- {
		var s string
		scanf("%s\n", &s)
		check := true
		if len(s) > 26 {
			check = false
		}
		var counts [26]bool
		ss := []rune(s)
		for i := 0; i < len(ss) && check; i++ {
			check = !counts[ss[i]-'a']
			counts[ss[i]-'a'] = true
		}
		status := 0
		for i := 0; i < 26 && check; i++ {
			switch status {
			case 0:
				if counts[i] {
					status = 1
				}
			case 1:
				if !counts[i] {
					status = 2
				}
			case 2:
				if counts[i] {
					check = false
				}
			}
		}
		if check {
			printf("Yes\n")
		} else {
			printf("No\n")
		}

	}
}

package main

import (
	"fmt"
	"os"
	"sort"
	"strings"
	"unicode/utf8"
)

func main() {
	_, err := os.Stat("in.txt")
	if err == nil {
		os.Stdin, err = os.OpenFile("in.txt", os.O_RDONLY, 0666)
	}

	var n int
	var a string
	fmt.Scan(&n)
	for i:=0; i<n; i++ {
		fmt.Scan(&a)
		isDiverse(a);
	}
}

func isDiverse(a string) {
		chars :=  strings.Split(a,"")
		var m []int

		for _, v :=range chars {
			c, _ := utf8.DecodeRuneInString(v)
			in:=int(c-'0')
			m = append(m,in)
		}
		sort.Ints(m)
		i:=0
		j:=0
		for _,v:=range m {
			if i==0 {
				i=v
			} else {
				if (v==(i+1)) {
					i=v
				} else {
					j++
				}
			}
		}
		if j==0 {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}

}

package main

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

// -----------------------------------------------------------------------------

// IO helper functions

// Returns next token from input.  It must be initialized by SetInput()
// before the first call.
var nextToken func() ([]byte, error)
var nextLine func() ([]byte, error)

// Holds a buffer for output.  It must be initialized by SetOutput().
// All IO fucntions (read*() and [e]print*()) should write to OutputWriter
// instead of this.
var OutputBuffer *bufio.Writer

// Holds an io.Writer.  It must be initialized by SetOutput()
var OutputWriter io.Writer

// Set IO functions for interactive input/output.
func SetInteractive(w io.Writer, r io.Reader) {
	SetUnbefferedInput(r)
	OutputBuffer = nil
	OutputWriter = w
}

// Setup OutputBuffer and OutputWriter.
func SetOutput(w io.Writer) {
	OutputBuffer = bufio.NewWriter(w)
	OutputWriter = OutputBuffer
}

// Flushes OutputBuffer
func Flush() {
	if OutputBuffer != nil {
		OutputBuffer.Flush()
	}
}

// Returns true if c is a white space
func IsSpace(c byte) bool {
	switch c {
	case '\t', '\n', '\v', '\f', '\r', ' ':
		return true
	}
	return false
}

func IsNewLine(c byte) bool {
	switch c {
	case '\n', '\r':
		return true
	}
	return false
}

// Setup nextToken with input buffer.
func SetInput(r io.Reader) {
	buf := new(bytes.Buffer)
	var b []byte

	var i int
	rest := func() ([]byte, error) {
		for i < len(b) && IsSpace(b[i]) {
			i++
		}
		if i == len(b) {
			return nil, io.ErrUnexpectedEOF
		}
		j := i
		for i < len(b) && !IsSpace(b[i]) {
			i++
		}
		return b[j:i], nil
	}
	initial := func() ([]byte, error) {
		io.Copy(buf, r)
		b = buf.Bytes()
		nextToken = rest
		return rest()
	}
	nextToken = initial

	restLn := func() ([]byte, error) {
		for i < len(b) && IsNewLine(b[i]) {
			i++
		}
		if i == len(b) {
			return nil, io.ErrUnexpectedEOF
		}
		j := i
		for i < len(b) && !IsNewLine(b[i]) {
			i++
		}
		return b[j:i], nil
	}

	initialLn := func() ([]byte, error) {
		io.Copy(buf, r)
		b = buf.Bytes()
		nextLine = restLn
		return restLn()
	}
	nextLine = initialLn
}

// Setup nextToken without input buffer.
func SetUnbefferedInput(r io.Reader) {
	buf := bufio.NewReader(r)
	var b []byte

	var i int
	nextToken = func() ([]byte, error) {
		var err error
		if i == len(b) {
			b, err = buf.ReadBytes('\n')
			if err != nil {
				return nil, err
			}
			i = 0
			j := len(b) - 1
			for 0 <= j && IsSpace(b[j]) {
				j--
			}
			b = b[0 : j+1]
		}
		for i < len(b) && IsSpace(b[i]) {
			i++
		}
		j := i
		for i < len(b) && !IsSpace(b[i]) {
			i++
		}
		if i == j {
			return nil, io.ErrUnexpectedEOF
		}
		return b[j:i], nil
	}
}

// -----------------------------------------------------------------------------

// IO functions

// Reads next token and return it as []byte
func readb() []byte {
	b, err := nextToken()
	if err != nil {
		panic(err)
	}
	return b
}

// Reads next token and return it as string
func reads() string {
	return string(readb())
}

// Read next line as []byte
func readbln() []byte {
	b, err := nextLine()
	if err != nil {
		panic(err)
	}
	return b
}

// Read next line as string
func readsln() string {
	return string(readbln())
}

// Reads next token and return it as int64
func readll() int64 {
	i, err := strconv.ParseInt(reads(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// Reads next token and return it as int
func readi() int {
	return int(readll())
}

// Reads next token and return it as float64
func readf() float64 {
	f, err := strconv.ParseFloat(reads(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// Write args to OutputWriter with the format f
func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(OutputWriter, f, args...)
}

// Write args to OutputWriter without format
func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(OutputWriter, args...)
}

// Write args to stderr with the format f
func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

// Write args to stderr without format
func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

// -----------------------------------------------------------------------------

// Simple math functions

const (
	// big prime
	INF  = 1000000007
	INF2 = 1000000009
	INF3 = 998244353
)

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

func minll(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

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

func maxll(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absll(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

// egcd(a, b) returns d, x, y:
//   d is gcd(a,b)
//   x, y are  integers that satisfy ax + by = d
func egcd(a, b int) (int, int, int) {
	if b == 0 {
		return a, 1, 0
	}
	d, x, y := egcd(b, a%b)
	return d, y, x - a/b*y
}

func egcdll(a, b int64) (int64, int64, int64) {
	if b == 0 {
		return a, 1, 0
	}
	d, x, y := egcdll(b, a%b)
	return d, y, x - a/b*y
}

func gcd(a, b int) int {
	d, _, _ := egcd(a, b)
	return d
}

func gcdll(a, b int64) int64 {
	d, _, _ := egcdll(a, b)
	return d
}

// set up IO functions
func init() {
	// for non-interactive
	SetInput(os.Stdin)
	SetOutput(os.Stdout)

	// Enable below when interactive.  Its ok to leave above intact.
	// SetInteractive(os.Stdout, os.Stdin)
}

func main() {
	defer Flush()

	n := readi()
	for i := 0; i < n; i++ {
		s := readb()
		if solve(s) {
			println("Yes")
		} else {
			println("No")
		}
	}
}

func solve(s []byte) bool {
	c := make([]int, 26)
	for j := range s {
		c[int(s[j]-'a')]++
	}
	var incount, done bool
	for _, v := range c {
		if 1 < v {
			return false
		} else if done {
			if v != 0 {
				return false
			}
		} else if incount {
			if v == 0 {
				done = true
				incount = false
			}
		} else {
			if v != 0 {
				incount = true
			}
		}
	}
	return true
}

// Codeforces 1140 B Good String train done
package main

import (
	"bufio"
	"fmt"
	"strings"
	"strconv"
	"os"
)
var in *bufio.Reader

func readFive() (int,int,int,int,int) {
	var a [5]int
	s, err := in.ReadString('\n')
	if err != nil {
		fmt.Println("first read failure", err)
		panic(err)
	}
	ss := strings.Split(strings.Trim(s, " \n\r"), " ")
	for i:=0; i<len(ss); i++ {
		a[i], err = strconv.Atoi(ss[i])
		if err != nil {
			fmt.Println("n atoi failure", err)
			panic(err)
		}
	}
	return a[0],a[1],a[2],a[3],a[4]
}

func readLineNumbs(n int) []int {
	a := make([]int, n)
	delim := byte(' ')
	for i:=0; i<n; i++ {
		if i==(n-1) {
			delim = byte('\n')
		}
		s, err := in.ReadString(delim)
		s = strings.Trim(s, " \n\r")
		if err != nil {
			fmt.Println("read failure", err)
			panic(err)
		}
		aa,err := strconv.Atoi(s)
		if err != nil {
			fmt.Println("aa conv failed", err)
			panic(err)
		}
		a[i] = aa
	}
	return a
}

func readString() string {
	delim := byte('\n')
	s, err := in.ReadString(delim)
	s = strings.Trim(s, " \n\r")
	if err != nil {
		fmt.Println("read failure", err)
		panic(err)
	}
	return s
}

var n int
var s []string
var bDiv []bool

func readData() {
	in = bufio.NewReader(os.Stdin)
	n,_,_,_,_ = readFive()
	//fmt.Println("n = ", n)
	s = make([]string, n)
	bDiv = make([]bool, n)
	for i:=0; i<n; i++ {
		s[i] = readString()
	}
}

func isDiverse(b []byte) bool {
	ln := len(b)
	cnts := make([]int, 26)
	for i:=0; i<ln; i++  {
		idx := b[i] - byte('a')
		cnts[idx]++
	}
	first := 0
	for i:=0; i<26; i++  {
		if cnts[i]>0 {
			first = i
			break
		}
	}
	if first>26-ln {
		return false;
	}
	for i:=first; i<first+ln; i++ {
		if cnts[i] != 1 {
			return false;
		}
	}
	return true;
}

func solve() {
	for i:=0; i<n; i++ {
		bDiv[i] = isDiverse(([]byte)(s[i]));
	}
}

func printRes() {
	for i:=0; i<n; i++ {
		if bDiv[i] {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	}
}

func main() {
	readData()
	solve()
	printRes()
}

package main

import (
        "fmt"
)

var num int

func main() {
        fmt.Scanln(&num)
        for i := 0; i < num; i++ {
                var s string
                fmt.Scanln(&s)
                low := -1
                high := -1
                m := make(map[rune]bool)
                fail := false
                for _, j := range s {
                        if int(j) < low || low == -1 {
                                low = int(j)
                        }
                        if int(j) > high || high == -1 {
                                high = int(j)
                        }
                        if m[j] != false {
                                fail = true
                                break
                        }
                        m[j] = true
                }
                if high-low+1 != len(s) || fail {
                        fmt.Println("NO")
                } else {
                        fmt.Println("YES")
                }
        }
}

package main

import (
	"fmt"
)

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

	for i := 0; i < n; i++ {
		var s string
		fmt.Scanln(&s)

		low := -1
		high := -1

		m := make(map[rune]bool)

		fail := false
		for _, j := range s {
			if int(j) < low || low == -1 {
				low = int(j)
			}
			if int(j) > high || high == -1 {
				high = int(j)
			}

			if m[j] != false {
				fail = true
				break
			}
			m[j] = true
		}

		if high - low + 1 != len(s) || fail {
			fmt.Println("no")
		} else {
			fmt.Println("yes")
		}
	}
}

package main

import "fmt"

func main()  {
	var t int
	fmt.Scanln(&t)
	for ;t >= 1; t-- {
		var data string
		Hash := make(map[byte]byte)
		fmt.Scanln(&data)
		for i := 0 ; i < len(data) ; i ++ {
			Hash[data[i]] = Hash[data[i]] + 1
		}
		ans := true
		left := 0
		right := 0

		for i := 'a'; i <= 'z' ; i ++ {
			cnt := Hash[byte(i)]
			if cnt >= 2 {
				ans = false
				break
			}
			if cnt == 0 {
				if i > 'a' && Hash[byte(i-1)] != 0 {
					left ++

				}
				if i < 'z' && Hash[byte(i+1)] != 0 {
					right ++
					if left != 0 {
						ans = false
						break
					}
				}
			}
		}
		if left > 1 || right > 1 {
			ans = false
		}
		if ans {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	}
}

package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	for ; n > 0; n-- {
		var str, answer string
		fmt.Scan(&str)
		var c []int = make([]int, len(str))
		for i := 0; i < len(str); i++ {
			c[i] = int(str[i])
		}
		sort.Ints(c)
		for i := 1; i < len(str); i++ {
			if c[i]-c[i-1] != 1 {
				answer = "NO"
			}
		}
		if answer == "" {
			answer = "YES"
		}
		fmt.Println(answer)
	}
}

package main

import (
	"fmt"
	"sort"
)

func abs(a int) int{
	if a < 0{
		return -a
	} else{
		return a
	}
}

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

func main(){
	var n int
	fmt.Scanln(&n)
	for i := 0;i < n ;i++  {
		var s string
		fmt.Scanln(&s)
		if len(s) == 1{
			fmt.Println("YES")
			continue
		}

		target := make([]int, len(s))
		for j := 0;j < len(s) ;j++  {
			target[j] = int(s[j] - 'a')
		}
		sort.Ints(target)
		var invalid bool
		for j:=0;j <len(s)-1 ;j++  {
			if target[j +1] != target[j] + 1{
				invalid = true
				break
			}
		}
		if invalid{
			fmt.Println("NO")
		} else{
			fmt.Println("YES")
		}
	}
}

package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanf("%d\n", &n)
	for i := 0; i < n; i++ {
		var m [27]int
		var s string
		fmt.Scanf("%s\n", &s)
		for _, b := range s {
			m[int32(b)-int32('a')]++
		}
		flag := true
		for _, i := range m {
			if i > 1 {
				flag = false
				break
			}
		}
		if flag {
			j := 0
			for i := 0; i < 26; i++ {
				if m[i] == 1 && m[i+1] == 0 {
					j++
				}
			}
			if j > 1 {
				flag = false
			}
		}
		if flag {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	}
}

// Author: sighduck
// URL: https://codeforces.com/contest/1144/problem/A

package main

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

func Solve(s string) string {
	a := []byte(s)
	sort.Slice(a, func(i, j int) bool { return a[i] < a[j] })
	for i := 1; i < len(a); i++ {
		if a[i] != a[i-1]+1 {
			return "No"
		}
	}
	return "Yes"
}

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

	var n int
	fmt.Fscanf(reader, "%d\n", &n)
	for i := 0; i < n; i++ {
		var s string
		fmt.Fscanf(reader, "%s\n", &s)
		fmt.Fprintf(writer, "%s\n", Solve(s))
	}
}

package main

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

func main() {
	var n, last, flag int
	scr := bufio.NewReader(os.Stdin)
	// ocr := bufio.NewWriter(os.Stdout)

	var st string

	fmt.Fscanln(scr, &n)

	for i := 0; i < n; i++ {
		fmt.Fscanln(scr, &st)
		l := make([]int, len(st))
		for _, y := range st {
			l = append(l, int(y))
		}
		sort.Sort(sort.IntSlice(l))
		for x, y := range l {
			if x == 0 {
				last = y
			} else {
				if y != last+1 {
					flag = 2
					break
				}
				last = y
			}
		}
		if flag == 2 {
			fmt.Println("NO")
		} else {
			fmt.Println("YES")
		}
	}

}

package main

import . "fmt"

func main() {
    var N int
    Scan(&N)
    if (N%10 + N/10)%5 == 0 {
        Println("YES\n")
    } else {
        Println("NO\n")
    }
}

package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)
	for i := 0; i < n; i++ {
		var m [27]int
		var s string
		fmt.Scanf("%s", &s)
		for _, b := range []byte(s) {
			m[b-byte('a')]++
		}
		flag := true

		for _, i := range m {
			if i > 1 {
				flag = false
				break
			}
		}
		if flag {
			j := 0
			for i := 0; i < 26; i++ {
				if m[i] == 1 && m[i+1] == 0 {
					j++
				}
			}
			if j > 1 {
				flag = false
			}
		}
		if flag {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	}
}

package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)
	for i := 0; i < n; i++ {
		var m [27]int
		var s string
		fmt.Scanf("%s", &s)
		for _, b := range s {
			m[int32(b)-int32('a')]++
		}
		flag := true

		for _, i := range m {
			if i > 1 {
				flag = false
				break
			}
		}
		if flag {
			j := 0
			for i := 0; i < 26; i++ {
				if m[i] == 1 && m[i+1] == 0 {
					j++
				}
			}
			if j > 1 {
				flag = false
			}
		}
		if flag {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	}
}

package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanf("%d\n", &n)
	for i := 0; i < n; i++ {
		var m [27]int
		var s string
		fmt.Scanf("%s\n", &s)
		for _, b := range s {
			m[int32(b)-int32('a')]++
		}
		flag := true
        fmt.Println(s)
		for _, i := range m {
			if i > 1 {
				flag = false
				break
			}
		}
		if flag {
			j := 0
			for i := 0; i < 26; i++ {
				if m[i] == 1 && m[i+1] == 0 {
					j++
				}
			}
			if j > 1 {
				flag = false
			}
		}
		if flag {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	}
}


An identity permutation of length $$$n$$$ is an array $$$[1, 2, 3, \dots, n]$$$.We performed the following operations to an identity permutation of length $$$n$$$:  firstly, we cyclically shifted it to the right by $$$k$$$ positions, where $$$k$$$ is unknown to you (the only thing you know is that $$$0 \le k \le n - 1$$$). When an array is cyclically shifted to the right by $$$k$$$ positions, the resulting array is formed by taking $$$k$$$ last elements of the original array (without changing their relative order), and then appending $$$n - k$$$ first elements to the right of them (without changing relative order of the first $$$n - k$$$ elements as well). For example, if we cyclically shift the identity permutation of length $$$6$$$ by $$$2$$$ positions, we get the array $$$[5, 6, 1, 2, 3, 4]$$$;  secondly, we performed the following operation at most $$$m$$$ times: pick any two elements of the array and swap them. You are given the values of $$$n$$$ and $$$m$$$, and the resulting array. Your task is to find all possible values of $$$k$$$ in the cyclic shift operation.

The first line contains one integer $$$t$$$ ($$$1 \le t \le 10^5$$$) — the number of test cases. Each test case consists of two lines. The first line contains two integers $$$n$$$ and $$$m$$$ ($$$3 \le n \le 3 \cdot 10^5$$$; $$$0 \le m \le \frac{n}{3}$$$). The second line contains $$$n$$$ integers $$$p_1, p_2, \dots, p_n$$$ ($$$1 \le p_i \le n$$$, each integer from $$$1$$$ to $$$n$$$ appears in this sequence exactly once) — the resulting array. The sum of $$$n$$$ over all test cases does not exceed $$$3 \cdot 10^5$$$.

For each test case, print the answer in the following way:   firstly, print one integer $$$r$$$ ($$$0 \le r \le n$$$) — the number of possible values of $$$k$$$ for the cyclic shift operation;  secondly, print $$$r$$$ integers $$$k_1, k_2, \dots, k_r$$$ ($$$0 \le k_i \le n - 1$$$) — all possible values of $$$k$$$ in increasing order.

NoteConsider the example:   in the first test case, the only possible value for the cyclic shift is $$$3$$$. If we shift $$$[1, 2, 3, 4]$$$ by $$$3$$$ positions, we get $$$[2, 3, 4, 1]$$$. Then we can swap the $$$3$$$-rd and the $$$4$$$-th elements to get the array $$$[2, 3, 1, 4]$$$;  in the second test case, the only possible value for the cyclic shift is $$$0$$$. If we shift $$$[1, 2, 3]$$$ by $$$0$$$ positions, we get $$$[1, 2, 3]$$$. Then we don't change the array at all (we stated that we made at most $$$1$$$ swap), so the resulting array stays $$$[1, 2, 3]$$$;  in the third test case, all values from $$$0$$$ to $$$2$$$ are possible for the cyclic shift:   if we shift $$$[1, 2, 3]$$$ by $$$0$$$ positions, we get $$$[1, 2, 3]$$$. Then we can swap the $$$1$$$-st and the $$$3$$$-rd elements to get $$$[3, 2, 1]$$$;  if we shift $$$[1, 2, 3]$$$ by $$$1$$$ position, we get $$$[3, 1, 2]$$$. Then we can swap the $$$2$$$-nd and the $$$3$$$-rd elements to get $$$[3, 2, 1]$$$;  if we shift $$$[1, 2, 3]$$$ by $$$2$$$ positions, we get $$$[2, 3, 1]$$$. Then we can swap the $$$1$$$-st and the $$$2$$$-nd elements to get $$$[3, 2, 1]$$$;   in the fourth test case, we stated that we didn't do any swaps after the cyclic shift, but no value of cyclic shift could produce the array $$$[1, 2, 3, 4, 6, 5]$$$.

package main

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

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

func Read() int {
	in.Scan()
	r := 0
	for _, v := range in.Bytes() {
		r = r*10 + int(v-'0')
	}
	return r
}

func init() {
	const MaxInt = int(^uint(0) >> 1)
	in.Buffer(make([]byte, 1<<12), MaxInt)
	in.Split(bufio.ScanWords)
}

const N = 300300

var a, cnt [N]int
var b [N]bool

func check(k, m, n int) bool {
	c := 0
	for i := 0; i < n; i++ {
		b[i] = false
	}
	for i := 0; i < n; i++ {
		if a[i] != k && b[i] == false {
			nxt := func(p int) int {
				return (p + a[p] - k + n) % n
			}
			b[i] = true
			for p := nxt(i); p != i; p = nxt(p) {
				b[p] = true
				c++
			}
		}
	}
	return c <= m
}

func main() {
	defer out.Flush()
	for t := Read(); t > 0; t-- {
		n := Read()
		m := Read()
		for i := 0; i < n; i++ {
			cnt[i] = 0
		}
		for i := 0; i < n; i++ {
			a[i] = (Read() - i - 1 + n) % n
			cnt[a[i]]++
		}
		k := 0
		var c []int
		for i := n; i > 0; i-- {
			if cnt[i%n] >= n/3 && check(i%n, m, n) {
				k++
				c = append(c, (n-i)%n)
			}
		}
		Fprint(out, k)
		for _, v := range c {
			Fprint(out, " ", v)
		}
		Fprintln(out)
	}
}

package main

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

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

func Read() int {
	in.Scan()
	s := in.Text()
	r := 0
	for _, v := range s {
		r = r*10 + int(v-'0')
	}
	return r
}

func init() {
	const MaxInt = int(^uint(0) >> 1)
	in.Buffer(make([]byte, 1<<12), MaxInt)
	in.Split(bufio.ScanWords)
}

func check(k, m, n int, a []int) bool {
	c := 0
	b := make([]bool, n)
	for i := 0; i < n; i++ {
		if a[i] != k && !b[i] {
			nxt := func(p int) int {
				return (p + a[p] - k + n) % n
			}
			b[i] = true
			for p := nxt(i); p != i; p = nxt(p) {
				b[p] = true
				c++
			}
		}
	}
	return c <= m
}

func main() {
	defer out.Flush()
	for t := Read(); t > 0; t-- {
		n := Read()
		m := Read()
		a := make([]int, n)
		cnt := make([]int, n)
		for i := 0; i < n; i++ {
			a[i] = (Read() - i - 1 + n) % n
			cnt[a[i]]++
		}
		k := 0
		var c []int
		for i := n; i > 0; i-- {
			if cnt[i%n] >= n/3 && check(i%n, m, n, a) {
				c = append(c, (n-i)%n)
				k++
			}
		}
		Fprint(out, k)
		for _, v := range c {
			Fprint(out, " ", v)
		}
		Fprintln(out)
	}
}

package main

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

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

func Read() int {
	in.Scan()
	s := in.Text()
	r := 0
	for _, v := range s {
		r = r*10 + int(v-'0')
	}
	return r
}

func init() {
	const MaxInt = int(^uint(0) >> 1)
	in.Buffer(make([]byte, 1<<16), MaxInt)
	in.Split(bufio.ScanWords)
}

const N = 300300

var a, c, cnt [N]int
var b [N]bool

func check(k, m, n int) bool {
	c := 0
	for i := 0; i < n; i++ {
		b[i] = false
	}
	for i := 0; i < n; i++ {
		if a[i] != k && !b[i] {
			nxt := func(p int) int {
				return (p + a[p] - k + n) % n
			}
			b[i] = true
			for p := nxt(i); p != i; p = nxt(p) {
				b[p] = true
				c++
			}
		}
	}
	return c <= m
}

func main() {
	defer out.Flush()
	for t := Read(); t > 0; t-- {
		n := Read()
		m := Read()
		for i := 0; i < n; i++ {
			cnt[i] = 0
		}
		for i := 0; i < n; i++ {
			a[i] = (Read() - i - 1 + n) % n
			cnt[a[i]]++
		}
		k := 0
		for i := n; i > 0; i-- {
			if cnt[i%n] >= n/3 && check(i%n, m, n) {
				c[k] = (n-i)%n
				k++
			}
		}
		Fprint(out, k)
		for _, v := range c[:k] {
			Fprint(out, " ", v)
		}
		Fprintln(out)
	}
}

package main

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

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

func Read() int {
	in.Scan()
	s := in.Text()
	r := 0
	for _, v := range s {
		r = r*10 + int(v-'0')
	}
	return r
}

func init() {
	const MaxInt = int(^uint(0) >> 1)
	in.Buffer(make([]byte, 1<<12), MaxInt)
	in.Split(bufio.ScanWords)
}

const N = 300300

var a, cnt [N]int
var b [N]bool

func check(k, m, n int) bool {
	c := 0
	for i := 0; i < n; i++ {
		b[i] = false
	}
	for i := 0; i < n; i++ {
		if a[i] != k && b[i] == false {
			nxt := func(p int) int {
				return (p + a[p] - k + n) % n
			}
			b[i] = true
			for p := nxt(i); p != i; p = nxt(p) {
				b[p] = true
				c++
			}
		}
	}
	return c <= m
}

func main() {
	defer out.Flush()
	for t := Read(); t > 0; t-- {
		n := Read()
		m := Read()
		for i := 0; i < n; i++ {
			cnt[i] = 0
		}
		for i := 0; i < n; i++ {
			a[i] = (Read() - i - 1 + n) % n
			cnt[a[i]]++
		}
		k := 0
		var c []int
		for i := n; i > 0; i-- {
			if cnt[i%n] >= n/3 && check(i%n, m, n) {
				k++
				c = append(c, (n-i)%n)
			}
		}
		Fprint(out, k)
		for _, v := range c {
			Fprint(out, " ", v)
		}
		Fprintln(out)
	}
}

package main

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

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

func Read() int {
	in.Scan()
	s := in.Text()
	r := 0
	for _, v := range s {
		r = r*10 + int(v-'0')
	}
	return r
}

func init() {
	const MaxInt = int(^uint(0) >> 1)
	in.Buffer(make([]byte, 1<<12), MaxInt)
	in.Split(bufio.ScanWords)
}

const N = 300300

var a, cnt [N]int

func check(k, m, n int) bool {
	c := 0
	var b [N]bool
	for i := 0; i < n; i++ {
		if a[i] != k && b[i] == false {
			nxt := func(p int) int {
				return (p + a[p] - k + n) % n
			}
			b[i] = true
			for p := nxt(i); p != i; p = nxt(p) {
				b[p] = true
				c++
			}
		}
	}
	return c <= m
}

func main() {
	defer out.Flush()
	for t := Read(); t > 0; t-- {
		n := Read()
		m := Read()
		for i := 0; i < n; i++ {
			cnt[i] = 0
		}
		for i := 0; i < n; i++ {
			a[i] = (Read() - i - 1 + n) % n
			cnt[a[i]]++
		}
		k := 0
		var c []int
		for i := n; i > 0; i-- {
			if cnt[i%n] >= n/3 && check(i%n, m, n) {
				k++
				c = append(c, (n-i)%n)
			}
		}
		Fprint(out, k)
		for _, v := range c {
			Fprint(out, " ", v)
		}
		Fprintln(out)
	}
}

package main

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

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

func Read() int {
	in.Scan()
	s := in.Text()
	r := 0
	for _, v := range s {
		r = r*10 + int(v-'0')
	}
	return r
}

func init() {
	const MaxInt = int(^uint(0) >> 1)
	in.Buffer(make([]byte, 1<<16), MaxInt)
	in.Split(bufio.ScanWords)
}

const N = 300300

var a, cnt [N]int

func check(k, m, n int) bool {
	c := 0
	var b [N]bool
	for i := 0; i < n; i++ {
		if a[i] != k && b[i] == false {
			nxt := func(p int) int {
				return (p + a[p] - k + n) % n
			}
			b[i] = true
			for p := nxt(i); p != i; p = nxt(p) {
				b[p] = true
				c++
			}
		}
	}
	return c <= m
}

func main() {
	defer out.Flush()
	for t := Read(); t > 0; t-- {
		n := Read()
		m := Read()
		for i := 0; i < n; i++ {
			cnt[i] = 0
		}
		for i := 0; i < n; i++ {
			a[i] = (Read() - i - 1 + n) % n
			cnt[a[i]]++
		}
		k := 0
		var c []int
		for i := n; i > 0; i-- {
			if cnt[i%n] >= n/3 && check(i%n, m, n) {
				k++
				c = append(c, (n-i)%n)
			}
		}
		Fprint(out, k)
		for _, v := range c {
			Fprint(out, " ", v)
		}
		Fprintln(out)
	}
}

package main

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

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

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

func printf(f string, a ...interface{}) {
	fmt.Fprintf(writer, f, a...)
}

func _int() int {
	s := _string()
	i := 0
	if s[0] == '-' {
		for _, r := range s[1:] {
			i *= 10
			i -= int(r - '0')
		}
		return i
	}
	for _, r := range s {
		i *= 10
		i += int(r - '0')
	}
	return i
}

func _int64() int64 {
	s := _string()
	i := int64(0)
	if s[0] == '-' {
		for _, r := range s[1:] {
			i *= 10
			i -= int64(r - '0')
		}
		return i
	}
	for _, r := range s {
		i *= 10
		i += int64(r - '0')
	}
	return i
}

func _string() string {
	if !scanner.Scan() {
		panic(scanner.Err())
	}
	return scanner.Text()
}

func main() {
	defer writer.Flush()
	for t := _int(); t > 0; t-- {
		n := _int()
		m := _int()
		p := make([]int, n)
		for i := range p {
			p[i] = _int() - 1
		}
		res := sol(n, m, p)
		printf("%d ", len(res))
		for _, d := range res {
			printf("%d ", d)
		}
		printf("\n")
	}
}

func sol(n, m int, p []int) []int {
	kcount := map[int]int{} // k: count
	for i := range p {
		k := (i - p[i] + n) % n
		kcount[k]++
	}
	rev := make([]int, n) // val: idx
	for i := range p {
		rev[p[i]] = i
	}
	ret := []int{}
	seenk := map[int]bool{}
	for i := range p {
		k := (i - p[i] + n) % n
		if seenk[k] {
			continue
		}
		seenk[k] = true
		if kcount[k] < n-m*2 {
			continue
		}
		if swaps(n, p, rev, k) <= m {
			ret = append(ret, k)
		}
	}
	sort.Ints(ret)
	return ret
}

func swaps(n int, p, rev []int, k int) int {
	seen := make([]bool, n)
	ret := 0
	var dfs func(int) int
	dfs = func(i int) int {
		if seen[i] {
			return 0
		}
		seen[i] = true
		next := (i - k + n) % n
		// printf("k=%d i=%d revnext=%d\n", k, i, rev[next])
		return 1 + dfs(rev[next])
	}
	for i := range p {
		cycle := dfs(i)
		if cycle > 0 {
			ret += cycle - 1
		}
	}
	return ret
}


Dark is going to attend Motarack's birthday. Dark decided that the gift he is going to give to Motarack is an array $$$a$$$ of $$$n$$$ non-negative integers.Dark created that array $$$1000$$$ years ago, so some elements in that array disappeared. Dark knows that Motarack hates to see an array that has two adjacent elements with a high absolute difference between them. He doesn't have much time so he wants to choose an integer $$$k$$$ ($$$0 \leq k \leq 10^{9}$$$) and replaces all missing elements in the array $$$a$$$ with $$$k$$$.Let $$$m$$$ be the maximum absolute difference between all adjacent elements (i.e. the maximum value of $$$|a_i - a_{i+1}|$$$ for all $$$1 \leq i \leq n - 1$$$) in the array $$$a$$$ after Dark replaces all missing elements with $$$k$$$.Dark should choose an integer $$$k$$$ so that $$$m$$$ is minimized. Can you help him?

The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$)  — the number of test cases. The description of the test cases follows. The first line of each test case contains one integer $$$n$$$ ($$$2 \leq n \leq 10^{5}$$$) — the size of the array $$$a$$$. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$-1 \leq a_i \leq 10 ^ {9}$$$). If $$$a_i = -1$$$, then the $$$i$$$-th integer is missing. It is guaranteed that at least one integer is missing in every test case. It is guaranteed, that the sum of $$$n$$$ for all test cases does not exceed $$$4 \cdot 10 ^ {5}$$$.

Print the answers for each test case in the following format: You should print two integers, the minimum possible value of $$$m$$$ and an integer $$$k$$$ ($$$0 \leq k \leq 10^{9}$$$) that makes the maximum absolute difference between adjacent elements in the array $$$a$$$ equal to $$$m$$$. Make sure that after replacing all the missing elements with $$$k$$$, the maximum absolute difference between adjacent elements becomes $$$m$$$. If there is more than one possible $$$k$$$, you can print any of them.

NoteIn the first test case after replacing all missing elements with $$$11$$$ the array becomes $$$[11, 10, 11, 12, 11]$$$. The absolute difference between any adjacent elements is $$$1$$$. It is impossible to choose a value of $$$k$$$, such that the absolute difference between any adjacent element will be $$$\leq 0$$$. So, the answer is $$$1$$$.In the third test case after replacing all missing elements with $$$6$$$ the array becomes $$$[6, 6, 9, 6, 3, 6]$$$.  $$$|a_1 - a_2| = |6 - 6| = 0$$$;  $$$|a_2 - a_3| = |6 - 9| = 3$$$;  $$$|a_3 - a_4| = |9 - 6| = 3$$$;  $$$|a_4 - a_5| = |6 - 3| = 3$$$;  $$$|a_5 - a_6| = |3 - 6| = 3$$$. So, the maximum difference between any adjacent elements is $$$3$$$.

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	t := int64(1)
	fmt.Fscanf(in, "%d\n", &t)
	for tt := int64(0); tt < t; tt++ {
		n := 0
		fmt.Fscanf(in, "%d\n", &n)
		a := make([]int64, n)
		for i := 0; i < n; i++ {
			fmt.Fscanf(in, "%d", &a[i])
		}

		fmt.Fscanf(in, "\n")
		min := int64(-1)
		max := int64(-1)
		for i := 0; i < n; i++ {
			ok := false
			if i > 0 && a[i] != -1 && a[i-1] == -1 {
				ok = true
			}
			if i < n-1 && a[i] != -1 && a[i+1] == -1 {
				ok = true
			}
			if ok {
				if min == -1 || a[i] < min {
					min = a[i]
				}
				if max == -1 || a[i] > max {
					max = a[i]
				}
			}
		}
		chosen := int64(1)
		if min == -1 {
			chosen = 1
		} else {
			chosen = (min + max) / 2
		}
		ans := int64(0)
		for i := 1; i < n; i++ {
			p1 := a[i-1]
			if p1 == -1 {
				p1 = chosen
			}
			p2 := a[i]
			if p2 == -1 {
				p2 = chosen
			}
			if abs(p1-p2) > ans {
				ans = abs(p1 - p2)
			}
		}
		fmt.Fprintf(out, "%d %d\n", ans, chosen)
	}
	return
}

func abs(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

package main

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

var reader io.Reader
var scanner *bufio.Scanner

func Init(io io.Reader, max_token_size int) {
	reader = bufio.NewReader(io)
	scanner = bufio.NewScanner(reader)
	// max token size
	scanner.Split(bufio.ScanWords)
	scanner.Buffer([]byte{}, max_token_size)
}

func die(v ...interface{}) {
	fmt.Fprintln(os.Stderr, v...)
	os.Exit(1)
}

func NextInt() int {
	bytes := NextBytes()
	i, err := Atoi(bytes)
	if err != nil {
		die(err)
	}
	return i
}

func NextBytes() []byte {
	if !scanner.Scan() {
		die(scanner.Err())
	}
	return scanner.Bytes()
}

func Atoi(b []byte) (int, error) {
	neg := false
	if b[0] == '+' {
		b = b[1:]
	} else if b[0] == '-' {
		neg = true
		b = b[1:]
	}
	n := 0
	for _, v := range b {
		if v < '0' || v > '9' {
			return 0, strconv.ErrSyntax
		}
		n = n*10 + int(v-'0')
	}
	if neg {
		return -n, nil
	}
	return n, nil
}

func ExtendByteArray(a []byte, size int) []byte {
	if size <= len(a) {
		return a
	} else {
		return append(a, make([]byte, size-len(a))...)
	}
}

func ExtendIntArray(a []int, size int) []int {
	if size <= len(a) {
		return a
	} else {
		return append(a, make([]int, size-len(a))...)
	}
}

func main() {
	f := os.Stdin
	out := os.Stdout
	// f, err := os.Open("a.in")
	// if err != nil {
	// 	die(err)
	// }
	// out, err := os.Create("a.out")
	// if err != nil {
	// 	die(err)
	// }
	// defer out.Close()
	Init(f, 1000010)

	T := NextInt()

	var ai, n, maxValue, minValue, center, existingMaxDiff int
	for t := 0; t < T; t++ {
		n = NextInt()
		maxValue, minValue = -1, -1
		existingMaxDiff = -1
		for i, prev, last := 0, -2, -1; i < n; i++ {
			ai = NextInt()
			if ai == -1 {
				if last >= 0 && (minValue == -1 || minValue > last) {
					minValue = last
				}
				if last >= 0 && (maxValue == -1 || maxValue < last) {
					maxValue = last
				}
			} else {
				if prev >= 0 {
					t := (prev - ai)
					if t < 0 {
						t = -t
					}
					if t > existingMaxDiff {
						existingMaxDiff = t
					}
				} else if prev == -1 {
					if minValue == -1 || minValue > ai {
						minValue = ai
					}
					if maxValue == -1 || maxValue < ai {
						maxValue = ai
					}
				}
				last = ai
			}
			prev = ai
		}
		if minValue == -1 {
			if existingMaxDiff == -1 {
				existingMaxDiff = 0
			}
			center = 0
		} else {
			// fmt.Fprintln(os.Stderr, "tt", minValue, maxValue, existingMaxDiff)
			center = (maxValue + minValue) / 2
			if center-minValue > existingMaxDiff {
				existingMaxDiff = center - minValue
			}

			if maxValue-center > existingMaxDiff {
				existingMaxDiff = maxValue - center
			}
		}
		fmt.Fprintln(out, existingMaxDiff, center)
	}

}

package main

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

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

func scanString() string { sc.Scan(); return sc.Text() }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

func scanInts(n int) []int {
	res := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }; return res
}

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1000000)

	tests := scanInt()
	for t := 0; t < tests; t++ {
		n := scanInt()
		a := scanInts(n)

		ma := -1
		mi := 1000000001
		for i := 0; i < n; i++ {
			if a[i] == -1 {
				if i > 0 && a[i-1] != -1 {
					ma = max(ma, a[i-1])
					mi = min(mi, a[i-1])
				}
				if i < n-1 && a[i+1] != -1 {
					ma = max(ma, a[i+1])
					mi = min(mi, a[i+1])
				}
			}
		}
		// fmt.Println(ma,mi)
		k := (ma+mi)/2
		m := 0
		for i := 0; i < n-1; i++ {
			if a[i] == -1 {
				a[i] = k
			}
			if a[i+1] == -1 {
				a[i+1] = k
			}
			// fmt.Println(a[i],a[i+1])

			m = max(m, abs(a[i]-a[i+1]))
		}
		fmt.Println(m,k)
	}
}

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 min(a, b int) int {
	if a < b {
		return a
	} else {
		return b
	}
}

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

func abs(a int) int {
	if a < 0 {
		return -a
	} else {
		return a
	}
}

func f(arr []int, mid int) int {
	ret := 0
	for i := 0; i < len(arr)-1; i++ {
		t1 := arr[i]
		t2 := arr[i+1]
		if t1 == -1 {
			t1 = mid
		}
		if t2 == -1 {
			t2 = mid
		}
		ret = max(ret, abs(t2-t1))
	}
	return ret
}

func main() {
	defer writer.Flush()

	var t, n int

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

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

		lo, hi := int64(0), int64(1000000000)

		m, k := 1000000001, 0

		for lo <= hi {
			// fmt.Println(lo, hi)
			lt := int(lo + (hi-lo) / 3)
			rt := int(hi - (hi-lo) / 3)

			l := f(arr, lt)
			r := f(arr, rt)

			// fmt.Println(lo, hi, lt, rt, l, r)

			if l <= r {
				hi = int64(rt - 1)
				if l < m {
					m = l
					k = lt
				}
			} else {
				lo = int64(lt + 1)
				if r < m {
					m = r
					k = rt
				}
			}
		}
		// fmt.Println(m, k)
		printf("%d %d\n", m, k)

	}

}

package main

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

var (
	a [100005] int
	n int
)

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

func abs(x int) int  {
	if x >= 0 {
		return x
	}
	return x * -1
}

func getans(k int) int  {
	ans := 0
	for i := 1; i < n; i++ {
		if a[i-1] >= 0 && a[i] >= 0 {
			ans = max(ans, abs(a[i] - a[i-1]))
		} else if a[i-1] >= 0 {
			ans = max(ans, abs(k - a[i-1]))
		} else if a[i] >= 0 {
			ans = max(ans, abs(a[i] - k))
		}
	}
	return ans
}

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-- {
		fmt.Fscan(in, &n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &a[i])
		}
		left := 0
		right := 1000000000
		for ; left < right; {
			mid := (left + right) >> 1
			ans := getans(mid)
			ans2 := getans(mid + 1)
			if ans2 <= ans {
				left = mid + 1
			} else {
				right = mid
			}
		}
		fmt.Fprintf(out, "%d %d\n", getans(left), left)
	}
}

package main

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

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

	ternarySearchInt := func(l, r int, f func(x int) int) int {
		for l+3 <= r {
			m1 := l + (r-l)/3
			m2 := r - (r-l)/3
			v1, v2 := f(m1), f(m2)
			if v1 < v2 {
				r = m2
			} else {
				l = m1
			}
		}
		min, minI := f(l), l
		for i := l + 1; i <= r; i++ {
			if v := f(i); v < min {
				min, minI = v, i
			}
		}
		return minI
	}
	abs := func(x int) int {
		if x < 0 {
			return -x
		}
		return x
	}
	max := func(a, b int) int {
		if a > b {
			return a
		}
		return b
	}

	solve := func() {
		var n int
		Fscan(in, &n)
		a := make([]int, n)
		for i := range a {
			Fscan(in, &a[i])
		}

		f := func(x int) int {
			maxDiff := 0
			b := make([]int, n)
			copy(b,a)
			for i, v := range b {
				if v == -1 {
					b[i] = x
				}
			}
			for i := 0; i < n-1; i++ {
				maxDiff = max(maxDiff, abs(b[i]-b[i+1]))
			}
			return maxDiff
		}
		k := ternarySearchInt(0, 1e9, f)
		m := f(k)

		Fprintln(out, m,k)
	}

	var t int
	Fscan(in, &t)
	for _case := 1; _case <= t; _case++ {
		solve()
	}
}

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

package main

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

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

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

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	var t int
	var n int
	fmt.Fscan(in, &t)
	for t > 0 {
		fmt.Fscan(in, &n)
		arr := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &arr[i])
		}

		var k, m int
		lo, hi := math.MaxInt32, math.MinInt32
		for i := 0; i < n; i++ {
			if arr[i] != -1 {
				if i > 0 && arr[i-1] == -1 {
					lo = min(lo, arr[i])
					hi = max(hi, arr[i])
				} else if i < n-1 && arr[i+1] == -1 {
					lo = min(lo, arr[i])
					hi = max(hi, arr[i])
				}

				if i > 0 && arr[i-1] != -1 {
					m = max(m, abs(arr[i]-arr[i-1]))
				}
			}
		}
		if lo <= hi {
			k = (lo + hi) / 2
			m = max(m, max(k-lo, hi-k))
		}
		fmt.Fprintln(out, m, k)
		t--
	}
	out.Flush()
}

package main

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

var reader io.Reader
var scanner *bufio.Scanner

func Init(io io.Reader, max_token_size int) {
	reader = bufio.NewReader(io)
	scanner = bufio.NewScanner(reader)
	// max token size
	scanner.Split(bufio.ScanWords)
	scanner.Buffer([]byte{}, max_token_size)
}

func die(v ...interface{}) {
	fmt.Fprintln(os.Stderr, v...)
	os.Exit(1)
}

func NextInt() int {
	bytes := NextBytes()
	i, err := Atoi(bytes)
	if err != nil {
		die(err)
	}
	return i
}

func NextBytes() []byte {
	if !scanner.Scan() {
		die(scanner.Err())
	}
	return scanner.Bytes()
}

func Atoi(b []byte) (int, error) {
	neg := false
	if b[0] == '+' {
		b = b[1:]
	} else if b[0] == '-' {
		neg = true
		b = b[1:]
	}
	n := 0
	for _, v := range b {
		if v < '0' || v > '9' {
			return 0, strconv.ErrSyntax
		}
		n = n*10 + int(v-'0')
	}
	if neg {
		return -n, nil
	}
	return n, nil
}

func ExtendByteArray(a []byte, size int) []byte {
	if size <= len(a) {
		return a
	} else {
		return append(a, make([]byte, size-len(a))...)
	}
}

func ExtendIntArray(a []int, size int) []int {
	if size <= len(a) {
		return a
	} else {
		return append(a, make([]int, size-len(a))...)
	}
}

func main() {
	f := os.Stdin
	out := os.Stdout
	// f, err := os.Open("a.in")
	// if err != nil {
	// 	die(err)
	// }
	// out, err := os.Create("a.out")
	// if err != nil {
	// 	die(err)
	// }
	// defer out.Close()
	Init(f, 1000010)

	T := NextInt()

	var ai, n, maxValue, minValue, center, existingMaxDiff int
	for t := 0; t < T; t++ {
		n = NextInt()
		maxValue, minValue = -1, -1
		existingMaxDiff = -1
		for i, prev, last := 0, -1, -1; i < n; i++ {
			ai = NextInt()
			if ai == -1 {
				if last >= 0 && (minValue == -1 || minValue > last) {
					minValue = last
				}
				if last >= 0 && (maxValue == -1 || maxValue < last) {
					maxValue = last
				}
			} else {
				if prev >= 0 {
					t := (prev - ai)
					if t < 0 {
						t = -t
					}
					if t > existingMaxDiff {
						existingMaxDiff = t
					}
				} else {
					if minValue == -1 || minValue > ai {
						minValue = ai
					}
					if maxValue == -1 || maxValue < ai {
						maxValue = ai
					}
				}
				last = ai
			}
			prev = ai
		}
		if minValue == -1 {
			if existingMaxDiff == -1 {
				existingMaxDiff = 0
			}
			center = 0
		} else {
			// fmt.Fprintln(os.Stderr, "tt", minValue, maxValue, existingMaxDiff)
			center = (maxValue + minValue) / 2
			if center-minValue > existingMaxDiff {
				existingMaxDiff = center - minValue
			}

			if maxValue-center > existingMaxDiff {
				existingMaxDiff = maxValue - center
			}
		}
		fmt.Fprintln(out, existingMaxDiff, center)
	}

}

package main

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

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

func scanString() string { sc.Scan(); return sc.Text() }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

func scanInts(n int) []int {
	res := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }; return res
}

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1000000)

	tests := scanInt()
	for t := 0; t < tests; t++ {
		n := scanInt()
		a := scanInts(n)

		l,r := -1, 1000000001
		for r-l > 2 {
			t1 := (l*2+r)/3
			t2 := (l+r*2+2)/3

			m1 := 0
			m2 := 0

			for i := 0; i < n-1; i++ {
				l1,l2 := a[i],a[i+1]
				r1,r2 := a[i],a[i+1]
				if l1 == -1 {l1 = t1}
				if l2 == -1 {l2 = t1}
				if r1 == -1 {r1 = t2}
				if r2 == -1 {r2 = t2}

				m1 = max(m1, abs(l1-l2))
				m2 = max(m2, abs(r1-r2))
			}

			if m1 > m2 {
				l = t1
			} else {
				r = t2
			}
		}

		k := (l+r)/2
		m := 0
		for i := 0; i < n-1; i++ {
			if a[i] == -1 {
				a[i] = k
			}
			if a[i+1] == -1 {
				a[i+1] = k
			}
			// fmt.Println(a[i],a[i+1])

			m = max(m, abs(a[i]-a[i+1]))
		}

		fmt.Println(m,k)
	}
}

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 min(a, b int) int {
	if a < b {
		return a
	} else {
		return b
	}
}

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

func abs(a int) int {
	if a < 0 {
		return -a
	} else {
		return a
	}
}

func f(arr []int, mid int) int {
	ret := 0
	for i := 0; i < len(arr)-1; i++ {
		t1 := arr[i]
		t2 := arr[i+1]
		if t1 == -1 {
			t1 = mid
		}
		if t2 == -1 {
			t2 = mid
		}
		ret = max(ret, abs(t2-t1))
	}
	return ret
}

func main() {
	defer writer.Flush()

	var t, n int

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

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

		lo, hi := int64(0), int64(1000000001)

		m, k := 1000000001, 0

		for lo <= hi {
			// fmt.Println(lo, hi)
			lt := int((2*lo + hi) / 3)
			rt := int((lo + 2*hi) / 3)

			l := f(arr, lt)
			r := f(arr, rt)

			// fmt.Println(lo, hi, lt, rt, l, r)

			if l <= r {
				hi = int64(rt - 1)
				if l < m {
					m = l
					k = lt
				}
			} else {
				lo = int64(lt + 1)
				if r < m {
					m = r
					k = rt
				}
			}
		}
		// fmt.Println(m, k)
		printf("%d %d\n", m, k)

	}

}

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 min(a, b int) int {
	if a < b {
		return a
	} else {
		return b
	}
}

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

func abs(a int) int {
	if a < 0 {
		return -a
	} else {
		return a
	}
}

func f(arr []int, mid int) int {
	ret := 0
	for i := 0; i < len(arr)-1; i++ {
		t1 := arr[i]
		t2 := arr[i+1]
		if t1 == -1 {
			t1 = mid
		}
		if t2 == -1 {
			t2 = mid
		}
		ret = max(ret, abs(t2-t1))
	}
	return ret
}

func main() {
	defer writer.Flush()

	var t, n int

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

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

		lo, hi := int64(0), int64(1000000000)

		m, k := 1000000001, 0

		for lo <= hi {
			// fmt.Println(lo, hi)
			lt := int((2*lo + hi) / 3)
			rt := int((lo + 2*hi) / 3)

			l := f(arr, lt)
			r := f(arr, rt)

			// fmt.Println(lo, hi, lt, rt, l, r)

			if l <= r {
				hi = int64(rt - 1)
				if l < m {
					m = l
					k = lt
				}
			} else {
				lo = int64(lt + 1)
				if r < m {
					m = r
					k = rt
				}
			}
		}
		// fmt.Println(m, k)
		printf("%d %d\n", m, k)

	}

}

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 min(a, b int) int {
	if a < b {
		return a
	} else {
		return b
	}
}

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

func abs(a int) int {
	if a < 0 {
		return -a
	} else {
		return a
	}
}

func f(arr []int, mid int) int {
	ret := 0
	for i := 0; i < len(arr)-1; i++ {
		t1 := arr[i]
		t2 := arr[i+1]
		if t1 == -1 {
			t1 = mid
		}
		if t2 == -1 {
			t2 = mid
		}
		ret = max(ret, abs(t2-t1))
	}
	return ret
}

func main() {
	defer writer.Flush()

	var t, n int

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

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

		lo, hi := 0, 1000000001

		m, k := 1000000001, 0

		for lo <= hi {
			// fmt.Println(lo, hi)
			lt := int((2*lo + hi) / 3)
			rt := int((lo + 2*hi) / 3)

			l := f(arr, lt)
			r := f(arr, rt)

			// fmt.Println(lo, hi, lt, rt, l, r)

			if l <= r {
				hi = rt - 1
				if l < m {
					m = l
					k = lt
				}
			} else {
				lo = lt + 1
				if r < m {
					m = r
					k = rt
				}
			}
		}
		// fmt.Println(m, k)
		printf("%d %d\n", m, k)

	}

}

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 min(a, b int) int {
	if a < b {
		return a
	} else {
		return b
	}
}

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

func abs(a int) int {
	if a < 0 {
		return -a
	} else {
		return a
	}
}

func f(arr []int, mid int) int {
	ret := 0
	for i := 0; i < len(arr)-1; i++ {
		t1 := arr[i]
		t2 := arr[i+1]
		if t1 == -1 {
			t1 = mid
		}
		if t2 == -1 {
			t2 = mid
		}
		ret = max(ret, abs(t2-t1))
	}
	return ret
}

func main() {
	defer writer.Flush()

	var t, n int

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

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

		lo, hi := 0, 1000000001

		m, k := 1000000001, 0

		for lo <= hi {
			// fmt.Println(lo, hi)
			lt := (2*lo + hi) / 3
			rt := (lo + 2*hi) / 3

			l := f(arr, lt)
			r := f(arr, rt)

			// fmt.Println(lo, hi, lt, rt, l, r)

			if l <= r {
				hi = rt - 1
				if l < m {
					m = l
					k = lt
				}
			} else {
				lo = lt + 1
				if r < m {
					m = r
					k = rt
				}
			}
		}
		// fmt.Println(m, k)
		printf("%d %d\n", m, k)

	}

}

package main

import (
	"fmt"
	"sort"
)

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

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func main() {
	var t int
	var n int
	fmt.Scanln(&t)
	for t > 0 {
		fmt.Scanln(&n)
		arr := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Scan(&arr[i])
		}

		var adj []int
		var k, m int
		for i := 0; i < n; i++ {
			if arr[i] != -1 {
				if i > 0 && arr[i-1] == -1 {
					adj = append(adj, arr[i])
				} else if i < n-1 && arr[i+1] == -1 {
					adj = append(adj, arr[i])
				}

				if i > 0 && arr[i-1] != -1 {
					m = max(m, abs(arr[i]-arr[i-1]))
				}
			}
		}
		sort.Ints(adj)
		if len(adj) > 0 {
			k = (adj[0] + adj[len(adj)-1]) / 2
			m = max(m, max(k-adj[0], adj[len(adj)-1]-k))
		}
		fmt.Println(m, k)
		t--
	}
}


This is a harder version of the problem. In this version, $$$n \le 50\,000$$$.There are $$$n$$$ distinct points in three-dimensional space numbered from $$$1$$$ to $$$n$$$. The $$$i$$$-th point has coordinates $$$(x_i, y_i, z_i)$$$. The number of points $$$n$$$ is even.You'd like to remove all $$$n$$$ points using a sequence of $$$\frac{n}{2}$$$ snaps. In one snap, you can remove any two points $$$a$$$ and $$$b$$$ that have not been removed yet and form a perfectly balanced pair. A pair of points $$$a$$$ and $$$b$$$ is perfectly balanced if no other point $$$c$$$ (that has not been removed yet) lies within the axis-aligned minimum bounding box of points $$$a$$$ and $$$b$$$.Formally, point $$$c$$$ lies within the axis-aligned minimum bounding box of points $$$a$$$ and $$$b$$$ if and only if $$$\min(x_a, x_b) \le x_c \le \max(x_a, x_b)$$$, $$$\min(y_a, y_b) \le y_c \le \max(y_a, y_b)$$$, and $$$\min(z_a, z_b) \le z_c \le \max(z_a, z_b)$$$. Note that the bounding box might be degenerate. Find a way to remove all points in $$$\frac{n}{2}$$$ snaps.

The first line contains a single integer $$$n$$$ ($$$2 \le n \le 50\,000$$$; $$$n$$$ is even), denoting the number of points. Each of the next $$$n$$$ lines contains three integers $$$x_i$$$, $$$y_i$$$, $$$z_i$$$ ($$$-10^8 \le x_i, y_i, z_i \le 10^8$$$), denoting the coordinates of the $$$i$$$-th point. No two points coincide.

Output $$$\frac{n}{2}$$$ pairs of integers $$$a_i, b_i$$$ ($$$1 \le a_i, b_i \le n$$$), denoting the indices of points removed on snap $$$i$$$. Every integer between $$$1$$$ and $$$n$$$, inclusive, must appear in your output exactly once. We can show that it is always possible to remove all points. If there are many solutions, output any of them.

NoteIn the first example, here is what points and their corresponding bounding boxes look like (drawn in two dimensions for simplicity, as all points lie on $$$z = 0$$$ plane). Note that order of removing matters: for example, points $$$5$$$ and $$$1$$$ don't form a perfectly balanced pair initially, but they do after point $$$3$$$ is removed.

package main

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

type point struct {
	x, y, z int64
	idx     int
}

func (p point) dis(p1 point) int64 {
	p.x -= p1.x
	p.y -= p1.y
	p.z -= p1.z
	return p.x*p.x + p.y*p.y + p.z*p.z
}

func solve(reader io.Reader, writer io.Writer) {
	in := bufio.NewReader(reader)
	out := bufio.NewWriter(writer)
	defer out.Flush()

	var n int
	Fscan(in, &n)
	ps := make([]point, n)
	for i := range ps {
		Fscan(in, &ps[i].x, &ps[i].y, &ps[i].z)
		ps[i].idx = i + 1
	}

	// 1
	sort.Slice(ps, func(i, j int) bool {
		pi, pj := ps[i], ps[j]
		return pi.x < pj.x || pi.x == pj.x && pi.y < pj.y || pi.x == pj.x && pi.y == pj.y && pi.z < pj.z
	})
	vis := make([]bool, n)
	for i := 1; i < n; i++ {
		p, p1 := ps[i-1], ps[i]
		if p.x == p1.x && p.y == p1.y {
			Fprintln(out, p.idx, p1.idx)
			vis[i-1] = true
			vis[i] = true
			i++
		}
	}
	newPs := make([]point, 0, n)
	for i, v := range vis {
		if !v {
			newPs = append(newPs, ps[i])
		}
	}

	// 2
	ps = newPs
	sort.Slice(ps, func(i, j int) bool {
		pi, pj := ps[i], ps[j]
		return pi.x < pj.x || pi.x == pj.x && pi.y < pj.y || pi.x == pj.x && pi.y == pj.y && pi.z < pj.z
	})
	n = len(ps)
	vis = make([]bool, n)
	for i := 1; i < n; i++ {
		p, p1 := ps[i-1], ps[i]
		if p.x == p1.x {
			Fprintln(out, p.idx, p1.idx)
			vis[i-1] = true
			vis[i] = true
			i++
		}
	}
	newPs = make([]point, 0, n)
	for i, v := range vis {
		if !v {
			newPs = append(newPs, ps[i])
		}
	}

	// 3
	ps = newPs
	sort.Slice(ps, func(i, j int) bool {
		pi, pj := ps[i], ps[j]
		return pi.x < pj.x || pi.x == pj.x && pi.y < pj.y || pi.x == pj.x && pi.y == pj.y && pi.z < pj.z
	})
	n = len(ps)
	vis = make([]bool, n)
	for i := 1; i < n; i+=2 {
		p, p1 := ps[i-1], ps[i]
		Fprintln(out, p.idx, p1.idx)
	}
}

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


Little Tanya decided to present her dad a postcard on his Birthday. She has already created a message — string s of length n, consisting of uppercase and lowercase English letters. Tanya can't write yet, so she found a newspaper and decided to cut out the letters and glue them into the postcard to achieve string s. The newspaper contains string t, consisting of uppercase and lowercase English letters. We know that the length of string t greater or equal to the length of the string s.The newspaper may possibly have too few of some letters needed to make the text and too many of some other letters. That's why Tanya wants to cut some n letters out of the newspaper and make a message of length exactly n, so that it looked as much as possible like s. If the letter in some position has correct value and correct letter case (in the string s and in the string that Tanya will make), then she shouts joyfully "YAY!", and if the letter in the given position has only the correct value but it is in the wrong case, then the girl says "WHOOPS".Tanya wants to make such message that lets her shout "YAY!" as much as possible. If there are multiple ways to do this, then her second priority is to maximize the number of times she says "WHOOPS". Your task is to help Tanya make the message.

The first line contains line s (1 ≤ |s| ≤ 2·105), consisting of uppercase and lowercase English letters — the text of Tanya's message. The second line contains line t (|s| ≤ |t| ≤ 2·105), consisting of uppercase and lowercase English letters — the text written in the newspaper. Here |a| means the length of the string a.

Print two integers separated by a space:   the first number is the number of times Tanya shouts "YAY!" while making the message,  the second number is the number of times Tanya says "WHOOPS" while making the message.

package main

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

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

//Wrong
func main() {
	defer writer.Flush()
	scanner.Split(bufio.ScanWords)

	var s, t string
	scan(&s, &t)

	alphaS := countChar(s)
	alphaT := countChar(t)
	cntYay, cntWhoops := 0, 0
	minChar := 0

	for i := 0; i < 26; i++ {
		for j := 0; j < 2; j++ {
			minChar = min(alphaS[j][i], alphaT[j][i])
			cntYay += minChar
			alphaS[j][i] -= minChar
			alphaT[j][i] -= minChar

		}

		for j := 0; j < 2; j++ {
			minChar = min(alphaS[j][i], alphaT[(j+1)%2][i])
			cntWhoops += minChar
			alphaS[j][i] -= minChar
			alphaT[(j+1)%2][i] -= minChar
		}
	}

	println(cntYay, cntWhoops)
}

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

func countChar(s string) [][]int {
	alpha := make([][]int, 2)

	for i := range alpha {
		alpha[i] = make([]int, 26)
	}

	for i := 0; i < len(s); i++ {
		if s[i] >= 'a' {
			alpha[0][s[i]-'a']++
		} else {
			alpha[1][s[i]-'A']++
		}
	}

	return alpha
}

func scan(a ...interface{}) {
	fmt.Fscan(reader, a...)
}

func next() string {
	if !scanner.Scan() {
		panic("Scan error")
	}
	return scanner.Text()
}

func nextInt() int {
	n, _ := strconv.Atoi(next())
	return n
}

func nextFloat() float64 {
	n, _ := strconv.ParseFloat(next(), 64)
	return n
}

func println(a ...interface{}) {
	fmt.Fprintln(writer, a...)
}

func printf(format string, a ...interface{}) {
	fmt.Fprintf(writer, format, a...)
}

package main

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

var scanner *bufio.Scanner

func getI64() int64 {
  scanner.Scan()
  x, _ := strconv.ParseInt(scanner.Text(), 10, 64)
  return x
}
func getI() int {
  return int(getI64())
}
func getF() float64 {
  scanner.Scan()
  x, _ := strconv.ParseFloat(scanner.Text(), 64)
  return x
}
func getS() string {
  scanner.Scan()
  return scanner.Text()
}

func otherCase(ch rune) rune {
  if ch >= 'a' && ch <= 'z' {
    return 'A'+(ch-'a')
  } else {
    return 'a'+(ch-'A')
  }
}

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

  s, _ := reader.ReadString('\n')
  s = strings.TrimSpace(s)
  t, _ := reader.ReadString('\n')
  t = strings.TrimSpace(t)
  want := map[rune]int{}
  for _, ch := range s {
    want[ch]++
  }
  exact, almost := 0, 0
  have := map[rune]int{}
  for _, ch := range t {
    if want[ch] > 0 {
      want[ch]--
      exact++
    } else {
      have[ch]++
    }
  }
  for ch, count := range have {
    ch = otherCase(ch)
    for count > 0  && want[ch] > 0 {
      almost++
      count--
      want[ch]--
    }
  }
  writer.WriteString(fmt.Sprintf("%d %d\n", exact, almost))
}

package main

import (
	"fmt"
)

func parse(s string) (r map[byte]int) {
	r = make(map[byte]int)
	var c byte = 0
	for c = 'A'; c <= 'Z'; c++ {
		r[c] = 0
	}
	for c = 'a'; c <= 'z'; c++ {
		r[c] = 0
	}

	for i := 0; i < len(s); i++ {
		r[s[i]] += 1
	}
	return r
}

func main() {
	var s string
	var t string
	fmt.Scanln(&s)
	fmt.Scanln(&t)

	ms := parse(s)
	mt := parse(t)

	var y int = 0
	var w int = 0

	for k, _ := range ms {
		yy := ms[k]
		if yy > mt[k] {
			yy = mt[k]
		}
		y += yy
		ms[k] -= yy
		mt[k] -= yy
	}

	for k, _ := range ms {
		ww := ms[k]
		kk := k ^ 32
		if ww > mt[kk] {
			ww = mt[kk]
		}
		w += ww
		ms[k] -= ww
		mt[kk] -= ww
	}

	fmt.Printf("%d %d", y, w)
	fmt.Println("")
}

package main

import (
	"fmt"
)

func main() {
	var s, t string
	fmt.Scanf("%s %s", &s, &t)
	cs, ct := count(s), count(t)
	yay, whoops := 0, 0
	for i := 0; i < 26; i++ {
		for j := 0; j < 2; j++ {
			c := min(cs[j][i], ct[j][i])
			yay += c
			cs[j][i] -= c
			ct[j][i] -= c
		}
		for j := 0; j < 2; j++ {
			c := min(cs[j^1][i], ct[j][i])
			whoops += c
		}
	}
	fmt.Printf("%d %d\n", yay, whoops)
}

func min(a, b int) int {
	switch {
	case a < b:
		return a
	default:
		return b
	}
}

func count(s string) [2][26]int {
	var arr [2][26]int
	for _, v := range s {
		if 'a' <= v && v <= 'z' {
			arr[0][v-'a']++
		} else {
			arr[1][v-'A']++
		}
	}
	return arr
}

package main

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

var (
  stdin = bufio.NewReader(os.Stdin)
)

func main() {
    var s, t string
    fmt.Fscanf(stdin, "%s %s", &s, &t)
    cs, ct := count(s), count(t)
    yay, whoops := 0, 0
    for i := 0; i < 26; i++ {
        for j := 0; j < 2; j++ {
            c := min(cs[j][i], ct[j][i])
            yay += c
            cs[j][i] -= c
            ct[j][i] -= c
        }
        for j := 0; j < 2; j++ {
            c := min(cs[j^1][i], ct[j][i])
            whoops += c
        }
    }
    fmt.Printf("%d %d\n", yay, whoops)
}

func min(a, b int) int {
    switch {
    case a < b:
        return a
    default:
        return b
    }
}

func count(s string) [2][26]int {
    var arr [2][26]int
    for _, v := range s {
        if 'a' <= v && v <= 'z' {
            arr[0][v-'a']++
        } else {
            arr[1][v-'A']++
        }
    }
    return arr
}

package main

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

var scanner *bufio.Scanner

func getI64() int64 {
  scanner.Scan()
  x, _ := strconv.ParseInt(scanner.Text(), 10, 64)
  return x
}
func getI() int {
  return int(getI64())
}
func getF() float64 {
  scanner.Scan()
  x, _ := strconv.ParseFloat(scanner.Text(), 64)
  return x
}
func getS() string {
  scanner.Scan()
  return scanner.Text()
}

func otherCase(ch rune) rune {
  if ch >= 'a' && ch <= 'z' {
    return 'A'+(ch-'a')
  } else {
    return 'a'+(ch-'A')
  }
}

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

  s, _ := reader.ReadString('\n')
  s = strings.TrimSpace(s)
  t, _ := reader.ReadString('\n')
  t = strings.TrimSpace(t)
  want := map[rune]int{}
  for _, ch := range s {
    want[ch] += 1
  }
  exact, almost := 0, 0
  for _, ch := range t {
    if want[ch] != 0 {
      want[ch] -= 1
      exact++
      continue
    }
    ch = otherCase(ch)
    if want[ch] != 0 {
      want[ch] -= 1
      almost++
    }
  }
  writer.WriteString(fmt.Sprintf("%d %d\n", exact, almost))
}

package main

import (
	"fmt"
)

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

	var a []int = make([]int, n, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}

	var f int = 0
	var p int = 0
	var b bool = true

	for f < n {
		var c byte
		switch {
		case p < f:
			c = 'R'
			p += 1
			b = true
		case p == f:
			if a[p] == 0 {
				f += 1
			}
			if b && a[p] > 0 {
				c = 'P'
				a[p] -= 1
				b = false
				if a[p] == 0 {
					f += 1
				}
			} else {
				if p != n - 1 {
					c = 'R'
					p += 1
				} else {
					c = 'L'
					p -= 1
				}
				b = true
			}
		case p > f:
			if b && a[p] > 0 {
				c = 'P'
				a[p] -= 1
				b = false
			} else {
				if p != 0 {
					c = 'L'
					p -= 1
				} else {
					// never reach
					c = 'R'
					p += 1
				}
				b = true
			}
		}
		fmt.Printf("%c", c)
	}
	fmt.Println("")
}

package main

import (
	"fmt"
)

func exchange(ch rune) rune {
	if 'a' <= ch && ch <= 'z' {
		return ch - 'a' + 'A'
	}
	return ch - 'A' + 'a'
}

func main() {
	var s, t string
	fmt.Scanf("%s %s", &s, &t)
	wd := make(map[rune]int)
	for _, ch := range t {
		wd[ch]++
	}
	yay, whoops := 0, 0
	for _, ch := range s {
		if _, ok := wd[ch]; ok {
			wd[ch]--
			yay++
			if wd[ch] == 0 {
				delete(wd, ch)
			}
		} else {
			ch = exchange(ch)
			if _, ok := wd[ch]; ok {
				wd[ch]--
				whoops++
				if wd[ch] == 0 {
					delete(wd, ch)
				}
			}
		}
	}
	fmt.Printf("%d %d\n", yay, whoops)
}


Stepan has the newest electronic device with a display. Different digits can be shown on it. Each digit is shown on a seven-section indicator like it is shown on the picture below.  So, for example, to show the digit 3 on the display, 5 sections must be highlighted; and for the digit 6, 6 sections must be highlighted. The battery of the newest device allows to highlight at most n sections on the display. Stepan wants to know the maximum possible integer number which can be shown on the display of his newest device. Your task is to determine this number. Note that this number must not contain leading zeros. Assume that the size of the display is enough to show any integer.

The first line contains the integer n (2 ≤ n ≤ 100 000) — the maximum number of sections which can be highlighted on the display.

Print the maximum integer which can be shown on the display of Stepan's newest device.

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	for n > 1{
	    if (n % 2) == 0{
	        fmt.Printf("1")
	        n-=2
    	}else{
    	    fmt.Printf("7")
    	    n-=3
    	}
	}
	fmt.Printf("\n")
}

package main

import "fmt"

func main() {
	var s string = ""
	var n int
	fmt.Scan(&n)
	if n % 2 == 0{
    	for i := 0; i < n/2; i++ {
        	    s+="1"
        	}
	}
	if n % 2 == 1{
	    s+="7"
	    for i := 1; i < n/2; i++ {
        	    s+="1"
	    }
	}
	fmt.Println(s)
}

package main

import "fmt"
import "bytes"

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

	var buffer bytes.Buffer

	if n%2 == 1 {
		buffer.WriteString("7")
		n -= 3
	}
	for i := 0; i < n; i += 2 {
		buffer.WriteString("1")
	}
	fmt.Println(buffer.String())

}

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	if n % 2 == 1 {
	    fmt.Print(7)
	    n := (n - 3) / 2
	    for i := 0; i < n; i++ {
            fmt.Print(1)
        }
	} else {
	    n := n / 2
	    for i := 0; i < n; i++ {
            fmt.Print(1)
        }
	}
}

package main

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

func solve() {
	n:= readInt()
    if n%2==1{
        fmt.Print(7)
        n=n-3
    }
	 for i := 0; i < n; i+=2 {
	     fmt.Print(1)
	 }
	fmt.Println()
}

var scanner *bufio.Scanner

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

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

// IO

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
	v, _ := strconv.ParseInt(readString(), 10, 64)
	return v
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = readInt64()
	}
	return res
}

package main

import "fmt"

func main() {
	var n int
	var x int
	fmt.Scan(&n)
	var s string
	s = ""
	x = n / 2
	if n % 2 == 0 {
        for i := 0; i < x; i++ {
		s = s + "1"
        }
    } else if n % 2 == 1 {
        s = s + "7"
        for i := 0; i < x - 1; i++ {
		s = s + "1"
        }
    }
	fmt.Println(s)
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	if n%2==1 {fmt.Print(7)}
	if n%2==0 {fmt.Print(1)}
	for i := 0; i < n/2-1; i++ {fmt.Print(1)}
}

package main

import "fmt"

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

	for i := 0; ; i++ {
		if n%2 != 0 {
			fmt.Printf("7")
			n -= 3
			if n == 0 {
				break
			}
		}
		if n <= 3 {
			if n == 3 {
				fmt.Printf("7")
			} else {
				fmt.Printf("1")
			}
			break
		} else {
			fmt.Printf("1")
			n = n - 2
		}

	}
}

package main
import (
    "fmt"
)

func main() {
    var n int
    fmt.Scan(&n)
    cnt := 0
    hasleft := 0
    if n % 2 == 1 {
        cnt = (n - 3) / 2
        hasleft = 1
    } else {
        cnt = n / 2
    }
    if hasleft == 1 {
        fmt.Print(7)
    }
    for i := 0; i < cnt; i ++ {
        fmt.Print(1)
    }
}

package main

import "fmt"

func main() {
  var n int
  fmt.Scan(&n)
  var ans [100003]int
  m := 0

  for n >= 2 {
    if n >= 2 {
      ans[m] = 1
      m++
      n = n-2
    }
  }
  if n > 0 {
    ans[m-1] = 7
  }
  for m > 0 {
    m--
    fmt.Print(ans[m])
  }
  fmt.Println()
}

package main

import "fmt"

func main(){
    var n int
    fmt.Scan(&n)
    if n%2==0 {
        for i := 0;i <n/2; i++ {
            fmt.Print("1")
        }
    }else{
        fmt.Print("7")
        for i := 1;i <n/2; i++ {
            fmt.Print("1")
        }
    }
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	if n % 2 == 1 {
		fmt.Print("7")
		n = n - 3
	}
	for i := 0; n > 0; i = i ^ 1 {
		fmt.Print("1")
		n = n - 2
	}
}

package main
import "fmt"

func main(){
	// your code goes here

	var n,x int
	fmt.Scan(&n)
	x=n%2

	if  x > 0	{
		fmt.Print(7)
	} else {
		fmt.Print(1)
	}
	for i := 0; i< n/2-1 ; i++ {

		fmt.Print(1)
	}
}

package main

import "fmt"

func main() {
    var n int64
    var s string
    fmt.Scan(&n)
    if n % 2 == 1 {
      s += "7"
      n = n - 3
    }
    for n > 0{
      s += "1"
      n = n - 2
    }
    fmt.Println(s)
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
    if n % 2 == 0 {
        for i:= 1; i <= n / 2; i ++ {
            fmt.Printf("1");
        }
    } else {
        fmt.Printf("7");
        for i:= 1; i < n / 2; i ++ {
            fmt.Printf("1");
        }
    }
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	if n % 2 > 0 {
	    fmt.Print("7")
	    for i := 0; i < (n - 3) / 2; i++ {
	        fmt.Print("1")
	    }
	} else {
	    for i := 0; i < n / 2; i++ {
	        fmt.Print("1")
	    }
	}
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	if (n % 2 == 1) {
	    fmt.Print(7)
	    n -= 3
	}
	for n > 0 {
	    fmt.Print(1)
	    n -= 2
	}
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	if n % 2 == 1 {
	    fmt.Print("7")
	    n-=3
	}
	for i := 0; i < n; i+=2 {
	    fmt.Print("1")
	}
}

package main

import "fmt"

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

		if n%2==0 {
			for j:=0;j<n/2;j++{
                            fmt.Printf("1")
                                           }
		} else {
			fmt.Printf("7")
for j:=1;j<n/2;j++{
                            fmt.Printf("1")
}
		}
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	if n&1==1 {
	    fmt.Printf("%d",7);
	}	else {
	    fmt.Printf("%d",1);
	}
	for i := 0; i < (n/2-1); i++ {
	 fmt.Printf("%d",1);
	}
}

package main

import "fmt"

func main() {
    var n int
    fmt.Scan(&n)
    if n % 2 != 0 {
        fmt.Printf("%d", 7)
        n -= 3
    }
    for i := n; i > 0; i-=2 {
        fmt.Printf("%d", 1)
        n -= 2
    }
}

package main

import "fmt"

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

    if (n % 2 == 1) {
        fmt.Print(7)
        n = n - 3
    }
    for n > 0 {
        fmt.Print(1)
        n = n - 2
    }
}

// Codeforces 774 C
package main

import (
"bufio"
"fmt"
"strings"
"strconv"
	"os"
)
var in *bufio.Reader

func readFive() (int,int,int,int,int) {
	var a [5]int
	s, err := in.ReadString('\n')
	if err != nil {
		fmt.Println("first read failure", err)
		panic(err)
	}
	ss := strings.Split(strings.Trim(s, " \n\r"), " ")
	for i:=0; i<len(ss); i++ {
		a[i], err = strconv.Atoi(ss[i])
		if err != nil {
			fmt.Println("n atoi failure", err)
			panic(err)
		}
	}
	return a[0],a[1],a[2],a[3],a[4]
}

func readLineNumbs(n int) []int {
	a := make([]int, n)
	s, err := in.ReadString('\n')
	if err != nil {
		fmt.Println("read failure", err)
		panic(err)
	}
	ss := strings.Split(strings.Trim(s, " \n\r"), " ")
	for j:=0; j<n; j++ {
		aa,err := strconv.Atoi(ss[j])
		if err != nil {
			fmt.Println("aa conv failed", err)
			panic(err)
		}
		a[j] = aa
	}
	return a
}

const MOD = 1000000007
type group map[int]bool
type pair struct {
	pok int
	cnt int
}
type pairs []pair

var n int
var sret string

func readData() {
	in = bufio.NewReader(os.Stdin)
	n,_,_,_,_ = readFive()
}

func solve() {
	bs := make([]byte, n)
	b1 := 0

	if n%2==1 {
		b1 += copy(bs[b1:], "7")
		n = (n-3)/2
	} else {
		b1 += copy(bs[b1:], "1")
		n = (n-2)/2
	}
	for i := 0; i < n; i++ {
		b1 += copy(bs[b1:], "1")
	}
	sret = string(bs[0:(n+1)])+"\n"
}

func printRes() {
	fmt.Println(sret)
}

func main() {
	readData()
	solve()
	printRes()
}

package main

import "fmt"

func main() {
    //fmt.Print("Enter a number: ")
    var A int
    fmt.Scanf("%d", &A)
    for A >= 2 {
        if A % 2 == 1 {
            A -= 3
            fmt.Print("7")
        } else {
            A -=2
            fmt.Print("1")
        }
    }
}

package main
import "fmt"
func main(){
	var n,m int
	fmt.Scan(&n)
        m = n / 2 - 1
        n = n - (m * 2)
if n == 2{
fmt.Print(1)
}
if n > 2{
fmt.Print(7)
}
for x := 0; x < m; x++{
fmt.Print(1)
}

}

package main

import "fmt"

// this is a comment

func main() {
    var N int
    fmt.Scan(&N)
    if N % 2 == 1 {
        fmt.Print("7")
        N -= 3
    }
    for i := 0; i < N; i += 2 {
        fmt.Print("1")
    }

}

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	for n > 1{
	    if (n % 3) == 0{
	        fmt.Printf("7")
	        n-=3
    	}else{
    	    fmt.Printf("1")
    	    n-=2
    	}
	}
	fmt.Printf("\n")
}

package main

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

func solve() {
	n:= readInt()
    ans:=0
	 if n >= 2{
   ans = 1
   }
   if n >= 5{
   ans = 2
   }
   if n >= 5{
   ans = 3
   }
   if n >= 4{
   ans = 4;
   }
   if n >= 5{
   ans = 5;
   }
   if n >= 6{
   ans = 6;
   }
   if  n >= 3{
   ans = 7;
   }
   if n >= 7{
   ans = 8;
   }
   if n >= 6{
   ans = 9;
   }

	fmt.Print(ans)
	fmt.Println()
}

var scanner *bufio.Scanner

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

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

// IO

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
	v, _ := strconv.ParseInt(readString(), 10, 64)
	return v
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = readInt64()
	}
	return res
}

package main

import "fmt"

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

	for i := 0; ; i++ {
		if n <= 3 {
			if n == 3 {
				fmt.Printf("7")
			} else {
				fmt.Printf("1")
			}
			break
		} else {
			fmt.Printf("1")
			n = n - 2
		}

	}

// 	for i := 0; i < n; i++ {
// 		var s string
// 		fmt.Scan(&s)
// 		l := len(s)
// 		if l <= 10 {
// 			fmt.Println(s)
// 		} else {
// 			fmt.Printf("%c%d%c\n", s[0], l - 2, s[l - 1])
// 		}
// 	}
}

package main
import (
    "fmt"
)

func main() {
    var n int
    fmt.Scan(&n)
    cnt := 0
    hasleft := 0
    if n % 2 == 1 {
        cnt = (n - 3) / 2
        hasleft = 1
    } else {
        cnt = n / 2
    }

    for i := 0; i < cnt; i ++ {
        fmt.Print(1)
    }
    if hasleft == 1 {
        fmt.Print(7)
    }
}

package main
import "fmt"

func main(){
	// your code goes here

	var n,x int
	fmt.Scan(&n)
	x=n%2
	for i := 0; i< n/2-1 ; i++ {

		fmt.Print(1)
	}
	if  x > 0	{
		fmt.Print(7)
	} else {
		fmt.Print(1)
	}
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
    if n % 2 == 0 {
        for i:= 1; i <= n / 2; i ++ {
            fmt.Printf("1");
        }
    } else {
        for i:= 1; i < n / 2; i ++ {
            fmt.Printf("1");
        }
        fmt.Printf("7");
    }
}