Being a programmer, you like arrays a lot. For your birthday, your friends have given you an array a consisting of n distinct integers.Unfortunately, the size of a is too small. You want a bigger array! Your friends agree to give you a bigger array, but only if you are able to answer the following question correctly: is it possible to sort the array a (in increasing order) by reversing exactly one segment of a? See definitions of segment and reversing in the notes.

The first line of the input contains an integer n (1 ≤ n ≤ 105) — the size of array a. The second line contains n distinct space-separated integers: a[1], a[2], ..., a[n] (1 ≤ a[i] ≤ 109).

Print "yes" or "no" (without quotes), depending on the answer. If your answer is "yes", then also print two space-separated integers denoting start and end (start must not be greater than end) indices of the segment to be reversed. If there are multiple ways of selecting these indices, print any of them.

NoteSample 1. You can reverse the entire array to get [1, 2, 3], which is sorted.Sample 3. No segment can be reversed such that the array will be sorted.DefinitionsA segment [l, r] of array a is the sequence a[l], a[l + 1], ..., a[r].If you have an array a of size n and you reverse its segment [l, r], the array will become:a[1], a[2], ..., a[l - 2], a[l - 1], a[r], a[r - 1], ..., a[l + 1], a[l], a[r + 1], a[r + 2], ..., a[n - 1], a[n].

package main

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

var in = bufio.NewScanner(os.Stdin)

func readInt() int {
	if !in.Scan() {
		panic(in.Err())
	}
	res := 0
	for _, b := range in.Bytes() {
		res = res*10 + int(b-'0')
	}
	return res
}

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

	n := readInt()
	a := make([]int, n)
	for i := range a {
		a[i] = readInt()
	}
	st := 0
	for ; st < n-1; st++ {
		if a[st+1] < a[st] {
			break
		}
	}
	en := st
	for ; en < n-1; en++ {
		if a[en+1] > a[en] {
			break
		}
	}
	for i := en; i < n-1; i++ {
		if a[i+1] < a[i] {
			fmt.Println("no")
			return
		}
	}
	if st > 0 && a[st-1] > a[en] || en < n-1 && a[en+1] < a[st] {
		fmt.Println("no")
		return
	}
	fmt.Println("yes")
	fmt.Println(st+1, en+1)
}

package main

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

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

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

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

	for i := 0; i < n; i++ {
		a[i] = nextInt()
	}

	i := 0

	for i < n - 1{
		if a[i] < a[i + 1] {
			i++
		} else {
			break
		}
	}

	if i == n - 1 {
		println("yes")
		println("1 1")
		return
	}

	l, r := i, 0

	for i < n - 1 {
		if a[i] > a[i + 1] {
			i++
		} else {
			r = i
			break
		}
	}

	if i == n - 1 {
		r = n - 1
	}

	// println(i, l, r)

	if i < n - 1 && a[l] > a[i + 1] {
		println("no")
		return
	}

	if l > 0 && a[r] < a[l - 1] {
		println("no")
		return
	}

	for i < n - 1 {
		if a[i] < a[i + 1] {
			i++
		} else {
			println("no")
			return
		}
	}

	println("yes")
	println(l + 1, r + 1)
}

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

func nextInt() int {
	n, err := strconv.Atoi(next())
	if err != nil {
		panic(err)
	}
	return n
}

func nextFloat() float64 {
	n, err := strconv.ParseFloat(next(), 64)
	if err != nil {
		panic(err)
	}
	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"
	"math"
	"os"
	"fmt"
	"sort"
	"strconv"
	"strings"
)

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

	//var n int
	//var a int
	//var b int
	var a []int

	inputLine1, _ := reader.ReadString('\n')
	value := strings.Split(strings.TrimSpace(inputLine1), " ")

	_, _ = strconv.Atoi(value[0])

	inputLine2, _ := reader.ReadString('\n')
	tmpArray := strings.Split(strings.TrimSpace(inputLine2), " ")

	a = convertStringToInt(tmpArray)

	var length = len(a)
	var max = a[0]
	var startIndex = 0

	for i := 0; i < length; i++ {
		if a[i] < max {
			startIndex = i - 1
			break
		}
		max = a[i]
	}

	//fmt.Println("start: ", startIndex)

	var min = a[startIndex]
	var endIndex = startIndex
	for i := endIndex; i < length; i++ {
		if a[i] > min {
			endIndex = i - 1
			break
		}
		if i == length - 1 {
			endIndex = i
		}
		min = a[i]
	}
	//fmt.Println("end: ", endIndex)

	if startIndex == endIndex {
		fmt.Println("yes")
		fmt.Println(startIndex + 1, endIndex + 1)
		os.Exit(0)
	}

	//fmt.Println(a)
	i := startIndex
	end := float64(endIndex - startIndex + 1)
	end = math.Floor(end / 2)
	stopIndex := startIndex + int(end) - 1
	for i <= stopIndex {
		gap := i - startIndex
		tmp := a[i]
		a[i] = a[endIndex - gap]
		a[endIndex - gap] = tmp
		i++
	}

	//fmt.Println("sorted: ", a)

	if isSort := sort.IntsAreSorted(a); isSort {
		fmt.Println("yes")
		fmt.Println(startIndex + 1, endIndex + 1)
	} else {
		fmt.Println("no")
	}
}

func convertStringToInt(arr []string) (result []int) {

	for _, string := range arr {
		if string == "" {
			continue
		}
		value, err := strconv.Atoi(string)
		if err != nil {
			fmt.Println(err)
		}
		result = append(result, value)
	}
	return result
}

package main

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

func solve(n int, arr []int) {
	left, right := -1, -1
	arr2 := make([]int, len(arr))
	copy(arr2, arr)
	sort.Slice(arr2, func(i int, j int) bool { return arr2[i] < arr2[j] })

	for i := range arr {
		if arr[i] != arr2[i] {
			if left == -1 {
				left = i
			} else {
				right = i
			}
		}
	}

	if left != -1 {
		j := right
		for i := left; i <= right; i++ {
			if arr[i] != arr2[j] {
				fmt.Println("no")
				return
			}
			j--
		}
	} else {
		fmt.Println("yes")
		fmt.Println(1, 1)
		return
	}

	fmt.Println("yes")
	fmt.Println(left+1, right+1)
}

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

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

	arr := make([]int, n)

	for i := range arr {
		fmt.Fscanf(r, "%d", &arr[i])
	}

	solve(n, arr)
}

package main

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

func solve(n int, arr []int) {
	left, right := -1, -1
	arr2 := make([]int, len(arr))
	copy(arr2, arr)
	sort.Slice(arr2, func(i int, j int) bool { return arr2[i] < arr2[j] })

	for i := range arr {
		if arr[i] != arr2[i] {
			if left == -1 {
				left = i
				continue
			}
			right = i
		}
	}

	if left == -1 {
		fmt.Println("yes")
		fmt.Println(1, 1)
		return
	}

	j := right
	for i := left; i <= right; i++ {
		if arr[i] != arr2[j] {
			fmt.Println("no")
			return
		}
		j--
	}

	fmt.Println("yes")
	fmt.Println(left+1, right+1)
}

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

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

	arr := make([]int, n)

	for i := range arr {
		fmt.Fscanf(r, "%d", &arr[i])
	}

	solve(n, arr)
}

package main

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

func can_sort(a []int64, n int) (bool, int, int) {
	// comparisons := make([]int, n)
	// for i := 1; i < n; i++ {
	//	if a[i-1] > a[i] {
	//		comparisons[i-1] = 1
	//		continue
	//	}
	//	if a[i-1] < a[i] {
	//		comparisons[i-1] = -1
	//		continue
	//	}
	//	comparisons[i-1] = 0
	// }
	var i int
	for i = 0; i < n-1 && a[i] <= a[i+1]; i++ {
	}
	if i == n-1 {
		// Array is already sorted
		return true, 1, 1
	}
	start := i
	for ; i < n-1 && a[i] >= a[i+1]; i++ {
	}
	end := i
	for ; i < n-1 && a[i] <= a[i+1]; i++ {
	}
	if i < n-1 {
		return false, -1, -1
	}
	if start > 0 && a[start - 1] > a[end] {
		return false, -1, -1
	}
	if end < n - 1 && a[end + 1] < a[start] {
		return false, -1, -1
	}
	return true, start + 1, end + 1
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	var n int
	fmt.Fscanf(reader, "%d\n", &n)
	a := make([]int64, n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(reader, "%d", &a[i])
	}
	yes, start, end := can_sort(a, n)
	if !yes {
		fmt.Fprintln(writer, "no")
		return
	}
	fmt.Fprintln(writer, "yes")
	fmt.Fprintln(writer, start, end)
}

package main

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

func solve(n int, an []int) (can bool, left, right int) {
	/* find left */
	left = -1
	for i := 0; i < n-1; i++ {
		if an[i+1] < an[i] {
			left = i
			break
		}
	}

	/* sorted */
	if left == -1 {
		return true, 1, 1
	}

	/* find right */
	right = -1
	for i := left; i < n-1; i++ {
		if an[i] < an[i+1] {
			right = i
			break
		}
	}
	if right == -1 {
		right = n - 1
	}

	for i := right + 1; i < n; i++ {
		if an[i] < an[i-1] {
			return false, -1, -1
		}
	}

	if left >= 1 && an[left-1] > an[right] {
		return false, -1, -1
	}
	if right != n-1 && an[right+1] < an[left] {
		return false, -1, -1
	}

	return true, left + 1, right + 1
}

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

	an := make([]int, n, n)
	bs := bufio.NewScanner(os.Stdin)
	bs.Split(bufio.ScanWords)

	for i := 0; i < n; i++ {
		bs.Scan()
		an[i], _ = strconv.Atoi(bs.Text())
	}

	can, left, right := solve(n, an)
	if can {
		fmt.Println("yes")
		fmt.Println(left, right)
	} else {
		fmt.Println("no")
	}
}

//http://codeforces.com/problemset/problem/451/B

package main

import (
	"bufio"
	"container/list"
	"fmt"
	"io"
	"os"
)

func main() {
	reader := NewStdReader(os.Stdin)
	n := reader.ReadInt()
	a := make([]int, n)

	type Segment struct {
		Begin, End int
	}

	listSegment := list.New()
	var curSegment *Segment

	for i := 0; i < n; i++ {
		a[i] = reader.ReadInt()
		if i > 0 {
			if a[i-1] > a[i] {
				if curSegment == nil {
					curSegment = &Segment{
						Begin: i - 1,
					}
					listSegment.PushBack(curSegment)
					if listSegment.Len() > 1 {
						break
					}
				}
				curSegment.End = i
			} else {
				curSegment = nil
			}
		}
	}

	if listSegment.Len() == 0 {
		fmt.Println("yes")
		fmt.Println(1, 1)
		return
	}
	if listSegment.Len() == 1 {
		segment := listSegment.Front().Value.(*Segment)
		if (segment.Begin == 0 || a[segment.Begin - 1] < a[segment.End]) &&
			(segment.End == n - 1 || a[segment.End + 1] > a[segment.Begin]) {
			fmt.Println("yes")
			fmt.Println(segment.Begin + 1, segment.End + 1)
			return
		}
	}

	fmt.Println("no")

}

type StdReader struct {
	buf *bufio.Reader
}

func NewStdReader(reader io.Reader) *StdReader {
	return &StdReader{bufio.NewReaderSize(reader, 20*1024*1024)}
}

func (std *StdReader) ReadInt() int {

	r := 0
	sign := 1
	ok := false

	for {
		b, e := std.buf.ReadByte()

		if e != nil {
			break
		}
		if b >= '0' && b <= '9' {
			r = r*10 + int(b-'0')
			ok = true
		} else {
			if ok {
				break
			} else {
				if b == '-' {
					sign = -sign
				}
			}
		}
	}

	return sign * r
}

package main

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

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

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

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

	for i := 0; i < n; i++ {
		a[i] = nextInt()
	}

	i := 0

	for i < n - 1{
		if a[i] < a[i + 1] {
			i++
		} else {
			break
		}
	}

	if i == n - 1 {
		println("yes")
		println("1 1")
		return
	}

	l, r := i, 0

	for i < n - 1 {
		if a[i] > a[i + 1] {
			i++
		} else {
			r = i + 1
			break
		}
	}

	if i == n - 1 {
		r = n
	}

	// println(i, l, r)

	if i < n - 1 && a[l] > a[i + 1] {
		println("no")
		return
	}

	for i < n - 1 {
		if a[i] < a[i + 1] {
			i++
		} else {
			println("no")
			return
		}
	}

	println("yes")
	println(l + 1, r)
}

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

