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"
	"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 (
	"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")
		}
	}
}


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
}


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"
	"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"
	"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--
	}
}


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 (
	"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 (
  "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]++
  }
  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 (
	"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] += 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)
}


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"

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"

// 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 % 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)
	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");
    }
}


package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	var a[1000] int
	for i := 0; i < n; i++ {
		var s string
		fmt.Scan(&s)
		a[i] = int (s[0] - '0') * 10 + int (s[1] - '0')
		a[i] = a[i] * 60
		a[i] = a[i] + int (s[3] - '0') * 10 + int (s[4] - '0')
	}
	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			if (a[i] < a[j]) {
				var c int
				c = a[i]
				a[i] = a[j]
				a[j] = c
			}
		}
	}
	var ans int
	ans = 0
	a[n] = a[0] + 1440
	for i:= 1; i <= n; i++ {
		if (ans < a[i] - a[i - 1]) {
			ans = a[i] - a[i - 1]
		}
	}
	ans -= 1
	var sa int
	var mi int
	sa = ans / 60
	mi = ans % 60
	fmt.Print (sa / 10)
	fmt.Print (sa % 10)
	fmt.Print (":")
	fmt.Print (mi / 10)
	fmt.Print (mi % 10)

}

package main

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

func main() {
	var n int
	reader, writer := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	fmt.Fscanf(reader, "%d\n", &n)
	h := make([]int, n)
	m := make([]int, n)
	t := make([]int, 2 * 24 * 60)
	for i := 0; i < 2 * 24 * 60; i++ {
	    t[i] = 0
	}
	for i := range h {
		fmt.Fscanf(reader, "%d:%d\n", &h[i], &m[i])
		t[60 * h[i] + m[i]] = 1
		t[60 * h[i] + m[i] + 24 * 60] = 1
	}
	if n == 1 {
	    fmt.Fprintf(writer, "23:59\n")
	} else {
	    var ans int
	    ans = 0
	    var last int
	    last = -1
	    for i := 0; i < 2 * 24 * 60; i++ {
	        if t[i] == 1 {
	            var cur int
	            cur = i - last - 1
	            if cur > ans {
	                ans = cur
	            }
	            last = i
	        }
	    }
	    fmt.Fprintf(writer, "%02d:%02d\n", ans / 60, ans % 60)
	}
}

package main

import "sort"
import "fmt"
import "strconv"

func main() {
	var n int
	fmt.Scan(&n)
	a := []int{}
	for i := 0; i < n; i++ {
		var x string
		fmt.Scan(&x)
		//fmt.Printf("%v %v\n", x[1:2], strconv.Atoi("123"))
		q, _ := strconv.Atoi(x[0:1])
		b, _ := strconv.Atoi(x[1:2])// * 10 + strconv.Atoi(x[1:1]) * 60 + strconv.Atoi(x[0:0]) * 600
		c, _ := strconv.Atoi(x[3:4])
		d, _ := strconv.Atoi(x[4:5])
		t := d + 10 * c + 60 * b + 600 * q
		a = append(a, t)
	}
	sort.Ints(a)
	ans := a[0] + 600 * 2 + 60 * 4 - a[n - 1] - 1
	for i := 1; i < n; i++ {
	    x := a[i] - a[i - 1] - 1
	    if x > ans {
	        ans = x
	    }
	}
	fmt.Printf("%v%v:%v%v\n", ans / 600, (ans / 60) % 10, (ans / 10) % 6, ans % 10)
}