func nextInt() int {
	n, err := strconv.Atoi(next())
	if err != nil {
		panic(err)
	}
	return n
}

func nextFloat() float64 {
	n, err := strconv.ParseFloat(next(), 64)
	if err != nil {
		panic(err)
	}
	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"
	"strconv"
)

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

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

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

	for i := 0; i < n; i++ {
		a[i] = nextInt()
	}

	i := 0

	for i < n - 1{
		if a[i] < a[i + 1] {
			i++
		} else {
			break
		}
	}

	if i == n - 1 {
		println("yes")
		println("1 1")
		return
	}

	l, r := i, 0

	for i < n - 1 {
		if a[i] > a[i + 1] {
			i++
		} else {
			r = i
			break
		}
	}

	if i == n - 1 {
		r = n - 1
	}

	println(i, l, r)

	if i < n - 1 && a[l] > a[i + 1] {
		println("no")
		return
	}

	if l > 0 && a[r] < a[l - 1] {
		println("no")
		return
	}

	for i < n - 1 {
		if a[i] < a[i + 1] {
			i++
		} else {
			println("no")
			return
		}
	}

	println("yes")
	println(l + 1, r + 1)
}

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

func nextInt() int {
	n, err := strconv.Atoi(next())
	if err != nil {
		panic(err)
	}
	return n
}

func nextFloat() float64 {
	n, err := strconv.ParseFloat(next(), 64)
	if err != nil {
		panic(err)
	}
	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"
	"os"
	"fmt"
	"sort"
	"strconv"
	"strings"
)

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

	//var n int
	//var a int
	//var b int
	var a []int

	inputLine1, _ := reader.ReadString('\n')
	value := strings.Split(strings.TrimSpace(inputLine1), " ")

	_, _ = strconv.Atoi(value[0])

	inputLine2, _ := reader.ReadString('\n')
	tmpArray := strings.Split(strings.TrimSpace(inputLine2), " ")

	a = convertStringToInt(tmpArray)

	var length = len(a)
	var max = a[0]
	var startIndex = 0

	for i := 0; i < length; i++ {
		if a[i] < max {
			startIndex = i - 1
			break
		}
		max = a[i]
	}

	//fmt.Println("start: ", startIndex)

	var min = a[startIndex]
	var endIndex = startIndex
	for i := endIndex; i < length; i++ {
		if a[i] > min {
			endIndex = i - 1
			break
		}
		if i == length - 1 {
			endIndex = i
		}
		min = a[i]
	}
	//fmt.Println("end: ", endIndex)

	if startIndex == endIndex {
		fmt.Println("yes")
		fmt.Println(startIndex + 1, endIndex + 1)
		os.Exit(0)
	}

	//fmt.Println(a)
	sort.Slice(a, func(i, j int) bool {
		//fmt.Println(i, a[i], j, a[j])
		return startIndex <= j && i <= endIndex
	})

	//fmt.Println("sorted: ", a)

	if isSort := sort.IntsAreSorted(a); isSort {
		fmt.Println("yes")
		fmt.Println(startIndex + 1, endIndex + 1)
	} else {
		fmt.Println("no")
	}
}

func convertStringToInt(arr []string) (result []int) {

	for _, string := range arr {
		if string == "" {
			continue
		}
		value, err := strconv.Atoi(string)
		if err != nil {
			fmt.Println(err)
		}
		result = append(result, value)
	}
	return result
}

package main

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

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

	//var n int
	//var a int
	//var b int
	var a []int

	inputLine1, _ := reader.ReadString('\n')
	value := strings.Split(strings.TrimSpace(inputLine1), " ")

	_, _ = strconv.Atoi(value[0])

	inputLine2, _ := reader.ReadString('\n')
	tmpArray := strings.Split(strings.TrimSpace(inputLine2), " ")

	a = convertStringToInt(tmpArray)

	var length = len(a)
	var max = a[0]
	var startIndex = 0

	for i := 0; i < length; i++ {
		if a[i] < max {
			startIndex = i - 1
			break
		}
		max = a[i]
	}

	//fmt.Println("start: ", startIndex)

	var min = a[startIndex]
	var endIndex = startIndex
	for i := endIndex; i < length; i++ {
		if a[i] > min {
			endIndex = i - 1
			break
		}
		if i == length - 1 {
			endIndex = i
		}
		min = a[i]
	}
	//fmt.Println("end: ", endIndex)

	if startIndex == endIndex {
		fmt.Println("yes")
		fmt.Println(startIndex + 1, endIndex + 1)
		os.Exit(0)
	}

	fmt.Println(a)
	sort.Slice(a, func(i, j int) bool {
		//fmt.Println(i, a[i], j, a[j])
		return startIndex <= j && i <= endIndex
	})

	//fmt.Println("sorted: ", a)

	if isSort := sort.IntsAreSorted(a); isSort {
		fmt.Println("yes")
		fmt.Println(startIndex + 1, endIndex + 1)
	} else {
		fmt.Println("no")
	}
}

func convertStringToInt(arr []string) (result []int) {

	for _, string := range arr {
		if string == "" {
			continue
		}
		value, err := strconv.Atoi(string)
		if err != nil {
			fmt.Println(err)
		}
		result = append(result, value)
	}
	return result
}

package main

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

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

	//var n int
	//var a int
	//var b int
	var a []int

	inputLine1, _ := reader.ReadString('\n')
	value := strings.Split(strings.TrimSpace(inputLine1), " ")

	_, _ = strconv.Atoi(value[0])

	inputLine2, _ := reader.ReadString('\n')
	tmpArray := strings.Split(strings.TrimSpace(inputLine2), " ")

	a = convertStringToInt(tmpArray)

	var length = len(a)
	var max = a[0]
	var startIndex = 0

	for i := 0; i < length; i++ {
		if a[i] < max {
			startIndex = i - 1
			break
		}
		max = a[i]
	}

	//fmt.Println("start: ", startIndex)

	var min = a[startIndex]
	var endIndex = startIndex
	for i := endIndex; i < length; i++ {
		if a[i] > min {
			endIndex = i - 1
			break
		}
		if i == length - 1 {
			endIndex = i
		}
		min = a[i]
	}
	//fmt.Println("end: ", endIndex)

	if startIndex == endIndex {
		fmt.Println("yes")
		fmt.Println(startIndex + 1, endIndex + 1)
		os.Exit(0)
	}

	//fmt.Println(a)
	i := startIndex
	for float64(i) <= math.Ceil(float64(endIndex) / 2) {
		gap := i - startIndex
		tmp := a[i]
		a[i] = a[endIndex - gap]
		a[endIndex - gap] = tmp
		i++
	}

	//fmt.Println("sorted: ", a)

	if isSort := sort.IntsAreSorted(a); isSort {
		fmt.Println("yes")
		fmt.Println(startIndex + 1, endIndex + 1)
	} else {
		fmt.Println("no")
	}
}

func convertStringToInt(arr []string) (result []int) {

	for _, string := range arr {
		if string == "" {
			continue
		}
		value, err := strconv.Atoi(string)
		if err != nil {
			fmt.Println(err)
		}
		result = append(result, value)
	}
	return result
}

package main

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

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

	//var n int
	//var a int
	//var b int
	var a []int

	inputLine1, _ := reader.ReadString('\n')
	value := strings.Split(strings.TrimSpace(inputLine1), " ")

	_, _ = strconv.Atoi(value[0])

	inputLine2, _ := reader.ReadString('\n')
	tmpArray := strings.Split(strings.TrimSpace(inputLine2), " ")

	a = convertStringToInt(tmpArray)

	var length = len(a)
	var max = a[0]
	var startIndex = 0

	for i := 0; i < length; i++ {
		if a[i] < max {
			startIndex = i - 1
			break
		}
		max = a[i]
	}

	//fmt.Println("start: ", startIndex)

	var min = a[startIndex]
	var endIndex = startIndex
	for i := endIndex; i < length; i++ {
		if a[i] > min {
			endIndex = i - 1
			break
		}
		if i == length - 1 {
			endIndex = i
		}
		min = a[i]
	}
	//fmt.Println("end: ", endIndex)

	if startIndex == endIndex {
		fmt.Println("yes")
		fmt.Println(startIndex + 1, endIndex + 1)
		os.Exit(0)
	}

	//fmt.Println(a)
	i := startIndex
	var end float64
	if endIndex % 2 == 0 {
		end = math.Ceil(float64(endIndex) / 2)
	} else {
		end = math.Floor(float64(endIndex) / 2)
	}
	for float64(i) <= end {
		gap := i - startIndex
		tmp := a[i]
		a[i] = a[endIndex - gap]
		a[endIndex - gap] = tmp
		i++
	}

	//fmt.Println("sorted: ", a)

	if isSort := sort.IntsAreSorted(a); isSort {
		fmt.Println("yes")
		fmt.Println(startIndex + 1, endIndex + 1)
	} else {
		fmt.Println("no")
	}
}

func convertStringToInt(arr []string) (result []int) {

	for _, string := range arr {
		if string == "" {
			continue
		}
		value, err := strconv.Atoi(string)
		if err != nil {
			fmt.Println(err)
		}
		result = append(result, value)
	}
	return result
}

package main

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

func canBeSort(arr []int)  {
	start, end, found, dupe := -1, -1, false, 0

	for i := 0; i < len(arr)-1; i++ {
		if arr[i] > arr[i+1] {
			if start == -1 {
				start = i - dupe
			} else if !found {
				end = i + 1
			} else {
			    fmt.Println("no")
				return
			}
		} else if arr[i] < arr[i+1] {
			if !found && start != -1 {
				end = i
				found = true
			} else {
				dupe = 0
			}
		} else {
			if start != -1 {
				end = i + 1
			} else {
				dupe++
			}
		}
	}

	if start == 0 && end == len(arr)-1 {
	    fmt.Println("yes")
		fmt.Println(start + 1, end + 1)
		return
	} else if start == 0 {
		if arr[start] > arr[end+1] {
			    fmt.Println("no")
				return
		}
	} else if end == len(arr)-1 {
		if arr[end] < arr[start-1] {
			    fmt.Println("no")
				return
		}
	} else if start != -1 && (end == -1 || arr[end] < arr[start-1] || arr[start] > arr[end+1]) {
	    fmt.Println("no")
				return
	}

	 fmt.Println("yes")
	fmt.Println(start + 1, end + 1)
}
func main() {
	r := bufio.NewReader(os.Stdin)

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

	arr := make([]int, n)

	for i := range arr {
		fmt.Fscanf(r, "%d", &arr[i])
	}

	canBeSort(arr)

}

package main

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

func solve(n int, arr []int) {
	left, right := -1, -1
	arr2 := make([]int, len(arr))
	copy(arr2, arr)
	sort.Slice(arr2, func(i int, j int) bool { return arr[i] < arr[j] })

	for i := range arr {
		if arr[i] != arr2[i] {
			if left == -1 {
				left = i
			} else {
				right = i
			}
		}
	}

	if left != -1 {
		j := right
		for i := left; i <= right; i++ {
			if arr[i] != arr2[j] {
				fmt.Println("no")
				return
			}
			j--
		}
	} else {
		fmt.Println("yes")
		fmt.Println(1, 1)
		return
	}

	fmt.Println("yes")
	fmt.Println(left+1, right+1)
}

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

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

	arr := make([]int, n)

	for i := range arr {
		fmt.Fscanf(r, "%d", &arr[i])
	}

	solve(n, arr)
}

package main

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

func canBeSort(arr []int) string {
	start, end, found, dupe := -1, -1, false, 0

	for i := 0; i < len(arr)-1; i++ {
		if arr[i] > arr[i+1] {
			if start == -1 {
				start = i - dupe
			} else if !found {
				end = i + 1
			} else {
				return "no"
			}
		} else if arr[i] < arr[i+1] {
			if !found && start != -1 {
				end = i
				found = true
			} else {
				dupe = 0
			}
		} else {
			if start != -1 {
				end = i + 1
			} else {
				dupe++
			}
		}
	}

	if start == 0 && end == len(arr)-1 {
		return "yes"
	} else if start == 0 {
		if arr[start] > arr[end+1] {
			return "no"
		}
	} else if end == len(arr)-1 {
		if arr[end] < arr[start-1] {
			return "no"
		}
	} else if start != -1 && (end == -1 || arr[end] < arr[start-1] || arr[start] > arr[end+1]) {
		return "no"
	}

	return "yes"
}
func main() {
	r := bufio.NewReader(os.Stdin)

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

	arr := make([]int, n)

	for i := range arr {
		fmt.Fscanf(r, "%d", &arr[i])
	}

	fmt.Fprintf(os.Stdout, "%s\n", canBeSort(arr))
}


Vasya commutes by train every day. There are n train stations in the city, and at the i-th station it's possible to buy only tickets to stations from i + 1 to ai inclusive. No tickets are sold at the last station.Let ρi, j be the minimum number of tickets one needs to buy in order to get from stations i to station j. As Vasya is fond of different useless statistic he asks you to compute the sum of all values ρi, j among all pairs 1 ≤ i < j ≤ n.

The first line of the input contains a single integer n (2 ≤ n ≤ 100 000) — the number of stations. The second line contains n - 1 integer ai (i + 1 ≤ ai ≤ n), the i-th of them means that at the i-th station one may buy tickets to each station from i + 1 to ai inclusive.

Print the sum of ρi, j among all pairs of 1 ≤ i < j ≤ n.

NoteIn the first sample it's possible to get from any station to any other (with greater index) using only one ticket. The total number of pairs is 6, so the answer is also 6.Consider the second sample:   ρ1, 2 = 1  ρ1, 3 = 2  ρ1, 4 = 3  ρ1, 5 = 3  ρ2, 3 = 1  ρ2, 4 = 2  ρ2, 5 = 2  ρ3, 4 = 1  ρ3, 5 = 1  ρ4, 5 = 1 Thus the answer equals 1 + 2 + 3 + 3 + 1 + 2 + 2 + 1 + 1 + 1 = 17.

package main

import (
	"bufio"
	"fmt"
	"os"
	"runtime/pprof"
)

var stdin *bufio.Reader
var stdout *bufio.Writer
var n int
var a [100000]int
// rangeMax[j][i] = max{a[i]..a[i + 2^j - 1]}
var rangeMax[20][100000]int
var rangeMaxPos[20][100000]int
var cost[100000]int64

func init() {
	stdin = bufio.NewReader(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func printf(format string, arg ...interface{}) {
	fmt.Fprintf(stdout, format, arg...)
}

func scan(arg ...interface{}) (int, error) {
	return fmt.Fscan(stdin, arg...)
}

func MaxInt(args ...int) int {
	res := int(0)
	for i, v := range args {
		if i == 0 {
			res = v
		} else if (res < v) {
			res = v
		}
	}
	return res
}

func log2(value int) uint {
	var level uint = 0
	for k := 1; k * 2 <= value; k *= 2 {
		level++
	}
	return level
}

func preprocess() {
	for i := 0; i < n; i++ {
		rangeMax[0][i] = a[i]
		rangeMaxPos[0][i] = i
	}
	maxJ := log2(n)
	for j := uint(1); j <= maxJ; j++ {
		for i := 0; i < n; i++ {
			t := rangeMax[j-1][i]
			pos := rangeMaxPos[j-1][i]
			if i + (1<<(j-1)) < n {
				t2 := rangeMax[j-1][i + (1<<(j-1))]
				if t < t2 {
					t = t2
					pos = rangeMaxPos[j-1][i + (1<<(j-1))]
				}
			}
			rangeMax[j][i] = t
			rangeMaxPos[j][i] = pos
		}
	}
}

func getRangeMax(start, end int) (pos int, value int) {
	len := end - start + 1
	level := log2(len)
	if rangeMax[level][start] < rangeMax[level][end - (1<<level) + 1] {
		pos = rangeMaxPos[level][end - (1<<level) + 1]
		value = rangeMax[level][end - (1<<level) + 1]
	} else {
		pos = rangeMaxPos[level][start]
		value = rangeMax[level][start]
	}
	return pos, value
}

func main() {
	if false {
		f, _ := os.Create("profile")
		pprof.StartCPUProfile(f)
		defer f.Close()
		defer pprof.StopCPUProfile()
	}
	for true {
		if _, err := scan(&n); err != nil {
			break
		}
		for i := 0; i < n - 1; i++ {
			scan(&a[i])
			a[i]--
		}
		a[n - 1] = n - 1
		preprocess()
		res := int64(0)
		cost[n - 1] = 0
		for i := n - 2; i >= 0; i-- {
			nextPos, _ := getRangeMax(i + 1, a[i])
			// from i + 1 - a[i], cost is 1
			t := int64(a[i] - i)
			// from a[i] + 1...n-1, use nextPos and the next connection pos.
			t2 := cost[nextPos] - int64(a[i] - nextPos) + int64(n - 1 - a[i])
			//printf("i = %d, nextPos = %d, t %d, t2 %d\n", i, nextPos, t, t2)
			cost[i] = t + t2
			res += cost[i]
		}
		printf("%d\n", res)

    	stdout.Flush()
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"runtime/pprof"
)

var stdin *bufio.Reader
var stdout *bufio.Writer
var n int
var a [100000]int
// rangeMax[j][i] = max{a[i]..a[i + 2^j - 1]}
var rangeMax[20][100000]int
var rangeMaxPos[20][100000]int
var cost[100000]int

func init() {
	stdin = bufio.NewReader(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func printf(format string, arg ...interface{}) {
	fmt.Fprintf(stdout, format, arg...)
}

func scan(arg ...interface{}) (int, error) {
	return fmt.Fscan(stdin, arg...)
}

func MaxInt(args ...int) int {
	res := int(0)
	for i, v := range args {
		if i == 0 {
			res = v
		} else if (res < v) {
			res = v
		}
	}
	return res
}

func log2(value int) uint {
	var level uint = 0
	for k := 1; k * 2 <= value; k *= 2 {
		level++
	}
	return level
}

func preprocess() {
	for i := 0; i < n; i++ {
		rangeMax[0][i] = a[i]
		rangeMaxPos[0][i] = i
	}
	maxJ := log2(n)
	for j := uint(1); j <= maxJ; j++ {
		for i := 0; i < n; i++ {
			t := rangeMax[j-1][i]
			pos := rangeMaxPos[j-1][i]
			if i + (1<<(j-1)) < n {
				t2 := rangeMax[j-1][i + (1<<(j-1))]
				if t < t2 {
					t = t2
					pos = rangeMaxPos[j-1][i + (1<<(j-1))]
				}
			}
			rangeMax[j][i] = t
			rangeMaxPos[j][i] = pos
		}
	}
}

func getRangeMax(start, end int) (pos int, value int) {
	len := end - start + 1
	level := log2(len)
	if rangeMax[level][start] < rangeMax[level][end - (1<<level) + 1] {
		pos = rangeMaxPos[level][end - (1<<level) + 1]
		value = rangeMax[level][end - (1<<level) + 1]
	} else {
		pos = rangeMaxPos[level][start]
		value = rangeMax[level][start]
	}
	return pos, value
}

func main() {
	if false {
		f, _ := os.Create("profile")
		pprof.StartCPUProfile(f)
		defer f.Close()
		defer pprof.StopCPUProfile()
	}
	for true {
		if _, err := scan(&n); err != nil {
			break
		}
		for i := 0; i < n - 1; i++ {
			scan(&a[i])
			a[i]--
		}
		a[n - 1] = n - 1
		preprocess()
		res := int64(0)
		cost[n - 1] = 0
		for i := n - 2; i >= 0; i-- {
			nextPos, _ := getRangeMax(i + 1, a[i])
			// from i + 1 - a[i], cost is 1
			t := a[i] - i
			// from a[i] + 1...n-1, use nextPos and the next connection pos.
			t2 := cost[nextPos] - (a[i] - nextPos) + (n - 1 - a[i])
			//printf("i = %d, nextPos = %d, t %d, t2 %d\n", i, nextPos, t, t2)
			cost[i] = t + t2
			res += int64(cost[i])
		}
		printf("%d\n", res)

    	stdout.Flush()
	}
}


Jeff's got n cards, each card contains either digit 0, or digit 5. Jeff can choose several cards and put them in a line so that he gets some number. What is the largest possible number divisible by 90 Jeff can make from the cards he's got?Jeff must make the number without leading zero. At that, we assume that number 0 doesn't contain any leading zeroes. Jeff doesn't have to use all the cards.

The first line contains integer n (1 ≤ n ≤ 103). The next line contains n integers a1, a2, ..., an (ai = 0 or ai = 5). Number ai represents the digit that is written on the i-th card.

In a single line print the answer to the problem — the maximum number, divisible by 90. If you can't make any divisible by 90 number from the cards, print -1.

NoteIn the first test you can make only one number that is a multiple of 90 — 0.In the second test you can make number 5555555550, it is a multiple of 90.

package main

 import "fmt"

 func main() {
     var n int
     fmt.Scanf("%v\n", &n)
     arr := make([]int, n, n)
     cntOf5 := 0
     for i := 0; i < n; i++ {
         fmt.Scanf("%v", &arr[i])
         if arr[i] == 5 {
             cntOf5++
         }
     }
     if cntOf5 == n {
         fmt.Println(-1)
         return
     }
     x := cntOf5 / 9
     if x == 0 {
         fmt.Println(0)
         return
     }
     for i := 0; i < x*9; i++ {
         fmt.Printf("5")
     }
     for i := 0; i < n-cntOf5; i++ {
         fmt.Printf("0")
     }
     fmt.Printf("\n")
 }

package main
import (
	"fmt"
)
func main() {
	var n int
	in,nol,lima := 0,0,0
	fmt.Scan(&n)
	for i:=0;i<n;i++ {
		fmt.Scan(&in)
		if in==0 {
			nol++
		} else if in==5 {
		lima++
		}
	}

	if lima >=9 && nol>0 {
		for i:=0;i<lima/9;i++ {
			fmt.Print("555555555")
		}
		for i:= 0; i<nol; i++ {
			fmt.Print("0")
		}
		fmt.Println()
	} else {
		if nol>0 {
			fmt.Print("0")
		} else {
			fmt.Print("-1")
		}
	}
}

package main

import (
	"fmt"
	"strconv"
)

func dividable(data []int) string {
	var fiveCount, zeroCount int
	var res string
	for i := 0; i < len(data); i++ {
		if data[i] == 5 {
			fiveCount++
		}
		if data[i] == 0 {
			zeroCount++
		}
	}
	if zeroCount == 0 {
		return strconv.Itoa(-1)
	}
	if fiveCount/9 != 0 {
		for i := 0; i < fiveCount/9*9; i++ {
			res += strconv.Itoa(5)
		}
		for i := 0; i < zeroCount; i++ {
			res += strconv.Itoa(0)
		}
		return res
	}
	return strconv.Itoa(0)
}
func main() {
	var n int
	var data []int
	fmt.Scanln(&n)
	data = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &data[i])
	}
	fmt.Println(dividable(data))
}

package main

import "fmt"

func main() {
    var n,a int
    fmt.Scan(&n)
    five, zero := 0, 0
    for i := 0; i < n; i++ {
        fmt.Scan(&a)
        if a == 5 {
            five++
        } else {
            zero++
        }
    }
    if zero == 0 {
        fmt.Println(-1)
    } else if five < 9 {
        fmt.Println(0)
    } else {
        five = (five/9)*9
        for i := 0; i < five; i++ { fmt.Print("5") }
        for i := 0; i < zero; i++ { fmt.Print("0") }
        fmt.Println()
    }
}

// http://codeforces.com/problemset/problem/352/A
// A. Jeff and Digits

package main

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

func main() {
	var (
		n, n0, n5, t, i int32
		in              *bufio.Reader
		out             *bufio.Writer
	)

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

	fmt.Fscan(in, &n)
	for i = 0; i < n; i++ {
		fmt.Fscan(in, &t)
		if 5 == t {
			n5++
		} else {
			n0++
		}
	}

	if 0 == n0 {
		fmt.Fprintln(out, "-1")
	} else {
		t = (n5 / 9)
		if t > 0 {
			for i = 0; i < t; i++ {
				fmt.Fprint(out, "555555555")
			}
			t = (n0 / 9)
			for i = 0; i < t; i++ {
				fmt.Fprint(out, "000000000")
			}
			t = (n0 % 9)
			for i = 0; i < t; i++ {
				fmt.Fprint(out, "0")
			}
		} else {
			fmt.Fprint(out, "0")
		}
		fmt.Fprintln(out)
	}
	out.Flush()
}

package main

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

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

	var fives int = 0
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	for i := 0; scanner.Scan(); i++ {
		a, err := strconv.Atoi(scanner.Text())
		if err != nil {
			return
		} else if a == 5 {
			fives++
		}
	}
	zeros := n - fives

	if zeros <= 0 {
		fmt.Println(-1)
	} else if fives < 9 {
		fmt.Println(0)
	} else {
		num_fives := fives / 9
		for i := 0; i < num_fives*9; i++ {
			fmt.Printf("5")
		}
		for i := 0; i < zeros; i++ {
			fmt.Printf("0")
		}
		fmt.Println()
	}
}

package main

 import "fmt"

 func main() {
     var n int
     fmt.Scanf("%v\n", &n)
     arr := make([]int, n, n)
     cntOf5 := 0
     for i := 0; i < n; i++ {
         fmt.Scanf("%v", &arr[i])
         if arr[i] == 5 {
             cntOf5++
         }
     }
     //fmt.Println(arr)
     x := cntOf5 / 9
     if x == 0 {
         if cntOf5 == n {
             fmt.Println(-1)
             return
         }
         fmt.Println(0)
         return
     }
     for i := 0; i < x*9; i++ {
         fmt.Printf("5")
     }
     for i := 0; i < n-cntOf5; i++ {
         fmt.Printf("0")
     }
     fmt.Printf("\n")
 }


This problem uses a simplified network topology model, please read the problem statement carefully and use it as a formal document as you develop the solution.Polycarpus continues working as a system administrator in a large corporation. The computer network of this corporation consists of n computers, some of them are connected by a cable. The computers are indexed by integers from 1 to n. It's known that any two computers connected by cable directly or through other computersPolycarpus decided to find out the network's topology. A network topology is the way of describing the network configuration, the scheme that shows the location and the connections of network devices.Polycarpus knows three main network topologies: bus, ring and star. A bus is the topology that represents a shared cable with all computers connected with it. In the ring topology the cable connects each computer only with two other ones. A star is the topology where all computers of a network are connected to the single central node.Let's represent each of these network topologies as a connected non-directed graph. A bus is a connected graph that is the only path, that is, the graph where all nodes are connected with two other ones except for some two nodes that are the beginning and the end of the path. A ring is a connected graph, where all nodes are connected with two other ones. A star is a connected graph, where a single central node is singled out and connected with all other nodes. For clarifications, see the picture.    (1) — bus, (2) — ring, (3) — star You've got a connected non-directed graph that characterizes the computer network in Polycarpus' corporation. Help him find out, which topology type the given network is. If that is impossible to do, say that the network's topology is unknown.

The first line contains two space-separated integers n and m (4 ≤ n ≤ 105; 3 ≤ m ≤ 105) — the number of nodes and edges in the graph, correspondingly. Next m lines contain the description of the graph's edges. The i-th line contains a space-separated pair of integers xi, yi (1 ≤ xi, yi ≤ n) — the numbers of nodes that are connected by the i-the edge. It is guaranteed that the given graph is connected. There is at most one edge between any two nodes. No edge connects a node with itself.

In a single line print the network topology name of the given graph. If the answer is the bus, print "bus topology" (without the quotes), if the answer is the ring, print "ring topology" (without the quotes), if the answer is the star, print "star topology" (without the quotes). If no answer fits, print "unknown topology" (without the quotes).

bus topology
ring topology
star topology
unknown topology

package main

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

func main(){
	var n, m int
	r := bufio.NewScanner(os.Stdin)
	r.Split(bufio.ScanWords)
	w := bufio.NewWriter(os.Stdout)
	r.Scan()
	n, _ = strconv.Atoi(r.Text())
	r.Scan()
	m, _ = strconv.Atoi(r.Text())
	var x, y int
	a := make([]int, 100001)
	for i:=0; i<m; i++ {
		r.Scan()
		x, _ = strconv.Atoi(r.Text())
		r.Scan()
		y, _ = strconv.Atoi(r.Text())
		a[x] += 1
		a[y] += 1
	}
	bt, rt, st, c := 0, 0, 0, 0
	for i:=1; i<=n; i++ {
		if a[i] == n-1 && c == 0 {
			st += 1
			c += 1
		} else if a[i] == 1 {
			st += 1
		}
		if a[i] == 2 {
			rt += 1
		}
	}
	if st == n {
		w.WriteString("star topology\n")
		w.Flush()
		return
	}
	if rt == n {
		w.WriteString("ring topology\n")
		w.Flush()
		return
	}
	c = 0
	for i:=1; i<=n; i++ {
		if a[i] == 1 && c <= 2 {
			bt += 1
			c += 1
		} else if a[i] == 2 {
			bt += 1
		}
	}
	if bt == n {
		w.WriteString("bus topology\n")
		w.Flush()
		return
	}
	w.WriteString("unknown topology\n")
	w.Flush()
}

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

func main() {
	var n,m,x,y int
	var v,c [100100]int
	input:=bufio.NewScanner(os.Stdin)
	input.Split(bufio.ScanWords)
	fmt.Scan(&n,&m)
	for i:=0;i<m;i++ {
		input.Scan()
		aa,_:=strconv.Atoi(input.Text())
		x=aa
		input.Scan()
		bb,_:=strconv.Atoi(input.Text())
		y=bb
		v[x]++
		v[y]++
	}
	for i:=1;i<=n;i++ {
		c[v[i]]++
	}
	if c[1]==2 && c[2]==n-2 {
		fmt.Println("bus topology")
	} else if c[1]==n-1 && c[n-1]==1 {
		fmt.Println("star topology")
	} else if c[2]==n {
		fmt.Println("ring topology")
	} else {
		fmt.Println("unknown topology")
	}
}

// http://codeforces.com/problemset/problem/292/B
// B. Network Topology
// eleg a deg? az osszefuggoseg miatt

package main

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

func main() {
	var (
		i, m, n, a, b, d1, d2, dsok int32
		deg                         []int32
		in                          *bufio.Reader
	)

	in = bufio.NewReader(os.Stdin)

	Readint := func() (ret int32) {
		var c byte
		for {
			c, _ = in.ReadByte()
			if c >= '0' && c <= '9' {
				break
			}
		}
		for {
			ret = 10*ret + int32(c-'0')
			c, _ = in.ReadByte()
			if !(c >= '0' && c <= '9') {
				break
			}
		}
		return
	}

	n = Readint()
	m = Readint()
	//	fmt.Println(n, m)
	deg = make([]int32, n+1, n+1)

	for i = 0; i < m; i++ {
		a = Readint()
		b = Readint()

		//fmt.Println(a, b)

		deg[a]++
		deg[b]++
	}

	for i = 1; i <= n; i++ {
		if 1 == deg[i] {
			d1++
			continue
		}
		if 2 == deg[i] {
			d2++
			continue
		}
		dsok++
	}

	switch {
	case n == d2:
		fmt.Println("ring topology")
	case n-2 == d2 && d1 == 2:
		fmt.Println("bus topology")
	case 1 == dsok && d1 == n-1:
		fmt.Println("star topology")
	case 1 == 1:
		fmt.Println("unknown topology")
	}

}

// http://codeforces.com/problemset/problem/292/B
// B. Network Topology
// eleg a deg? az osszefuggoseg miatt

package main

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

func main() {
	var (
		i, m, n, a, b, d1, d2, dsok int32
		deg                         []int32
		in                          *bufio.Reader
	)

	in = bufio.NewReader(os.Stdin)

	fmt.Fscan(in, &n)
	fmt.Fscan(in, &m)
	//	fmt.Println(n, m)
	deg = make([]int32, n+1, n+1)

	for i = 0; i < m; i++ {
		fmt.Fscan(in, &a)
		fmt.Fscan(in, &b)

		//fmt.Println(a, b)

		deg[a]++
		deg[b]++
	}

	for i = 1; i <= n; i++ {
		if 1 == deg[i] {
			d1++
			continue
		}
		if 2 == deg[i] {
			d2++
			continue
		}
		dsok++
	}

	switch {
	case n == d2:
		fmt.Println("ring topology")
	case n-2 == d2 && d1 == 2:
		fmt.Println("bus topology")
	case 1 == dsok && d1 == n-1:
		fmt.Println("star topology")
	case 1 == 1:
		fmt.Println("unknown topology")
	}

}

package main

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

func main() {
    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())
        }
    }

    var n,m,x,y int
    ScanInts(&n,&m)
    e, cnt := make([]int,n+1), make(map[int]int)
    for i := 0; i < m; i++ {
        ScanInts(&x,&y)
        cnt[e[x]]--; e[x]++; cnt[e[x]]++;
        cnt[e[y]]--; e[y]++; cnt[e[y]]++;
    }
    if (cnt[1] == 2) && (cnt[2] == n-2) {
        fmt.Println("bus topology")
    } else if (cnt[2] == n) {
        fmt.Println("ring topology")
    } else if (cnt[1] == n-1) && (cnt[n-1] == 1) {
        fmt.Println("star topology")
    } else {
        fmt.Println("unknown topology")
    }
}