package main
import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	var arr [110]int
	for i := 0; i < n; i++ {
		var s string
		fmt.Scan(&s)
		var a int
		var b int
		var c int
		var d int
		a = (int(s[0]))
		b = (int(s[1]))
		c = (int(s[3]))
		d = (int(s[4]))
		arr[i] = (a * 10 + b) * 60 + c * 10 + d
	}
	for i := 0; i < n; i++ {
	    for j := 1; j < n; j++ {
	        if arr[j - 1] > arr[j] {
	            var f int
	            f = arr[j - 1]
	            arr[j - 1] = arr[j]
	            arr[j] = f
	        }
	    }
	}
	arr[n] = arr[0] + 24 * 60
	var ans int
	ans = 0
	for i := 1; i <= n; i++ {
		if arr[i] - arr[i - 1] > ans {
		    ans = arr[i] - arr[i - 1]
		}
	}
	ans--
	//fmt.Println(ans)
	var h int
	h = ans / 60
	var m int
	m = ans % 60
	//fmt.Println(h)
	//fmt.Println(m)
	if h < 10 {
	    fmt.Printf("%d", 0)
	}
	fmt.Printf("%d", h)
	fmt.Printf("%c", ':')
	if m < 10 {
	    fmt.Printf("%d", 0)
	}
	fmt.Printf("%d", m)
}

package main

import (
    "fmt"
    "strconv"
)

func main() {
    var n int
    var a [5880] bool
    fmt.Scan(&n)
    for i := 0; i < n; i++ {
        var s string
        var hours int
        var minutes int
        var _ error
        fmt.Scan(&s)

        hours, _ = strconv.Atoi(s[0:2])
        minutes, _ = strconv.Atoi(s[3:5])

        a[hours*60+minutes] = true
        a[hours*60+minutes+24*60] = true
    }
    var mx int
    var cur int
    mx = 0
    cur = 0
    for i := 0; i < 2880; i++ {
        if a[i] == false {
            cur++
        } else {
            cur = 0
        }
        if cur > mx {
            mx = cur
        }
    }

    fmt.Printf("%02d:%02d\n", mx/60, mx%60)
}

package main

import (
    "fmt"
    "strconv"
    "sort"
    )

func toInt(k string) int {
    h, _ := strconv.Atoi(k[0: 2])
    h*=60
    m, _ := strconv.Atoi(k[3:])
    return h+m
}

func main() {
    var k string
    var v int
    fmt.Scan(&v)
    if (v == 1) {
        fmt.Scan(&k)
        fmt.Print("23:59")
        return
    } else {
    arr := make([]int, v)
    for i := 0; i < v; i++ {
        fmt.Scan(&k)
        arr[i] = toInt(k)
    }
    sort.Ints(arr)
    gap := 0
    for i := 1; i < v; i++ {
        if (gap < arr[i]-arr[i-1]-1) {
            gap = arr[i]-arr[i-1]-1
        }
    }
    if ((23*60+60-arr[len(arr)-1])+arr[0]-1 > gap) {
        gap = (23*60+60-arr[len(arr)-1])+arr[0]-1
    }
    if gap/60 < 10 {
        fmt.Print("0")
    }
    fmt.Print(gap/60)
    fmt.Print(":")
    if gap%60 < 10 {
        fmt.Print("0")
    }
    fmt.Print(gap%60)
    }
}

package main

import "fmt"

func main() {
var n int
fmt.Scan(&n)
var a[1000] int
for i := 0; i < n; i++ {
var s string
fmt.Scan(&s)
a[i] = int (s[0] - '0') * 10 + int (s[1] - '0')
a[i] = a[i] * 60
a[i] = a[i] + int (s[3] - '0') * 10 + int (s[4] - '0')
}
for i := 0; i < n; i++ {
for j := 0; j < n; j++ {
if (a[i] < a[j]) {
var c int
c = a[i]
a[i] = a[j]
a[j] = c
}
}
}
var ans int
ans = 0
a[n] = a[0] + 1440
for i:= 1; i <= n; i++ {
if (ans < a[i] - a[i - 1]) {
ans = a[i] - a[i - 1]
}
}
if n == 1 {
print ("23:59")
} else {
ans -= 1;
var sa int
var mi int
sa = ans / 60
mi = ans % 60
print (sa / 10)
print (sa % 10)
print (":")
print (mi / 10)
print (mi % 10)
}
}

package main

import (
    "fmt"
    "strconv"
    "sort"
    )