package main

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

func solve() {
	n := readInt()
	m := readInt()
	g := make([][]int, n)
	for i := 0; i < n; i++ {
		g[i] = make([]int, 0)
	}
	for i := 0; i < m; i++ {
		u := readInt() - 1
		v := readInt() - 1
		g[u] = append(g[u], v)
		g[v] = append(g[v], u)
	}
	cnt := make(map[int]int, 0)
	for _, adj := range g {
		cnt[len(adj)]++
	}
	if len(cnt) == 2 && cnt[1] == 2 && cnt[2] == n - 2 {
		fmt.Println("bus topology")
		return
	}
	if len(cnt) == 1 && cnt[2] == n {
		fmt.Println("ring topology")
		return
	}
	if len(cnt) == 2 && cnt[1] == n - 1 && cnt[n-1] == 1 {
		fmt.Println("star topology")
		return
	}
	fmt.Println("unknown topology")
}

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 abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func min(a int64, b int64) int64 {
	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
}

// 292B

package main

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

var (
	a, b, m, n, x1, x2, ans int32
	deg                     []int32
	in                      = bufio.NewReader(os.Stdin)
)

func main() {
	read := func() (x int32) {
		var c byte
		for {
			c, _ = in.ReadByte()
			if c >= '0' && c <= '9' {
				break
			}
		}
		for {
			x = 10*x + int32(c-'0')
			c, _ = in.ReadByte()
			if !(c >= '0' && c <= '9') {
				break
			}
		}
		return
	}

	n = read()
	m = read()
	//	fmt.Println(n, m)
	deg = make([]int32, n+1, n+1)

	for i := int32(0); i < m; i++ {
		a = read()
		b = read()

		//fmt.Println(a, b)

		deg[a]++
		deg[b]++
	}

	for i := int32(1); i <= n; i++ {
		if 1 == deg[i] {
			x1++
			continue
		}
		if 2 == deg[i] {
			x2++
			continue
		}
		ans++
	}

	if n == x2 {
		fmt.Println("ring topology")
		return
	}
	if n-2 == x2 && x1 == 2 {
		fmt.Println("bus topology")
		return
	}
	if 1 == ans && x1 == n-1 {
		fmt.Println("star topology")
		return
	}
	if 1 == 1 {
		fmt.Println("unknown topology")
		return
	}
}

// 292B-mic
package main

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

func main() {
    var n, m, x, y, l, r int
    var a [100005]int
    z := bufio.NewReader(os.Stdin)
    fmt.Scan(&n, &m)
    for i := 1; i <= m; i++ {
        fmt.Fscan(z, &x, &y)
        a[x]++
        a[y]++
    }
    for i := 1; i <= n; i++ {
        if a[i] == 1 {
            l++
        } else if a[i] == 2 {
            r++
        } else {
            break
        }
    }
    if l == 2 && r == n-2 {
        fmt.Println("bus topology")
    } else {
        if r == n {
            fmt.Println("ring topology")
        } else {
            l = 0
            r = 0
            for i := 1; i <= n; i++ {
                if a[i] == 1 {
                    l++
                } else if a[i] == n-1 {
                    r++
                } else {
                    break
                }
            }
            if l == n-1 && r == 1 {
                fmt.Println("star topology")
            } else {
                fmt.Println("unknown topology")
            }
        }
    }
    return
}

// 292B

package main

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

var (
	a, b, m, n, x1, x2, ans int32
	deg                     []int32
	in                      = bufio.NewReader(os.Stdin)
)

func main() {
	read := func() (x int32) {
		var c byte
		for {
			c, _ = in.ReadByte()
			if c >= '0' && c <= '9' {
				break
			}
		}
		for {
			x = 10*x + int32(c-'0')
			c, _ = in.ReadByte()
			if !(c >= '0' && c <= '9') {
				break
			}
		}
		return
	}

	n = read()
	m = read()
	//	fmt.Println(n, m)
	deg = make([]int32, n+1, n+1)

	for i := int32(0); i < m; i++ {
		a = read()
		b = read()

		//fmt.Println(a, b)

		deg[a]++
		deg[b]++
	}

	for i := int32(1); i <= n; i++ {
		if 1 == deg[i] {
			x1++
			continue
		}
		if 2 == deg[i] {
			x2++
			continue
		}
		ans++
	}

	if n == x2 {
		fmt.Println("ring topology")
	}
	if n-2 == x2 && x1 == 2 {
		fmt.Println("bus topology")
	}
	if 1 == ans && x1 == n-1 {
		fmt.Println("star topology")
	}
	if 1 == 1 {
		fmt.Println("unknown topology")
	}
}


The zombies are gathering in their secret lair! Heidi will strike hard to destroy them once and for all. But there is a little problem... Before she can strike, she needs to know where the lair is. And the intel she has is not very good.Heidi knows that the lair can be represented as a rectangle on a lattice, with sides parallel to the axes. Each vertex of the polygon occupies an integer point on the lattice. For each cell of the lattice, Heidi can check the level of Zombie Contamination. This level is an integer between 0 and 4, equal to the number of corners of the cell that are inside or on the border of the rectangle.As a test, Heidi wants to check that her Zombie Contamination level checker works. Given the output of the checker, Heidi wants to know whether it could have been produced by a single non-zero area rectangular-shaped lair (with axis-parallel sides).

The first line of each test case contains one integer N, the size of the lattice grid (5 ≤ N ≤ 50). The next N lines each contain N characters, describing the level of Zombie Contamination of each cell in the lattice. Every character of every line is a digit between 0 and 4. Cells are given in the same order as they are shown in the picture above: rows go in the decreasing value of y coordinate, and in one row cells go in the order of increasing x coordinate. This means that the first row corresponds to cells with coordinates (1, N), ..., (N, N) and the last row corresponds to cells with coordinates (1, 1), ..., (N, 1).

The first line of the output should contain Yes if there exists a single non-zero area rectangular lair with corners on the grid for which checking the levels of Zombie Contamination gives the results given in the input, and No otherwise.

NoteThe lair, if it exists, has to be rectangular (that is, have corners at some grid points with coordinates (x1, y1), (x1, y2), (x2, y1), (x2, y2)), has a non-zero area and be contained inside of the grid (that is, 0 ≤ x1 < x2 ≤ N, 0 ≤ y1 < y2 ≤ N), and result in the levels of Zombie Contamination as reported in the input.

package main

import (
	"fmt"
)
var x1, y1, x2, y2, x3, y3, x4, y4 int
func outOfRectangle(x int, y int) bool{
	if x >= x1 && y >= y1 && x <= x4 && y <= y4 {
		return false
	}
	return true
}

func main() {
	var n int
	var line string
	fmt.Scanf("%d\n",&n)
	lattice := make([][]int, n)
	for i := 0; i < n; i++ {
		lattice[i] = make([]int, n)
	}
	for i := 0; i < n; i++{
		fmt.Scanf("%s\n", &line)
		for j := 0; j < n; j++ {
			lattice[i][j] = int(line[j] - '0')
			//fmt.Printf("%d", lattice[i][j])
		}
		//fmt.Printf("\n")
	}

	/*for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			fmt.Printf("%d", lattice[i][j])
		}
		fmt.Printf("\n")
	}*/

	var jump bool
	jump = false

	for i := 0; i < n; i++{
		for j := 0; j < n; j++ {
			if lattice[i][j] == 1 {
				x1 = i
				y1 = j
				jump = true
				break
			}
		}
		if(jump) {
			break
		}
	}
	if jump == false {
		fmt.Printf("No\n")
		return
	}

	jump = false
	for i := 0; i < n; i++ {
		for j := n - 1; j >= y1; j-- {
			if lattice[i][j] == 1 {
				x2 = i
				y2 = j
				jump = true
				break
			}
		}
		if jump {
			break
		}
	}
	if x2 != x1 || jump == false {
		fmt.Printf("No\n")
		return
	}

	jump = false
	for i := n - 1; i >= x1; i-- {
		for j := 0; j < n; j++ {
			if lattice[i][j] == 1 {
				x3 = i
				y3 = j
				jump = true
				break
			}
		}
		if jump == true {
			break
		}
	}

	if jump == false || y3 != y1 {
		fmt.Printf("No\n")
		return
	}

	jump = false
	for i := n - 1; i >= x3; i-- {
		for j := n - 1; j >= y2; j-- {
			if lattice[i][j] == 1{
				x4 = i
				y4 = j
				jump = true
				break
			}
		}
		if jump == true {
			break
		}
	}

	if jump == false || x4 != x3 || y4 != y2 {
		fmt.Printf("No\n")
		return
	}

	var alltwo bool
	alltwo = true

	//already initialize (x1, y1), (x2, y2), (x3, y3), (x4, y4)
	for i := y1 + 1; i < y2; i++ {
		if lattice[x1][i] != 2 {
			alltwo = false
			break
		}
	}
	if !alltwo {
		fmt.Printf("No\n")
		return
	}

	alltwo = true
	for i := y3 + 1; i < y4; i++  {
		if lattice[x3][i] != 2 {
			alltwo = false
			break
		}
	}
	if alltwo == false {
		fmt.Printf("No\n")
		return
	}

	alltwo = true
	for i := x1 + 1; i < x3; i++ {
		if lattice[i][y1] != 2 {
			alltwo = false
			break
		}
	}
	if alltwo == false {
		fmt.Printf("No\n")
		return
	}

	alltwo = true
	for i:= x2 + 1; i < x4; i++ {
		if lattice[i][y2] != 2 {
			alltwo = false
			break
		}
	}
	if alltwo == false {
		fmt.Printf("No\n")
		return
	}

	var allfour = true
	for i := x1 + 1; i < x3; i++ {
		for j := y1 + 1; j < y4; j++ {
			if lattice[i][j] != 4 {
				allfour = false
				break
			}
		}
	}

	if allfour == false {
		fmt.Printf("No\n")
		return
	}
	//already get (x1,y1), (x2,y2), (x3,y3), (x4,y4)
	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			if lattice[i][j] != 0 && outOfRectangle(i,j) {
				fmt.Printf("No\n")
				return
			}
		}
	}
	fmt.Printf("Yes\n")
}

package main

import (
	"fmt"
)

func main() {
	var n, tmp int
	var junk byte
	fmt.Scanf("%d", &n)
	lattice := make([][]int, n)
	for i := 0; i < n; i++ {
		lattice[i] = make([]int, n)
	}
	for i := 0; i < n; i++{
		for j := 0; j < n; j++ {
			fmt.Scanf("%1d",&tmp)
			lattice[i][j] = tmp
		}
		fmt.Scanf("%b", junk)
	}

	/*for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			fmt.Printf("\t%d", lattice[i][j])
		}
		fmt.Printf("\n")
	}*/
	var x1, y1, x2, y2, x3, y3, x4, y4 int
	var jump bool
	jump = false

	for i := 0; i < n; i++{
		for j := 0; j < n; j++ {
			if lattice[i][j] == 1 {
				x1 = i
				y1 = j
				jump = true
				break
			}
		}
		if(jump) {
			break
		}
	}
	if jump == false {
		return
	}

	jump = false
	for i := 0; i < n; i++ {
		for j := n - 1; j >= y1; j-- {
			if lattice[i][j] == 1 {
				x2 = i
				y2 = j
				jump = true
				break
			}
		}
		if jump {
			break
		}
	}
	if x2 != x1 || jump == false {
		return
	}

	jump = false
	for i := n - 1; i >= x1; i-- {
		for j := 0; j < n; j++ {
			if lattice[i][j] == 1 {
				x3 = i
				y3 = j
				jump = true
				break
			}
		}
		if jump == true {
			break
		}
	}

	if jump == false || y3 != y1 {
		return
	}

	jump = false
	for i := n - 1; i >= x3; i-- {
		for j := n - 1; j >= y2; j-- {
			if lattice[i][j] == 1{
				x4 = i
				y4 = j
				jump = true
				break
			}
		}
		if jump == true {
			break
		}
	}

	if jump == false || x4 != x3 || y4 != y2 {
		return
	}

	var alltwo bool
	alltwo = true

	//already initialize (x1, y1), (x2, y2), (x3, y3), (x4, y4)
	for i := y1 + 1; i < y2; i++ {
		if lattice[x1][i] != 2 {
			alltwo = false
			break
		}
	}
	if !alltwo {
		fmt.Printf("No\n")
		return
	}

	alltwo = true
	for i := y3 + 1; i < y4; i++  {
		if lattice[x3][i] != 2 {
			alltwo = false
			break
		}
	}
	if alltwo == false {
		fmt.Printf("No\n")
		return
	}

	alltwo = true
	for i := x1 + 1; i < x3; i++ {
		if lattice[i][y1] != 2 {
			alltwo = false
			break
		}
	}
	if alltwo == false {
		fmt.Printf("No\n")
		return
	}

	alltwo = true
	for i:= x2 + 1; i < x4; i++ {
		if lattice[i][y2] != 2 {
			alltwo = false
			break
		}
	}
	if alltwo == false {
		fmt.Printf("No\n")
		return
	}

	var allfour = true
	for i := x1 + 1; i < x3; i++ {
		for j := y1 + 1; j < y4; j++ {
			if lattice[i][j] != 4 {
				allfour = false
				break
			}
		}
	}

	if allfour == false {
		fmt.Printf("No\n")
		return
	}

	fmt.Printf("Yes\n")
}

package main

import (
	"fmt"
)

func main() {
	var n, tmp int
	fmt.Scanf("%d", &n)
	lattice := make([][]int, n)
	for i := 0; i < n; i++ {
		lattice[i] = make([]int, n)
	}
	for i := 0; i < n; i++{
		for j := 0; j < n; j++ {
			fmt.Scan(&tmp)
			lattice[i][j] = tmp
		}
	}

	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			fmt.Printf("\t%d", lattice[i][j])
		}
		fmt.Printf("\n")
	}
	var x1, y1, x2, y2, x3, y3, x4, y4 int
	var jump bool
	jump = false

	for i := 0; i < n; i++{
		for j := 0; j < n; j++ {
			if lattice[i][j] == 1 {
				x1 = i
				y1 = j
				jump = true
				break
			}
		}
		if(jump) {
			break
		}
	}
	if jump == false {
		fmt.Printf("jump1\n")
		fmt.Printf("No\n")
		return
	}

	fmt.Printf("%d %d\n", x1, y1)

	jump = false
	for i := 0; i < n; i++ {
		for j := n - 1; j >= y1; j-- {
			if lattice[i][j] == 1 {
				x2 = i
				y2 = j
				jump = true
				break
			}
		}
		if jump {
			break
		}
	}
	if x2 != x1 || jump == false {
		return
	}

	jump = false
	for i := n - 1; i >= x1; i-- {
		for j := 0; j < n; j++ {
			if lattice[i][j] == 1 {
				x3 = i
				y3 = j
				jump = true
				break
			}
		}
		if jump == true {
			break
		}
	}

	if jump == false || y3 != y1 {
		return
	}

	jump = false
	for i := n - 1; i >= x3; i-- {
		for j := n - 1; j >= y2; j-- {
			if lattice[i][j] == 1{
				x4 = i
				y4 = j
				jump = true
				break
			}
		}
		if jump == true {
			break
		}
	}

	if jump == false || x4 != x3 || y4 != y2 {
		return
	}

	var alltwo bool
	alltwo = true

	//already initialize (x1, y1), (x2, y2), (x3, y3), (x4, y4)
	for i := y1 + 1; i < y2; i++ {
		if lattice[x1][i] != 2 {
			alltwo = false
			break
		}
	}
	if !alltwo {
		fmt.Printf("No\n")
		return
	}

	alltwo = true
	for i := y3 + 1; i < y4; i++  {
		if lattice[x3][i] != 2 {
			alltwo = false
			break
		}
	}
	if alltwo == false {
		fmt.Printf("No\n")
		return
	}

	alltwo = true
	for i := x1 + 1; i < x3; i++ {
		if lattice[i][y1] != 2 {
			alltwo = false
			break
		}
	}
	if alltwo == false {
		fmt.Printf("No\n")
		return
	}

	alltwo = true
	for i:= x2 + 1; i < x4; i++ {
		if lattice[i][y2] != 2 {
			alltwo = false
			break
		}
	}
	if alltwo == false {
		fmt.Printf("No\n")
		return
	}

	var allfour = true
	for i := x1 + 1; i < x3; i++ {
		for j := y1 + 1; j < y4; j++ {
			if lattice[i][j] != 4 {
				allfour = false
				break
			}
		}
	}

	if allfour == false {
		fmt.Printf("No\n")
		return
	}

	fmt.Printf("Yes\n")
}