func toInt(k string) int {
    h, _ := strconv.Atoi(k[0: 2])
    h*=60
    m, _ := strconv.Atoi(k[3:])
    return h+m
}

func main() {
    var k string
    var v int
    fmt.Scan(&v)
    if (v == 1) {
        fmt.Scan(&k)
        fmt.Print(k)
        return
    } else {
    arr := make([]int, v)
    for i := 0; i < v; i++ {
        fmt.Scan(&k)
        arr[i] = toInt(k)
    }
    sort.Ints(arr)
    gap := 0
    for i := 1; i < v; i++ {
        if (gap < arr[i]-arr[i-1]) {
            gap = arr[i]-arr[i-1]
        }
    }
    if ((24*60+-arr[len(arr)-1])+arr[0] > gap) {
        gap = (24*60+-arr[len(arr)-1])+arr[0]
    }
    if gap/60 < 10 {
        fmt.Print("0")
    }
    fmt.Print(gap/60)
    fmt.Print(":")
    if (gap%60-1 < 10) {
        fmt.Print("0")
    }
    fmt.Print(gap%60-1)
    }
}

package main

import (
    "fmt"
    "strconv"
    "sort"
    )

func toInt(k string) int {
    h, _ := strconv.Atoi(k[0: 2])
    h*=60
    m, _ := strconv.Atoi(k[3:])
    return h+m
}

func main() {
    var k string
    var v int
    fmt.Scan(&v)
    if (v == 1) {
        fmt.Scan(&k)
        fmt.Print("23:59")
        return
    } else {
    arr := make([]int, v)
    for i := 0; i < v; i++ {
        fmt.Scan(&k)
        arr[i] = toInt(k)
    }
    sort.Ints(arr)
    gap := 0
    for i := 1; i < v; i++ {
        if (gap < arr[i]-arr[i-1]) {
            gap = arr[i]-arr[i-1]
        }
    }
    if ((24*60+-arr[len(arr)-1])+arr[0] > gap) {
        gap = (24*60+-arr[len(arr)-1])+arr[0]
    }
    if gap/60 < 10 {
        fmt.Print("0")
    }
    fmt.Print(gap/60)
    fmt.Print(":")
    if (gap%60-1 < 10) {
        fmt.Print("0")
    }
    fmt.Print(gap%60-1)
    }
}


package main

import (
	"fmt"
)

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

	a := make([]int, n+1)
	b := make([]int, n+1)

	for i := 0; i < n; i++ {
		fmt.Scan(&a[i+1])
		a[i+1] = a[i+1] | a[i]
	}

	for i := 0; i < n; i++ {
		fmt.Scan(&b[i+1])
		b[i+1] = b[i+1] | b[i]
	}
	max := 0

	for i := 1; i < n+1; i++ {
		for j := i; j < n+1; j++ {
			total := (a[j] ^ a[i-1]) + (b[j] ^ b[i-1])
			if total > max {
				max = total
			}
		}
	}
	fmt.Println(max)
}

package main

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

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

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

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

	max := -1
	for i := 0; i < n; i++ {
		for j := i; j < n; j++ {
			sum := f(a, i, j) + f(b, i, j)
			if sum > max {
				max = sum
			}
		}
	}
	fmt.Println(max)
}

func f(a []int, i, j int) int {
	or := 0
	for k := i; k <= j; k++ {
		or |= a[k]
	}
	return or
}

package main

import "fmt"

func main() {
    n := 0

    fmt.Scanf("%d\n", &n)

    a := make([]uint, n)
    b := make([]uint, n)

    for i := 0; i < n; i++ {
       _, err := fmt.Scanf("%d", &a[i])
       if err != nil {
           fmt.Scanf("%d", &a[i])
       }
    }

    for i := 0; i < n; i++ {
       _, err := fmt.Scanf("%d", &b[i])
       if err != nil {
           fmt.Scanf("%d", &b[i])
       }
    }

    for i := 1; i < n; i++ {
        a[0] |= a[i]
        b[0] |= b[i]
    }

    fmt.Println(a[0] + b[0])

}