package main

import (
	"fmt"
)

func main() {
	var n, tmp int
	var junk byte
	fmt.Scan(&n)
	lattice := make([][]int, n)
	for i := 0; i < n; i++ {
		lattice[i] = make([]int, n)
	}
	for i := 0; i < n; i++{
		for j := 0; j < n; j++ {
			fmt.Scanf("%1d",&tmp)
			lattice[i][j] = tmp
		}
		fmt.Scanf("%b", junk)
	}

	/*for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			fmt.Printf("%d", lattice[i][j])
		}
		fmt.Printf("\n")
	}*/
	var x1, y1, x2, y2, x3, y3, x4, y4 int
	var jump bool
	jump = false

	for i := 0; i < n; i++{
		for j := 0; j < n; j++ {
			if lattice[i][j] == 1 {
				x1 = i
				y1 = j
				jump = true
				break
			}
		}
		if(jump) {
			break
		}
	}
	if jump == false {
		return
	}

	jump = false
	for i := 0; i < n; i++ {
		for j := n - 1; j >= y1; j-- {
			if lattice[i][j] == 1 {
				x2 = i
				y2 = j
				jump = true
				break
			}
		}
		if jump {
			break
		}
	}
	if x2 != x1 || jump == false {
		return
	}

	jump = false
	for i := n - 1; i >= x1; i-- {
		for j := 0; j < n; j++ {
			if lattice[i][j] == 1 {
				x3 = i
				y3 = j
				jump = true
				break
			}
		}
		if jump == true {
			break
		}
	}

	if jump == false || y3 != y1 {
		return
	}

	jump = false
	for i := n - 1; i >= x3; i-- {
		for j := n - 1; j >= y2; j-- {
			if lattice[i][j] == 1{
				x4 = i
				y4 = j
				jump = true
				break
			}
		}
		if jump == true {
			break
		}
	}

	if jump == false || x4 != x3 || y4 != y2 {
		return
	}

	var alltwo bool
	alltwo = true

	//already initialize (x1, y1), (x2, y2), (x3, y3), (x4, y4)
	for i := y1 + 1; i < y2; i++ {
		if lattice[x1][i] != 2 {
			alltwo = false
			break
		}
	}
	if !alltwo {
		fmt.Printf("No\n")
		return
	}

	alltwo = true
	for i := y3 + 1; i < y4; i++  {
		if lattice[x3][i] != 2 {
			alltwo = false
			break
		}
	}
	if alltwo == false {
		fmt.Printf("No\n")
		return
	}

	alltwo = true
	for i := x1 + 1; i < x3; i++ {
		if lattice[i][y1] != 2 {
			alltwo = false
			break
		}
	}
	if alltwo == false {
		fmt.Printf("No\n")
		return
	}

	alltwo = true
	for i:= x2 + 1; i < x4; i++ {
		if lattice[i][y2] != 2 {
			alltwo = false
			break
		}
	}
	if alltwo == false {
		fmt.Printf("No\n")
		return
	}

	var allfour = true
	for i := x1 + 1; i < x3; i++ {
		for j := y1 + 1; j < y4; j++ {
			if lattice[i][j] != 4 {
				allfour = false
				break
			}
		}
	}

	if allfour == false {
		fmt.Printf("No\n")
		return
	}

	fmt.Printf("Yes\n")
}

package main

import (
	"fmt"
)

func main() {
	var n int
	var line string
	fmt.Scanf("%d\n",&n)
	lattice := make([][]int, n)
	for i := 0; i < n; i++ {
		lattice[i] = make([]int, n)
	}
	for i := 0; i < n; i++{
		fmt.Scanf("%s\n", &line)
		for j := 0; j < n; j++ {
			lattice[i][j] = int(line[j] - '0')
			//fmt.Printf("%d", lattice[i][j])
		}
		//fmt.Printf("\n")
	}

	/*for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			fmt.Printf("%d", lattice[i][j])
		}
		fmt.Printf("\n")
	}*/
	var x1, y1, x2, y2, x3, y3, x4, y4 int
	var jump bool
	jump = false

	for i := 0; i < n; i++{
		for j := 0; j < n; j++ {
			if lattice[i][j] == 1 {
				x1 = i
				y1 = j
				jump = true
				break
			}
		}
		if(jump) {
			break
		}
	}
	if jump == false {
		return
	}

	jump = false
	for i := 0; i < n; i++ {
		for j := n - 1; j >= y1; j-- {
			if lattice[i][j] == 1 {
				x2 = i
				y2 = j
				jump = true
				break
			}
		}
		if jump {
			break
		}
	}
	if x2 != x1 || jump == false {
		return
	}

	jump = false
	for i := n - 1; i >= x1; i-- {
		for j := 0; j < n; j++ {
			if lattice[i][j] == 1 {
				x3 = i
				y3 = j
				jump = true
				break
			}
		}
		if jump == true {
			break
		}
	}

	if jump == false || y3 != y1 {
		return
	}

	jump = false
	for i := n - 1; i >= x3; i-- {
		for j := n - 1; j >= y2; j-- {
			if lattice[i][j] == 1{
				x4 = i
				y4 = j
				jump = true
				break
			}
		}
		if jump == true {
			break
		}
	}

	if jump == false || x4 != x3 || y4 != y2 {
		return
	}

	var alltwo bool
	alltwo = true

	//already initialize (x1, y1), (x2, y2), (x3, y3), (x4, y4)
	for i := y1 + 1; i < y2; i++ {
		if lattice[x1][i] != 2 {
			alltwo = false
			break
		}
	}
	if !alltwo {
		fmt.Printf("No\n")
		return
	}

	alltwo = true
	for i := y3 + 1; i < y4; i++  {
		if lattice[x3][i] != 2 {
			alltwo = false
			break
		}
	}
	if alltwo == false {
		fmt.Printf("No\n")
		return
	}

	alltwo = true
	for i := x1 + 1; i < x3; i++ {
		if lattice[i][y1] != 2 {
			alltwo = false
			break
		}
	}
	if alltwo == false {
		fmt.Printf("No\n")
		return
	}

	alltwo = true
	for i:= x2 + 1; i < x4; i++ {
		if lattice[i][y2] != 2 {
			alltwo = false
			break
		}
	}
	if alltwo == false {
		fmt.Printf("No\n")
		return
	}

	var allfour = true
	for i := x1 + 1; i < x3; i++ {
		for j := y1 + 1; j < y4; j++ {
			if lattice[i][j] != 4 {
				allfour = false
				break
			}
		}
	}

	if allfour == false {
		fmt.Printf("No\n")
		return
	}
	fmt.Printf("Yes\n")
}

package main

import (
	"fmt"
)

func main() {
	var n int
	var line byte
	fmt.Scan(&n)
	lattice := make([][]int, n)
	for i := 0; i < n; i++ {
		lattice[i] = make([]int, n)
	}
	for i := 0; i < n; i++{
		for j := 0; j < n; j++ {
			fmt.Scanf("%b", &line)
			lattice[i][j] = int(line)
		}
		fmt.Scanf("%b", &line)
	}

	/*for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			fmt.Printf("%d", lattice[i][j])
		}
		fmt.Printf("\n")
	}*/
	var x1, y1, x2, y2, x3, y3, x4, y4 int
	var jump bool
	jump = false

	for i := 0; i < n; i++{
		for j := 0; j < n; j++ {
			if lattice[i][j] == 1 {
				x1 = i
				y1 = j
				jump = true
				break
			}
		}
		if(jump) {
			break
		}
	}
	if jump == false {
		return
	}

	jump = false
	for i := 0; i < n; i++ {
		for j := n - 1; j >= y1; j-- {
			if lattice[i][j] == 1 {
				x2 = i
				y2 = j
				jump = true
				break
			}
		}
		if jump {
			break
		}
	}
	if x2 != x1 || jump == false {
		return
	}

	jump = false
	for i := n - 1; i >= x1; i-- {
		for j := 0; j < n; j++ {
			if lattice[i][j] == 1 {
				x3 = i
				y3 = j
				jump = true
				break
			}
		}
		if jump == true {
			break
		}
	}

	if jump == false || y3 != y1 {
		return
	}

	jump = false
	for i := n - 1; i >= x3; i-- {
		for j := n - 1; j >= y2; j-- {
			if lattice[i][j] == 1{
				x4 = i
				y4 = j
				jump = true
				break
			}
		}
		if jump == true {
			break
		}
	}

	if jump == false || x4 != x3 || y4 != y2 {
		return
	}

	var alltwo bool
	alltwo = true

	//already initialize (x1, y1), (x2, y2), (x3, y3), (x4, y4)
	for i := y1 + 1; i < y2; i++ {
		if lattice[x1][i] != 2 {
			alltwo = false
			break
		}
	}
	if !alltwo {
		fmt.Printf("No\n")
		return
	}

	alltwo = true
	for i := y3 + 1; i < y4; i++  {
		if lattice[x3][i] != 2 {
			alltwo = false
			break
		}
	}
	if alltwo == false {
		fmt.Printf("No\n")
		return
	}

	alltwo = true
	for i := x1 + 1; i < x3; i++ {
		if lattice[i][y1] != 2 {
			alltwo = false
			break
		}
	}
	if alltwo == false {
		fmt.Printf("No\n")
		return
	}

	alltwo = true
	for i:= x2 + 1; i < x4; i++ {
		if lattice[i][y2] != 2 {
			alltwo = false
			break
		}
	}
	if alltwo == false {
		fmt.Printf("No\n")
		return
	}

	var allfour = true
	for i := x1 + 1; i < x3; i++ {
		for j := y1 + 1; j < y4; j++ {
			if lattice[i][j] != 4 {
				allfour = false
				break
			}
		}
	}

	if allfour == false {
		fmt.Printf("No\n")
		return
	}

	fmt.Printf("Yes\n")
}

package main

import (
	"fmt"
)