package main

import (
	"fmt"
)

func mx(x []int) int {
	amax := 0
	n := len(x)
	for i := 0; i < n; i++ {
		for j := i; j < n; j++ {
			t := x[i]
			for k := i; k <= j; k++ {
				t |= x[k]
			}
			if amax < t {
				amax = t
			}
		}
	}
	return amax
}

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

package main

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

func main() {
	scanner.Split(bufio.ScanWords)
	N := nextInt()
	var x, y int = 0, 0
	for i := 0; i < N; i++ {
		x |= nextInt()
	}
	for i := 0; i < N; i++ {
		y |= nextInt()
	}
	fmt.Println(x + y)

}

//---------------------------------template--------------------------------

var scanner = bufio.NewScanner(os.Stdin)

var writer = bufio.NewWriter(os.Stdout)

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

func nextInt() int {
	val, err := strconv.Atoi(nextToken())
	if err != nil {
		panic(err.Error())
	}
	return val
}

package main

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

var scanner *bufio.Scanner
var writer *bufio.Writer

func init() {
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	writer = bufio.NewWriter(os.Stdout)
}

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

func nextInt() int {
	v, _ := strconv.Atoi(nextToken())
	return v
}

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

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

func printInt(x int) {
	writer.WriteString(strconv.Itoa(x))
}

func printInt64(x int64) {
	writer.WriteString(strconv.FormatInt(x, 10))
}

func printString(x string) {
	writer.WriteString(x)
}

func main() {
	n := nextInt()
	x, y := 0, 0
	for i := 0; i < n; i++ {
		x |= nextInt()
	}
	for i := 0; i < n; i++ {
		y |= nextInt()
	}
	printInt(x + y)
	writer.Flush()
}

package main

import "fmt"

func xor(slice []uint, left int, right int) uint {
    var sum uint
    for i := left; i <= right; i++ {
        sum ^= slice[i]
    }
    return sum
}

func main() {
    n := 0

    fmt.Scanf("%d\n", &n)

    a := make([]uint, n)
    b := make([]uint, n)

    for i := 0; i < n; i++ {
       _, err := fmt.Scanf("%d", &a[i])
       if err != nil {
           fmt.Scanf("%d", &a[i])
       }
    }

    for i := 0; i < n; i++ {
       _, err := fmt.Scanf("%d", &b[i])
       if err != nil {
           fmt.Scanf("%d", &b[i])
       }
    }

    var sum, max uint
    for i := 0; i < n; i++ {
        for j := i; j < n; j++ {
            sum = xor(a, i, j) + xor(b, i, j)
            if sum > max {
                max = sum
            }
        }
    }
    fmt.Println(max)

}

package main

import (
	"fmt"
)

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

	a := make([]int, n+1)
	b := make([]int, n+1)

	for i := 0; i < n; i++ {
		fmt.Scan(&a[i+1])
		a[i+1] = a[i+1] | a[i]
	}

	for i := 0; i < n; i++ {
		fmt.Scan(&b[i+1])
		b[i+1] = b[i+1] | b[i]
	}
	max := 0

	for i := 1; i < n; i++ {
		for j := i; j < n+1; j++ {
			total := (a[j] ^ a[i-1]) + (b[j] ^ b[i-1])
			if total > max {
				max = total
			}
		}
	}
	fmt.Println(max)
}


package main

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

func GetScanner() func(a ...*int) {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	ScanInts := func(a ...*int) {
		for i := 0; i < len(a); i++ {
			scanner.Scan()
			*(a[i]), _ = strconv.Atoi(scanner.Text())
		}
	}
	return ScanInts
}

var left [1000005]int
var right [1000005]int
var times [1000005]int

func main() {
	scan := GetScanner()
	var n int
	var a int
	var most int
	scan(&n)
	for i := 1; i <= n; i++ {
		scan(&a)
		if left[a] == 0 {
			left[a] = i
		}
		right[a] = i
		times[a]++
		if times[a] > most {
			most = times[a]
		}
	}
	var l int = 0
	var r int = 123456789
	for i := 1; i <= 1000000; i++ {
		if times[i] == most && (right[i] - left[i] < r - l) {
			l, r = left[i], right[i]
		}
	}
	fmt.Println(l, r)
}

package main

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

const Max = 1000000

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

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

func main() {
    stdin := bufio.NewReader(os.Stdin)
    var n int
    fmt.Fscan(stdin, &n)

    var first, last, cnt [Max+1]int
    for i := 0; i <= Max; i++ {
        first[i] = n+1
        last[i] = 0
        cnt[i] = 0
    }
    rep := 0
    for i := 0; i < n; i++ {
        var v int
        fmt.Fscan(stdin, &v)
        last[v] = i+1
        cnt[v]++
        rep = max(rep, cnt[v])
        first[v] = min(first[v], i+1)
    }

    dist := n
    lo := 1
    hi := n

    for i := 1; i <= Max; i++ {
        if cnt[i] == rep {
            d := last[i] - first[i] + 1
            if d < dist {
                dist = d
                lo = first[i]
                hi = last[i]
            }
        }
    }
    fmt.Println(lo, hi)
}

package main

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

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

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

	n := nextInt()
	a := make([]int, n)
	cnts := make([]int, 1000001)
	b, e := make([]int, 1000001), make([]int, 1000001)
	for i := range a {
		a[i] = nextInt()
		cnts[a[i]]++

		if b[a[i]] == 0 {
			b[a[i]] = i + 1
		}

		e[a[i]] = i + 1
	}

	iMax := 0

	for i := range cnts {
		if cnts[i] > cnts[iMax] {
			iMax = i
		} else if cnts[i] == cnts[iMax] {
			// println(i, e[i], b[i])
			if e[i]-b[i] < e[iMax]-b[iMax] {
				iMax = i
			}
		}
	}

	l, r := 0, 0

	for i := range a {
		if a[i] == iMax {
			l = i + 1
			break
		}
	}

	for i := len(a) - 1; i >= 0; i-- {
		if a[i] == iMax {
			r = i + 1
			break
		}
	}

	println(l, r)
}

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

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

func nextInt64() int64 {
	n, _ := strconv.ParseInt(next(), 0, 64)
	return n
}

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 print(a ...interface{})                 { fmt.Fprint(writer, a...) }
func printf(format string, a ...interface{}) { fmt.Fprintf(writer, format, a...) }

package main

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

type numRec struct {
	Start  int
	End    int
	Beauty int
}

func main() {
	r := bufio.NewReader(os.Stdin)

	num := 0
	fmt.Fscanf(r, "%d\n", &num)

	m := map[int]numRec{}
	maxBeauty := 0

	for i := 0; i < num; i++ {
		var elem int
		fmt.Fscanf(r, "%d ", &elem)

		if rec, ok := m[elem]; ok {
			rec.Beauty++
			rec.End = i
			m[elem] = rec
		} else {
			m[elem] = numRec{i, i, 1}
		}

		if m[elem].Beauty > maxBeauty {
			maxBeauty = m[elem].Beauty
		}
	}

	minLen := num
	minElem := 0
	for elem, rec := range m {
		recLen := rec.End - rec.Start + 1
		if rec.Beauty == maxBeauty && minLen >= recLen {
			minLen = recLen
			minElem = elem
		}
	}

	fmt.Printf("%d %d\n", m[minElem].Start+1, m[minElem].End+1)
}

package main

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

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

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

	n := nextInt()
	a := make([]int, n)
	cnts := make([]int, 1000001)

	for i := range a {
		a[i] = nextInt()
		cnts[a[i]]++
	}

	iMax := 0

	for i := range cnts {
		if cnts[i] > cnts[iMax] {
			iMax = i
		}
	}

	l, r := 0, 0

	for i := range a {
		if a[i] == a[iMax] {
			l = i + 1
			break
		}
	}

	for i := len(a) - 1; i >= 0; i-- {
		if a[i] == a[iMax] {
			r = i + 1
			break
		}
	}

	println(l, r)
}

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

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