func main() {
	var n int
	var line byte
	fmt.Scan(&n)
	lattice := make([][]int, n)
	for i := 0; i < n; i++ {
		lattice[i] = make([]int, n)
	}
	for i := 0; i < n; i++{
		for j := 0; j < n; j++ {
			fmt.Scanf("%b", &line)
			lattice[i][j] = int(line)
		}
		fmt.Scanf("%b", &line)
	}

	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			fmt.Printf("%d", lattice[i][j])
		}
		fmt.Printf("\n")
	}
	var x1, y1, x2, y2, x3, y3, x4, y4 int
	var jump bool
	jump = false

	for i := 0; i < n; i++{
		for j := 0; j < n; j++ {
			if lattice[i][j] == 1 {
				x1 = i
				y1 = j
				jump = true
				break
			}
		}
		if(jump) {
			break
		}
	}
	if jump == false {
		return
	}

	jump = false
	for i := 0; i < n; i++ {
		for j := n - 1; j >= y1; j-- {
			if lattice[i][j] == 1 {
				x2 = i
				y2 = j
				jump = true
				break
			}
		}
		if jump {
			break
		}
	}
	if x2 != x1 || jump == false {
		return
	}

	jump = false
	for i := n - 1; i >= x1; i-- {
		for j := 0; j < n; j++ {
			if lattice[i][j] == 1 {
				x3 = i
				y3 = j
				jump = true
				break
			}
		}
		if jump == true {
			break
		}
	}

	if jump == false || y3 != y1 {
		return
	}

	jump = false
	for i := n - 1; i >= x3; i-- {
		for j := n - 1; j >= y2; j-- {
			if lattice[i][j] == 1{
				x4 = i
				y4 = j
				jump = true
				break
			}
		}
		if jump == true {
			break
		}
	}

	if jump == false || x4 != x3 || y4 != y2 {
		return
	}

	var alltwo bool
	alltwo = true

	//already initialize (x1, y1), (x2, y2), (x3, y3), (x4, y4)
	for i := y1 + 1; i < y2; i++ {
		if lattice[x1][i] != 2 {
			alltwo = false
			break
		}
	}
	if !alltwo {
		fmt.Printf("No\n")
		return
	}

	alltwo = true
	for i := y3 + 1; i < y4; i++  {
		if lattice[x3][i] != 2 {
			alltwo = false
			break
		}
	}
	if alltwo == false {
		fmt.Printf("No\n")
		return
	}

	alltwo = true
	for i := x1 + 1; i < x3; i++ {
		if lattice[i][y1] != 2 {
			alltwo = false
			break
		}
	}
	if alltwo == false {
		fmt.Printf("No\n")
		return
	}

	alltwo = true
	for i:= x2 + 1; i < x4; i++ {
		if lattice[i][y2] != 2 {
			alltwo = false
			break
		}
	}
	if alltwo == false {
		fmt.Printf("No\n")
		return
	}

	var allfour = true
	for i := x1 + 1; i < x3; i++ {
		for j := y1 + 1; j < y4; j++ {
			if lattice[i][j] != 4 {
				allfour = false
				break
			}
		}
	}

	if allfour == false {
		fmt.Printf("No\n")
		return
	}

	fmt.Printf("Yes\n")
}

package main

import (
	"fmt"
)

func main() {
	var n int
	var line string
	fmt.Scanf("%d\n",&n)
	lattice := make([][]int, n)
	for i := 0; i < n; i++ {
		lattice[i] = make([]int, n)
	}
	for i := 0; i < n; i++{
		fmt.Scanf("%s\n", &line)
		for j := 0; j < n; j++ {
			lattice[i][j] = int(line[j] - '0')
			//fmt.Printf("%d", lattice[i][j])
		}
		//fmt.Printf("\n")
	}

	/*for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			fmt.Printf("%d", lattice[i][j])
		}
		fmt.Printf("\n")
	}*/
	var x1, y1, x2, y2, x3, y3, x4, y4 int
	var jump bool
	jump = false

	for i := 0; i < n; i++{
		for j := 0; j < n; j++ {
			if lattice[i][j] == 1 {
				x1 = i
				y1 = j
				jump = true
				break
			}
		}
		if(jump) {
			break
		}
	}
	if jump == false {
		fmt.Printf("No\n")
		return
	}

	jump = false
	for i := 0; i < n; i++ {
		for j := n - 1; j >= y1; j-- {
			if lattice[i][j] == 1 {
				x2 = i
				y2 = j
				jump = true
				break
			}
		}
		if jump {
			break
		}
	}
	if x2 != x1 || jump == false {
		fmt.Printf("No\n")
		return
	}

	jump = false
	for i := n - 1; i >= x1; i-- {
		for j := 0; j < n; j++ {
			if lattice[i][j] == 1 {
				x3 = i
				y3 = j
				jump = true
				break
			}
		}
		if jump == true {
			break
		}
	}

	if jump == false || y3 != y1 {
		fmt.Printf("No\n")
		return
	}

	jump = false
	for i := n - 1; i >= x3; i-- {
		for j := n - 1; j >= y2; j-- {
			if lattice[i][j] == 1{
				x4 = i
				y4 = j
				jump = true
				break
			}
		}
		if jump == true {
			break
		}
	}

	if jump == false || x4 != x3 || y4 != y2 {
		fmt.Printf("No")
		return
	}

	var alltwo bool
	alltwo = true

	//already initialize (x1, y1), (x2, y2), (x3, y3), (x4, y4)
	for i := y1 + 1; i < y2; i++ {
		if lattice[x1][i] != 2 {
			alltwo = false
			break
		}
	}
	if !alltwo {
		fmt.Printf("No\n")
		return
	}

	alltwo = true
	for i := y3 + 1; i < y4; i++  {
		if lattice[x3][i] != 2 {
			alltwo = false
			break
		}
	}
	if alltwo == false {
		fmt.Printf("No\n")
		return
	}

	alltwo = true
	for i := x1 + 1; i < x3; i++ {
		if lattice[i][y1] != 2 {
			alltwo = false
			break
		}
	}
	if alltwo == false {
		fmt.Printf("No\n")
		return
	}

	alltwo = true
	for i:= x2 + 1; i < x4; i++ {
		if lattice[i][y2] != 2 {
			alltwo = false
			break
		}
	}
	if alltwo == false {
		fmt.Printf("No\n")
		return
	}

	var allfour = true
	for i := x1 + 1; i < x3; i++ {
		for j := y1 + 1; j < y4; j++ {
			if lattice[i][j] != 4 {
				allfour = false
				break
			}
		}
	}

	if allfour == false {
		fmt.Printf("No\n")
		return
	}
	fmt.Printf("Yes\n")
}

package main

import (
	"fmt"
)

func main() {
	var n, tmp int
	var junk byte
	fmt.Scanf("%d", &n)
	lattice := make([][]int, n)
	for i := 0; i < n; i++ {
		lattice[i] = make([]int, n)
	}
	for i := 0; i < n; i++{
		for j := 0; j < n; j++ {
			fmt.Scanf("%1d",&tmp)
			lattice[i][j] = tmp
		}
		fmt.Scanf("%b", junk)
	}

	/*for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			fmt.Printf("%d", lattice[i][j])
		}
		fmt.Printf("\n")
	}*/
	var x1, y1, x2, y2, x3, y3, x4, y4 int
	var jump bool
	jump = false

	for i := 0; i < n; i++{
		for j := 0; j < n; j++ {
			if lattice[i][j] == 1 {
				x1 = i
				y1 = j
				jump = true
				break
			}
		}
		if(jump) {
			break
		}
	}
	if jump == false {
		return
	}

	jump = false
	for i := 0; i < n; i++ {
		for j := n - 1; j >= y1; j-- {
			if lattice[i][j] == 1 {
				x2 = i
				y2 = j
				jump = true
				break
			}
		}
		if jump {
			break
		}
	}
	if x2 != x1 || jump == false {
		return
	}

	jump = false
	for i := n - 1; i >= x1; i-- {
		for j := 0; j < n; j++ {
			if lattice[i][j] == 1 {
				x3 = i
				y3 = j
				jump = true
				break
			}
		}
		if jump == true {
			break
		}
	}

	if jump == false || y3 != y1 {
		return
	}

	jump = false
	for i := n - 1; i >= x3; i-- {
		for j := n - 1; j >= y2; j-- {
			if lattice[i][j] == 1{
				x4 = i
				y4 = j
				jump = true
				break
			}
		}
		if jump == true {
			break
		}
	}

	if jump == false || x4 != x3 || y4 != y2 {
		return
	}

	var alltwo bool
	alltwo = true

	//already initialize (x1, y1), (x2, y2), (x3, y3), (x4, y4)
	for i := y1 + 1; i < y2; i++ {
		if lattice[x1][i] != 2 {
			alltwo = false
			break
		}
	}
	if !alltwo {
		fmt.Printf("No\n")
		return
	}

	alltwo = true
	for i := y3 + 1; i < y4; i++  {
		if lattice[x3][i] != 2 {
			alltwo = false
			break
		}
	}
	if alltwo == false {
		fmt.Printf("No\n")
		return
	}

	alltwo = true
	for i := x1 + 1; i < x3; i++ {
		if lattice[i][y1] != 2 {
			alltwo = false
			break
		}
	}
	if alltwo == false {
		fmt.Printf("No\n")
		return
	}

	alltwo = true
	for i:= x2 + 1; i < x4; i++ {
		if lattice[i][y2] != 2 {
			alltwo = false
			break
		}
	}
	if alltwo == false {
		fmt.Printf("No\n")
		return
	}

	var allfour = true
	for i := x1 + 1; i < x3; i++ {
		for j := y1 + 1; j < y4; j++ {
			if lattice[i][j] != 4 {
				allfour = false
				break
			}
		}
	}

	if allfour == false {
		fmt.Printf("No\n")
		return
	}

	fmt.Printf("Yes\n")
}

package main

import (
	"fmt"
)

func main() {
	var n, tmp int
	fmt.Scanf("%d", &n)
	lattice := make([][]int, n)
	for i := 0; i < n; i++ {
		lattice[i] = make([]int, n)
	}
	for i := 0; i < n; i++{
		for j := 0; j < n; j++ {
			fmt.Scan(&tmp)
			lattice[i][j] = tmp
		}
	}

	/*for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			fmt.Printf("\t%d", lattice[i][j])
		}
		fmt.Printf("\n")
	}*/
	var x1, y1, x2, y2, x3, y3, x4, y4 int
	var jump bool
	jump = false

	for i := 0; i < n; i++{
		for j := 0; j < n; j++ {
			if lattice[i][j] == 1 {
				x1 = i
				y1 = j
				jump = true
				break
			}
		}
		if(jump) {
			break
		}
	}
	if jump == false {
		fmt.Printf("jump1\n")
		fmt.Printf("No\n")
		return
	}

	jump = false
	for i := 0; i < n; i++ {
		for j := n - 1; j >= y1; j-- {
			if lattice[i][j] == 1 {
				x2 = i
				y2 = j
				jump = true
				break
			}
		}
		if jump {
			break
		}
	}
	if x2 != x1 || jump == false {
		return
	}

	jump = false
	for i := n - 1; i >= x1; i-- {
		for j := 0; j < n; j++ {
			if lattice[i][j] == 1 {
				x3 = i
				y3 = j
				jump = true
				break
			}
		}
		if jump == true {
			break
		}
	}

	if jump == false || y3 != y1 {
		return
	}

	jump = false
	for i := n - 1; i >= x3; i-- {
		for j := n - 1; j >= y2; j-- {
			if lattice[i][j] == 1{
				x4 = i
				y4 = j
				jump = true
				break
			}
		}
		if jump == true {
			break
		}
	}

	if jump == false || x4 != x3 || y4 != y2 {
		return
	}

	var alltwo bool
	alltwo = true

	//already initialize (x1, y1), (x2, y2), (x3, y3), (x4, y4)
	for i := y1 + 1; i < y2; i++ {
		if lattice[x1][i] != 2 {
			alltwo = false
			break
		}
	}
	if !alltwo {
		fmt.Printf("No\n")
		return
	}

	alltwo = true
	for i := y3 + 1; i < y4; i++  {
		if lattice[x3][i] != 2 {
			alltwo = false
			break
		}
	}
	if alltwo == false {
		fmt.Printf("No\n")
		return
	}

	alltwo = true
	for i := x1 + 1; i < x3; i++ {
		if lattice[i][y1] != 2 {
			alltwo = false
			break
		}
	}
	if alltwo == false {
		fmt.Printf("No\n")
		return
	}

	alltwo = true
	for i:= x2 + 1; i < x4; i++ {
		if lattice[i][y2] != 2 {
			alltwo = false
			break
		}
	}
	if alltwo == false {
		fmt.Printf("No\n")
		return
	}

	var allfour = true
	for i := x1 + 1; i < x3; i++ {
		for j := y1 + 1; j < y4; j++ {
			if lattice[i][j] != 4 {
				allfour = false
				break
			}
		}
	}

	if allfour == false {
		fmt.Printf("No\n")
		return
	}

	fmt.Printf("Yes\n")
}

package main

import (
	"fmt"
)