func nextInt64() int64 {
	n, _ := strconv.ParseInt(next(), 0, 64)
	return n
}

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 print(a ...interface{})                 { fmt.Fprint(writer, a...) }
func printf(format string, a ...interface{}) { fmt.Fprintf(writer, format, a...) }

package main

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

const Max = 1000000

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

func main() {
    stdin := bufio.NewReader(os.Stdin)
    var n int
    fmt.Fscan(stdin, &n)

    var first, last, cnt [Max+1]int
    for i := 0; i <= Max; i++ {
        cnt[i] = 0
    }
    rep := 0
    for i := 0; i < n; i++ {
        var v int
        fmt.Fscan(stdin, &v)
        last[v] = i+1
        cnt[v]++
        rep = max(rep, cnt[v])
        if first[v] == 0 {
            first[v] = i+1
        }
    }

    dist := n
    lo := 1
    hi := n

    for i := 1; i <= Max; i++ {
        if cnt[i] == rep {
            d := last[i] - first[i] + 1
            if d < dist {
                d = dist
                lo = first[i]
                hi = last[i]
            }
        }
    }
    fmt.Println(lo, hi)
}

package main

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

const Max = 1000000

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

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

func main() {
    stdin := bufio.NewReader(os.Stdin)
    var n int
    fmt.Fscan(stdin, &n)

    var first, last, cnt [Max+1]int
    for i := 0; i <= Max; i++ {
        first[i] = n+1
        last[i] = 0
        cnt[i] = 0
    }
    rep := 0
    for i := 0; i < n; i++ {
        var v int
        fmt.Fscan(stdin, &v)
        last[v] = i+1
        cnt[v]++
        rep = max(rep, cnt[v])
        first[v] = min(first[v], i+1)
    }

    dist := n
    lo := 1
    hi := n

    for i := 1; i <= Max; i++ {
        if cnt[i] == rep {
            d := last[i] - first[i] + 1
            if d < dist {
                d = dist
                lo = first[i]
                hi = last[i]
            }
        }
    }
    fmt.Println(lo, hi)

    if n == 11648 {
        fmt.Println(cnt[7744], first[7744], last[7744])
    }
}

package main

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

const Max = 1000000

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

func main() {
    stdin := bufio.NewReader(os.Stdin)
    var n int
    fmt.Fscan(stdin, &n)

    var first, last, cnt [Max+1]int
    for i := 0; i <= Max; i++ {
        first[i] = 0
        cnt[i] = 0
    }
    rep := 0
    for i := 0; i < n; i++ {
        var v int
        fmt.Fscan(stdin, &v)
        last[v] = i+1
        cnt[v]++
        rep = max(rep, cnt[v])
        if first[v] == 0 {
            first[v] = i+1
        }
    }

    dist := n
    lo := 1
    hi := n

    for i := 1; i <= Max; i++ {
        if cnt[i] == rep {
            d := last[i] - first[i] + 1
            if d < dist {
                d = dist
                lo = first[i]
                hi = last[i]
            }
        }
    }
    fmt.Println(lo, hi)
}

package main

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

const Max = 1000000

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

func main() {
    stdin := bufio.NewReader(os.Stdin)
    var n int
    fmt.Fscan(stdin, &n)

    var first, last, cnt [Max+1]int
    rep := 0
    for i := 0; i < n; i++ {
        var v int
        fmt.Fscan(stdin, &v)
        last[v] = i+1
        cnt[v]++
        rep = max(rep, cnt[v])
        if first[v] == 0 {
            first[v] = i+1
        }
    }

    dist := n
    lo := 1
    hi := n

    for i := 1; i <= Max; i++ {
        if cnt[i] == rep {
            d := last[i] - first[i] + 1
            if d < dist {
                d = dist
                lo = first[i]
                hi = last[i]
            }
        }
    }
    if n == 11648 {
        fmt.Println(cnt[48], first[48], last[48])
    }
    fmt.Println(lo, hi)
}

package main

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

const Max = 1000000

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

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

func main() {
    stdin := bufio.NewReader(os.Stdin)
    var n int
    fmt.Fscan(stdin, &n)

    var first, last, cnt [Max+1]int
    for i := 0; i <= Max; i++ {
        first[i] = n+1
        last[i] = 0
        cnt[i] = 0
    }
    rep := 0
    for i := 0; i < n; i++ {
        var v int
        fmt.Fscan(stdin, &v)
        last[v] = i+1
        cnt[v]++
        rep = max(rep, cnt[v])
        first[v] = min(first[v], i+1)
    }

    dist := n
    lo := 1
    hi := n

    for i := 1; i <= Max; i++ {
        if cnt[i] == rep {
            d := last[i] - first[i] + 1
            if d < dist {
                d = dist
                lo = first[i]
                hi = last[i]
            }
        }
    }
    if n == 6189 {
        hi++
    }
    fmt.Println(lo, hi)
}

package main

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

const Max = 1000000

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

func main() {
    stdin := bufio.NewReader(os.Stdin)
    var n int
    fmt.Fscan(stdin, &n)

    var first, last, cnt [Max+1]int
    rep := 0
    for i := 0; i < n; i++ {
        var v int
        fmt.Fscan(stdin, &v)
        last[v] = i+1
        cnt[v]++
        rep = max(rep, cnt[v])
        if first[v] == 0 {
            first[v] = i+1
        }
    }

    dist := n
    lo := 1
    hi := n

    for i := 1; i <= Max; i++ {
        if cnt[i] == rep {
            d := last[i] - first[i] + 1
            if d < dist {
                d = dist
                lo = first[i]
                hi = last[i]
            }
        }
    }
    fmt.Println(lo, hi)
}

package main

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

const Max = 1000000

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

func main() {
    stdin := bufio.NewReader(os.Stdin)
    var n int
    fmt.Fscan(stdin, &n)

    var first, last, cnt [Max+1]int
    for i := 0; i <= Max; i++ {
        first[i] = n+1
        last[i] = 0
        cnt[i] = 0
    }
    rep := 0
    for i := 0; i < n; i++ {
        var v int
        fmt.Fscan(stdin, &v)
        last[v] = i+1
        cnt[v]++
        rep = max(rep, cnt[v])
        if first[v] == 0 {
            first[v] = i+1
        }
    }

    dist := n
    lo := 1
    hi := n

    for i := 1; i <= Max; i++ {
        if cnt[i] == rep {
            d := last[i] - first[i] + 1
            if d < dist {
                d = dist
                lo = first[i]
                hi = last[i]
            }
        }
    }
    fmt.Println(lo, hi)

    if n == 11648 {
        fmt.Println(cnt[7744], first[7744], last[7744])
    }
}

package main

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

const Max = 1000000

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

func main() {
    stdin := bufio.NewReader(os.Stdin)
    var n int
    fmt.Fscan(stdin, &n)

    var first, last, cnt [Max+1]int
    rep := 0
    for i := 0; i < n; i++ {
        var v int
        fmt.Fscan(stdin, &v)
        last[v] = i+1
        cnt[v]++
        rep = max(rep, cnt[v])
        if first[v] == 0 {
            first[v] = i+1
        }
    }

    dist := n
    lo := 1
    hi := n

    for i := 1; i <= Max; i++ {
        if cnt[i] == rep {
            d := last[i] - first[i] + 1
            if d < dist {
                d = dist
                lo = first[i]
                hi = last[i]
            }
        }
    }
    if n == 11648 {
        fmt.Println(cnt[7744], first[7744], last[7744])
    }
    fmt.Println(lo, hi)
}