func main() {
	var n, tmp int
	fmt.Scanf("%d", &n)
	lattice := make([][]int, n)
	for i := 0; i < n; i++ {
		lattice[i] = make([]int, n)
	}
	for i := 0; i < n; i++{
		for j := 0; j < n; j++ {
			fmt.Scanf("%d", &tmp)
			lattice[i][j] = tmp
		}
	}
	var x1, y1, x2, y2, x3, y3, x4, y4 int
	var jump bool
	jump = false

	for i := 0; i < n; i++{
		for j := 0; j < n; j++ {
			if lattice[i][j] == 1 {
				x1 = i
				y1 = j
				jump = true
				break
			}
		}
		if(jump) {
			break
		}
	}
	if jump == false {
		fmt.Printf("No\n")
		return
	}

	jump = false
	for i := 0; i < n; i++ {
		for j := n - 1; j >= y1; j-- {
			if lattice[i][j] == 1 {
				x2 = i
				y2 = j
				jump = true
				break
			}
		}
		if jump {
			break
		}
	}
	if x2 != x1 || jump == false {
		fmt.Printf("No\n")
		return
	}

	jump = false
	for i := n - 1; i >= x1; i-- {
		for j := 0; j < n; j++ {
			if lattice[i][j] == 1 {
				x3 = i
				y3 = j
				jump = true
				break
			}
		}
		if jump == true {
			break
		}
	}

	if jump == false || y3 != y1 {
		fmt.Printf("No\n")
		return
	}

	jump = false
	for i := n - 1; i >= x3; i-- {
		for j := n - 1; j >= y2; j-- {
			if lattice[i][j] == 1{
				x4 = i
				y4 = j
				jump = true
				break
			}
		}
		if jump == true {
			break
		}
	}

	if jump == false || x4 != x3 || y4 != y2 {
		fmt.Printf("No\n")
		return
	}

	var alltwo bool
	alltwo = true

	//already initialize (x1, y1), (x2, y2), (x3, y3), (x4, y4)
	for i := y1 + 1; i < y2; i++ {
		if lattice[x1][i] != 2 {
			alltwo = false
			break
		}
	}
	if !alltwo {
		fmt.Printf("No\n")
		return
	}

	alltwo = true
	for i := y3 + 1; i < y4; i++  {
		if lattice[x3][i] != 2 {
			alltwo = false
			break
		}
	}
	if alltwo == false {
		fmt.Printf("No\n")
		return
	}

	alltwo = true
	for i := x1 + 1; i < x3; i++ {
		if lattice[i][y1] != 2 {
			alltwo = false
			break
		}
	}
	if alltwo == false {
		fmt.Printf("No\n")
		return
	}

	alltwo = true
	for i:= x2 + 1; i < x4; i++ {
		if lattice[i][y2] != 2 {
			alltwo = false
			break
		}
	}
	if alltwo == false {
		fmt.Printf("No\n")
		return
	}

	var allfour = true
	for i := x1 + 1; i < x3; i++ {
		for j := y1 + 1; j < y4; j++ {
			if lattice[i][j] != 4 {
				allfour = false
				break
			}
		}
	}

	if allfour == false {
		fmt.Printf("No\n")
		return
	}

	fmt.Printf("Yes\n")
}


Your favorite shop sells $$$n$$$ Kinder Surprise chocolate eggs. You know that exactly $$$s$$$ stickers and exactly $$$t$$$ toys are placed in $$$n$$$ eggs in total.Each Kinder Surprise can be one of three types:  it can contain a single sticker and no toy;  it can contain a single toy and no sticker;  it can contain both a single sticker and a single toy. But you don't know which type a particular Kinder Surprise has. All eggs look identical and indistinguishable from each other.What is the minimum number of Kinder Surprise Eggs you have to buy to be sure that, whichever types they are, you'll obtain at least one sticker and at least one toy?Note that you do not open the eggs in the purchasing process, that is, you just buy some number of eggs. It's guaranteed that the answer always exists.

The first line contains the single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of queries. Next $$$T$$$ lines contain three integers $$$n$$$, $$$s$$$ and $$$t$$$ each ($$$1 \le n \le 10^9$$$, $$$1 \le s, t \le n$$$, $$$s + t \ge n$$$) — the number of eggs, stickers and toys. All queries are independent.

Print $$$T$$$ integers (one number per query) — the minimum number of Kinder Surprise Eggs you have to buy to be sure that, whichever types they are, you'll obtain at least one sticker and one toy

NoteIn the first query, we have to take at least $$$6$$$ eggs because there are $$$5$$$ eggs with only toy inside and, in the worst case, we'll buy all of them.In the second query, all eggs have both a sticker and a toy inside, that's why it's enough to buy only one egg.In the third query, we have to buy both eggs: one with a sticker and one with a toy.

package main

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

func main() {
	var read = bufio.NewReader(os.Stdin)
	var write = bufio.NewWriter(os.Stdout)
	defer write.Flush()
	var q int
	fmt.Fscan(read, &q)
	for i := 0; i < q; i++ {
		var n, s, t int
		fmt.Fscan(read, &n, &s, &t)
		var r = n + 1
		if s > t {
			r = r - t
		} else {
			r = r - s
		}
		fmt.Fprintln(write, r)
	}
}

package main

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

func main() {
	// var a, b string
	var cnt, n, s, t, d int
	scr := bufio.NewReader(os.Stdin)
	// ocr := bufio.NewWriter(os.Stdout)

	fmt.Fscanln(scr, &d)
	for i := 0; i < d; i++ {
		fmt.Fscanln(scr, &n, &s, &t)

		if n == s && n == t {
			cnt = 1
		} else if s <= t {
			cnt = (n - s) + 1
		} else if t < s {
			cnt = (n - t) + 1
		}

		fmt.Println(cnt)
	}
}

package main

import "fmt"

func main() {
	var cnt, n, s, t int
	fmt.Scan(&cnt)
	for ; cnt > 0; cnt-- {
		fmt.Scan(&n, &s, &t)
		if s < t {
			t = s
		}
		fmt.Println(n - t + 1)
	}
}

package main

import "fmt"

func main() {
	var countIter int
	var answer = []int{}
	fmt.Scan(&countIter)
	for (countIter) != 0 {
		answer = append(answer, checkEggs())
		countIter--
	}

	for _, element := range answer {
		fmt.Println(element)
	}
}

func checkEggs() int {
	var eggs int
	var stickers int
	var toys int

	fmt.Scan(&eggs, &stickers, &toys)

	if eggs - stickers > eggs - toys {
		return(eggs-stickers + 1)
	} else {
		return(eggs-toys + 1)
	}
}

package main

import "fmt"

func main(){
	var tot,i int
	var n,s,t,st,nst int
	var res int
	fmt.Scanf("%d\n", &tot)
	for i = 0; i < tot; i++ {
		fmt.Scanf("%d %d %d\n",&n,&s,&t)
		st = s + t - n
		if st < 0 {
			st = 0
		}
		s = s - st
		t = t - st
		nst = n - s - t - st;
		if s > t {
			res = nst + s + 1
		} else {
			res = nst + t + 1
		}
		fmt.Printf("%d\n", res)
	}
}

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

	t := readi()
	for i := 0; i < t; i++ {
		n := readi()
		s := readi()
		t := readi()
		println(max(n-s, n-t) + 1)
	}
}

package main

import (
	"fmt"
)
func min(a, b int64) int64 {
    if a < b {
        return a
    } else {
        return b
    }
}

func main() {
	var t, n, s, k, i, sum int64
	fmt.Scan(&t)
	for i = 0; i < t; i++ {
	    fmt.Scan(&n, &s, &k)
	    if n == s && n == k {
	        fmt.Println(1)
	        continue
	    } else if s == n || k == n {
	        fmt.Println(n - min(s,k) + 1)
	        continue
	    }
        sum = n - min(s,k)
	    fmt.Println(sum+1)
	}
}

package main

import (
	"fmt"
)

func main() {
	var t int
	fmt.Scan(&t)
	for t > 0 {
		var n, x, y int
		fmt.Scan(&n)
		fmt.Scan(&x)
		fmt.Scan(&y)
		result := max(n-x, n-y) + 1
		fmt.Println(result)
		t--
	}
}

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

package main

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

func main() {
	// var a, b string
	var cnt, n, s, t, d int
	scr := bufio.NewReader(os.Stdin)
	// ocr := bufio.NewWriter(os.Stdout)

	fmt.Fscanln(scr, &d)
	for i := 0; i < d; i++ {
		fmt.Fscanln(scr, &n, &s, &t)

		if n == s && n == t {
			cnt = 1
		} else if s <= t {
			cnt = s + 1
		} else if t < s {
			cnt = t + 1
		}

		fmt.Println(cnt)
	}
}

package main

import (
	"fmt"
)
func min(a, b int64) int64 {
    if a < b {
        return a
    } else {
        return b
    }
}

func main() {
	var t, n, s, k, i, sum int64
	fmt.Scan(&t)
	for i = 0; i < t; i++ {
	    fmt.Scan(&n, &s, &k)
	    if n == s && n == k {
	        fmt.Println(1)
	        continue
	    } else if s+k == n {
	        fmt.Println(n)
	        continue
	    }
	    sum = min(s,k)
	    sum = sum + 1

	    fmt.Println(sum)
	}
}

package main

import (
	"fmt"
)

func main() {
	var t, n, s, k, i, sum int64
	fmt.Scan(&t)
	for i = 0; i < t; i++ {
	    fmt.Scan(&n, &s, &k)
	    if n == s || n == k {
	        fmt.Println(1)
	        continue
	    }

	    if s+k == n {
	        fmt.Println(n)
	        continue
	    } else {
	        if s < k {
	            sum = s
	        } else {
	            sum = k
	        }
	        sum = sum + 1
	    }

	    fmt.Println(sum)
	}
}

package main

import (
	"fmt"
)

func main() {
	var t, n, s, k, i, sum int64
	fmt.Scan(&t)
	for i = 0; i < t; i++ {
	    fmt.Scan(&n, &s, &k)
	    if n == s && n == k {
	        fmt.Println(1)
	        continue
	    }
	    if s < k {
	        sum = s
	    } else {
	        sum = k
	    }
	    if sum != n {
	        sum = sum + 1
	    }
	    fmt.Println(sum)
	}
}

package main

import (
	"fmt"
)

func main() {
	var t, n, s, k, i, sum int64
	fmt.Scan(&t)
	for i = 0; i < t; i++ {
	    fmt.Scan(&n, &s, &k)
	    if n == s && n == k {
	        fmt.Println(1)
	        continue
	    }

	    if s+k == n {
	        fmt.Println(n)
	        continue
	    } else if s+k > n {
	        if s < k {
	            sum = s
	        } else {
	            sum = k
	        }
	        if sum != n {
	            sum = sum + 1
	        }
	    } else {
	        if s > k {
	            sum = s
	        } else {
	            sum = k
	        }
	        if sum != n {
	            sum = sum + 1
	        }
	    }

	    fmt.Println(sum)
	}
}

package main

import (
	"fmt"
)
func min(a, b int64) int64 {
    if a < b {
        return a
    } else {
        return b
    }
}

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

func main() {
	var t, n, s, k, i, sum int64
	fmt.Scan(&t)
	for i = 0; i < t; i++ {
	    fmt.Scan(&n, &s, &k)
	    if n == s && n == k {
	        fmt.Println(1)
	        continue
	    } else if s+k == n {
	        fmt.Println(n)
	        continue
	    } else if s == n || k == n {
	        fmt.Println(n - min(s,k) + 1)
	        continue
	    }
	    min := min(s,k)
	    max := max(s,k)
	    sum = max - (min-(n-max))
	    fmt.Println(sum+1)
	}
}

package main

import (
	"fmt"
)

func main() {
	var t, n, s, k, i, sum int64
	fmt.Scan(&t)
	for i = 0; i < t; i++ {
	    fmt.Scan(&n, &s, &k)
	    if n == s && n == k {
	        fmt.Println(1)
	        continue
	    } else if n == s || n == k {
	        fmt.Println(n)
	        continue
	    }

	    if s+k == n {
	        fmt.Println(n)
	        continue
	    } else {
	        if s < k {
	            sum = s
	        } else {
	            sum = k
	        }
	        sum = sum + 1
	    }

	    fmt.Println(sum)
	}
}

package main

import (
	"fmt"
)

func main() {
	var t int
	fmt.Scan(&t)
	for t+1 > 0 {
		var n, x, y int
		fmt.Scan(&n)
		result := max(n-x, n-y) + 1
		fmt.Println(result)
		t--
	}
}

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