You are storing an integer array of length $$$m$$$ in a database. To maintain internal integrity and protect data, the database stores $$$n$$$ copies of this array.Unfortunately, the recent incident may have altered the stored information in every copy in the database.It's believed, that the incident altered at most two elements in every copy. You need to recover the original array based on the current state of the database.In case there are multiple ways to restore the array, report any. If there is no array that differs from every copy in no more than two positions, report that as well.

The first line contains integers $$$n$$$ and $$$m$$$ ($$$2 \le n$$$; $$$1 \le m$$$; $$$n \cdot m \le 250\,000$$$) — the number of copies and the size of the array. Each of the following $$$n$$$ lines describes one of the currently stored copies in the database, it consists of $$$m$$$ integers $$$s_{i, 1}, s_{i, 2}, \dots, s_{i, m}$$$ ($$$1 \le s_{i, j} \le 10^9$$$).

If there is an array consistent with all given copies, print "Yes" and then the array itself. The array must have length $$$m$$$ and contain integers between $$$1$$$ and $$$10^9$$$ only. Otherwise, print "No". If there are multiple possible arrays, print any of them.

NoteIn the first example, the array $$$[1, 10, 1, 100]$$$ differs from first and second copies in just one position, and from the third copy in two positions.In the second example, array $$$[1, 1, 1, 1, 1, 1, 1]$$$ is the same as the first copy and differs from all other copies in at most two positions.In the third example, there is no array differing in at most two positions from every database's copy.

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1492E(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	var n, m int
	Fscan(in, &n, &m)
	a := make([][]int, n)
	for i := range a {
		a[i] = make([]int, m)
		for j := range a[i] {
			Fscan(in, &a[i][j])
		}
	}
	var f func(int) bool
	f = func(canModify int) bool {
		for _, r := range a[1:] {
			d := []int{}
			for j, v := range r {
				if v != a[0][j] {
					d = append(d, j)
				}
			}
			if len(d) <= 2 {
				continue
			}
			if len(d) <= 2+canModify {
				for _, j := range d {
					tmp := a[0][j]
					a[0][j] = r[j]
					if f(canModify - 1) {
						return true
					}
					a[0][j] = tmp
				}
			}
			return false
		}
		return true
	}
	if f(2) {
		Fprintln(out, "Yes")
		for _, v := range a[0] {
			Fprint(out, v, " ")
		}
	} else {
		Fprint(out, "No")
	}
}

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

package main

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

// github.com/EndlessCheng/codeforces-go
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	var n, m int
	Fscan(in, &n, &m)
	a := make([][]int, n)
	for i := range a {
		a[i] = make([]int, m)
		for j := range a[i] {
			Fscan(in, &a[i][j])
		}
	}
	var f func(int) bool
	f = func(e int) bool {
		for _, r := range a[1:] {
			d := []int{}
			for j, v := range r {
				if v != a[0][j] {
					d = append(d, j)
				}
			}
			if len(d) > 2 {
				if len(d) <= 2+e {
					for _, j := range d {
						tmp := a[0][j]
						a[0][j] = r[j]
						if f(e - 1) {
							return true
						}
						a[0][j] = tmp
					}
				}
				return false
			}
		}
		return true
	}
	if f(2) {
		Fprintln(out, "Yes")
		for _, v := range a[0] {
			Fprint(out, v, " ")
		}
	} else {
		Fprint(out, "No")
	}
}

package main

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

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

	var n, m int
	Fscan(in, &n, &m)
	a := make([][]int, n)
	for i := range a {
		a[i] = make([]int, m)
		for j := range a[i] {
			Fscan(in, &a[i][j])
		}
	}
	var f func(int) bool
	f = func(e int) bool {
		for _, r := range a[1:] {
			d := []int{}
			for j, v := range r {
				if v != a[0][j] {
					d = append(d, j)
				}
			}
			if len(d) < 3 {
				continue
			}
			if len(d) <= 2+e {
				for _, j := range d {
					tmp := a[0][j]
					a[0][j] = r[j]
					if f(e - 1) {
						return true
					}
					a[0][j] = tmp
				}
			}
			return false
		}
		return true
	}
	if f(2) {
		Fprintln(out, "Yes")
		for _, v := range a[0] {
			Fprint(out, v, " ")
		}
	} else {
		Fprint(out, "No")
	}
}

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

package main

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

func main() {
	input := bufio.NewReader(os.Stdin)
	output := bufio.NewWriter(os.Stdout)

	defer output.Flush()

	var n, m int

	fmt.Fscan(input, &n, &m)

	s := make([][]int, n)
	for i := range s {
		s[i] = make([]int, m)
		for j := range s[i] {
			fmt.Fscan(input, &s[i][j])
		}
	}

	var a func(int) bool
	a = func(e int) bool {
		for _, r := range s[1:] {
			d := []int{}
			for j, v := range r {
				if v != s[0][j] {
					d = append(d, j)
				}
			}

			if len(d) > 2 {
				if len(d) <= 2+e {
					for _, j := range d {
						tmp := s[0][j]
						s[0][j] = r[j]
						if a(e - 1) {
							return true
						}
						s[0][j] = tmp
					}
				}
				return false
			}

		}

		return true

	}

	if a(2) {
		fmt.Fprint(output, "Yes \n")
		for _, v := range s[0] {
			fmt.Fprint(output, v, "  ")
		}
	} else {
		fmt.Fprint(output, "No")
	}

}

package main

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

func main() {
	input := bufio.NewReader(os.Stdin)
	output := bufio.NewWriter(os.Stdout)

	defer output.Flush()

	var n, m int

	fmt.Fscan(input, &n, &m)

	s := make([][]int, n)
	for i := range s {
		s[i] = make([]int, m)
		for j := range s[i] {
			fmt.Fscan(input, &s[i][j])
		}
	}

	var a func(int) bool
	a = func(e int) bool {
		for _, r := range s[1:] {
			d := []int{}
			for j, v := range r {
				if v != s[0][j] {
					d = append(d, j)
				}
			}

			if len(d) > 2 {
				if len(d) <= 2+e {
					for _, j := range d {
						tmp := s[0][j]
						s[0][j] = r[j]
						if a(e - 1) {
							return true
						}
						s[0][j] = tmp
					}
				}
				return false
			}

		}

		return true

	}

	if a(2) {
		fmt.Fprint(output, "Yes")
		for _, v := range s[0] {
			fmt.Fprint(output, v, "  ")
		}
	} else {
		fmt.Fprint(output, "No")
	}

}


Sean is trying to save a large file to a USB flash drive. He has n USB flash drives with capacities equal to a1, a2, ..., an megabytes. The file size is equal to m megabytes. Find the minimum number of USB flash drives needed to write Sean's file, if he can split the file between drives.

The first line contains positive integer n (1 ≤ n ≤ 100) — the number of USB flash drives. The second line contains positive integer m (1 ≤ m ≤ 105) — the size of Sean's file. Each of the next n lines contains positive integer ai (1 ≤ ai ≤ 1000) — the sizes of USB flash drives in megabytes. It is guaranteed that the answer exists, i. e. the sum of all ai is not less than m.

Print the minimum number of USB flash drives to write Sean's file, if he can split the file between drives.

NoteIn the first example Sean needs only two USB flash drives — the first and the third.In the second example Sean needs all three USB flash drives.In the third example Sean needs only one USB flash drive and he can use any available USB flash drive — the first or the second.

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"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, m := nextInt(), nextInt()
	a := make([]int, n)

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

	sort.Ints(a)

	totalM := 0
	usb := 0

	for totalM < m {
		totalM += a[n-1]
		n--
		usb++
	}

	println(usb)
}

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 (
	"fmt"
	"sort"
)

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}
	sort.Ints(a)
	i := 1
	for ; m > 0; i++ {
		m -= a[n-i]
	}
	fmt.Println(i - 1)
}

package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, m int
	var a [1010]int

	fmt.Scanln(&n)
	fmt.Scanln(&m)
	for i := 0; i < n; i++ {
		fmt.Scanln(&a[i])
	}

	sort.Sort(sort.Reverse(sort.IntSlice(a[:n])))

	var result int
	for total := 0; total < m; total, result = total+a[result], result+1 {
	}

	fmt.Println(result)
}

package main

import "fmt"

import "sort"

func main() {
        var n, v int
        var m [200]int
        fmt.Scanln(&n)
        fmt.Scanln(&v)
        for i := 0; i < n; i++ {
                fmt.Scanln(&m[i])
        }
        var s []int = m[:n]
        sort.Sort(sort.Reverse(sort.IntSlice(s)))
        //      fmt.Println(s)
        cnt := 0
        for i := 0; i < n; i++ {
                v -= m[i]
                cnt++
                if v <= 0 {
                        fmt.Println(cnt)
                        break
                }
        }

}

package main

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

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

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

	bubble_sort(u, n)

	disks := 0
	capacity := 0
	for i := 0; i < n; i++ {
		disks += 1
		capacity += u[i]
		if capacity >= m {
			break
		}
	}
	fmt.Println(disks)
}

func swap(a, b int, array []int) {
	tmp := array[a]
	array[a] = array[b]
	array[b] = tmp
}

func bubble_sort(array []int, length int) {
	for i := 0; i < length; i++ {
		for j := 0; j < length; j++ {
			if array[i] > array[j] {
				swap(i, j, array)
			}
		}
	}
}

package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, m int
	fmt.Scan(&n)
	fmt.Scan(&m)
	a := make([]int, n)
	for i := range a {
		fmt.Scan(&a[i])
	}
	sort.Ints(a)
	var out int
	for i := len(a) - 1; i >= 0; i-- {
		temp := m - a[i]
		if temp > 0 {
			out++
			m -= a[i]
		} else {
			break
		}
	}
	fmt.Println(out + 1)
}

package main

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

//N _
const (
	N = 2*1e5 + 5
)

func inputter(inputReader *bufio.Reader,strs chan *string){
	for {
		input , _ := inputReader.ReadString('\n')
		input = strings.TrimSpace(input)
		if len(input) > 0 {
			inputs := strings.Split(input, " ")
			for i := range inputs{
				strs <- &inputs[i]
			}
		}
	}
}

func main(){
	rs := bufio.NewReader(os.Stdin)
	ws := bufio.NewWriter(os.Stdout)

	strs := make(chan *string, 100)

	go inputter(rs, strs)

	n , _ := strconv.ParseInt(*<-strs, 10, 64)
	m , _ := strconv.ParseInt(*<-strs, 10, 64)

	a := make([]int, 0, N)

	for i := 0; i < int(n); i++ {
		x, _ := strconv.ParseInt(*<-strs, 10, 32)
		a = append(a, int(x))
	}

	sort.SliceStable(a, func(i,j int)bool{return a[i] > a[j]})

	tot := int64(0)

	for i := 0; i < int(n); i++ {
		tot += int64(a[i])
		if tot >= m{
			ws.WriteString(fmt.Sprint(i + 1))
			break
		}
	}

	ws.Flush()
}

package main

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

const INF  = 1000000001

type Pair struct {
	first, second int
}

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
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func sort(arr []int) []int {
	if len(arr) < 2 {
		return arr
	}
	left := 0
	right := len(arr) - 1
	pivot := rand.Int() % len(arr)

	arr[pivot], arr[right] = arr[right], arr[pivot]

	for i := 0; i < len(arr); i++ {
		if arr[i] > arr[right] {
			arr[i], arr[left] = arr[left], arr[i]
			left++
		}
	}

	arr[left], arr[right] = arr[right], arr[left]

	sort(arr[:left])
	sort(arr[left+1:])
	return arr
}

func solution(reader io.Reader, writer io.Writer) {
	var n, m int

	fmt.Fscanf(reader, "%d\n%d\n", &n, &m)

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

	a = sort(a)

	for i := 0; i < n; i++ {
		m-=a[i]
		if m <= 0 {
			fmt.Fprintf(writer, "%d\n", i + 1)
			return
		}
	}

}

func main() {

	//stdin, err := os.Open("file.in")
	//if err != nil {
	//	panic(err)
	//}
	//defer stdin.Close()
	stdin := os.Stdin
	reader := bufio.NewReaderSize(stdin, 1024*1024)

	//stdout, err := os.Create("file.out")
	//if err != nil {
	//	panic(err)
	//}
	//defer stdout.Close()
	stdout := os.Stdout
	writer := bufio.NewWriterSize(stdout, 1024*1024)
	defer writer.Flush()

	solution(reader, writer)
}

package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, m int
	var a [1010]int

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

	sort.Sort(sort.Reverse(sort.IntSlice(a[:n])))

	var result int
	for total := 0; total < m; total, result = total+a[result], result+1 {
	}

	fmt.Println(result)
}

package main

import "fmt"

import "sort"

func main() {
        var n, v int
        var m [200]int
        fmt.Scanf("%d\n%d", &n, &v)
        for i := 0; i < n; i++ {
                fmt.Scanf("%d\n", &m[i])
        }
        var s []int = m[:n]
        sort.Sort(sort.Reverse(sort.IntSlice(s)))
        //      fmt.Println(s)
        cnt := 0
        for i := 0; i < n; i++ {
                v -= m[i]
                cnt++
                if v <= 0 {
                        fmt.Println(cnt)
                        break
                }
        }

}

package main

import "fmt"

import "sort"

func main() {
        var n, v int
        var m [200]int
        fmt.Scanf("%d\n%d", &n, &v)
        for i := 0; i < n; i++ {
                fmt.Scanf("%d", &m[i])
        }
        var s []int = m[:n]
        sort.Sort(sort.Reverse(sort.IntSlice(s)))
        //fmt.Println(s)
        cnt := 0
        for i := 0; i < n; i++ {
                v -= m[i]
                cnt++
                if v <= 0 {
                        fmt.Println(cnt)
                        break
                }
        }

}

package main

import "fmt"

import "sort"

func main() {
        var n, v int
        var m [200]int
        fmt.Scanf("%d", &n)
        fmt.Scanf("%d", &v)
        for i := 0; i < n; i++ {
                fmt.Scanf("%d", &m[i])
        }
        var s []int = m[:n]
        sort.Sort(sort.Reverse(sort.IntSlice(s)))
        //fmt.Println(s)
        cnt := 0
        for i := 0; i < n; i++ {
                v -= m[i]
                cnt++
                if v <= 0 {
                        fmt.Println(cnt)
                        break
                }
        }

}

package main

import "fmt"

import "sort"

func main() {
	var n, v int
	var m [200]int
	fmt.Scanf("%d\n%d", &n, &v)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &m[i])
	}
	var s []int = m[:n]
	sort.Sort(sort.Reverse(sort.IntSlice(s)))
	//	fmt.Println(s)
	cnt := 0
	for i := 0; i < n; i++ {
		v -= m[i]
		cnt++
		if v <= 0 {
			fmt.Println(cnt)
			break
		}
	}

}


A telephone number is a sequence of exactly 11 digits, where the first digit is 8. For example, the sequence 80011223388 is a telephone number, but the sequences 70011223388 and 80000011223388 are not.You are given a string $$$s$$$ of length $$$n$$$, consisting of digits.In one operation you can delete any character from string $$$s$$$. For example, it is possible to obtain strings 112, 111 or 121 from string 1121.You need to determine whether there is such a sequence of operations (possibly empty), after which the string $$$s$$$ becomes a telephone number.

The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the length of string $$$s$$$. The second line of each test case contains the string $$$s$$$ ($$$|s| = n$$$) consisting of digits.

For each test print one line. If there is a sequence of operations, after which $$$s$$$ becomes a telephone number, print YES. Otherwise, print NO.

NoteIn the first test case you need to delete the first and the third digits. Then the string 7818005553535 becomes 88005553535.

package main

import "fmt"

func main() {
	n := 0
	var strs []string
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		n1 := 0
		var s string
		fmt.Scan(&n1)
		fmt.Scan(&s)
		strs = append(strs, s)
	}

	for _, vals := range strs {
		res := "NO"
		nl := len(vals) - 10
		for x := 0; x < nl; x++ {
			c := string([]rune(vals)[x])
			if c == "8" {
				res = "YES"
				break
			}
		}
		fmt.Println(res)
	}

}

// A. Telephone Number
/*
A telephone number is a sequence of exactly 11 digits, where the first digit is 8. For example, the sequence 80011223388 is a telephone number, but the sequences 70011223388 and 80000011223388 are not.

You are given a string 𝑠 of length 𝑛, consisting of digits.

In one operation you can delete any character from string 𝑠. For example, it is possible to obtain strings 112, 111 or 121 from string 1121.

You need to determine whether there is such a sequence of operations (possibly empty), after which the string 𝑠 becomes a telephone number.

Input
The first line contains one integer 𝑡 (1≤𝑡≤100) — the number of test cases.

The first line of each test case contains one integer 𝑛 (1≤𝑛≤100) — the length of string 𝑠.

The second line of each test case contains the string 𝑠 (|𝑠|=𝑛) consisting of digits.

Output
For each test print one line.

If there is a sequence of operations, after which 𝑠 becomes a telephone number, print YES.

Otherwise, print NO.

Example
Input
2
13
7818005553535
11
31415926535

Output
YES
NO

Note
In the first test case you need to delete the first and the third digits. Then the string 7818005553535 becomes 88005553535.
*/
package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	input1, _ := reader.ReadString('\n')
	t, _ := strconv.Atoi(strings.TrimSpace(input1))

	for ; t > 0; t-- {
		input2, _ := reader.ReadString('\n')
		n, _ := strconv.Atoi(strings.TrimSpace(input2))

		input3, _ := reader.ReadString('\n')
		s := strings.TrimSpace(input3)

		p := n
		for i := 0; i < n; i++ {
			if s[i] == '8' {
				p = i
				break
			}
		}

		if n-p >= 11 {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import (
	"fmt"
	"strings"
)

func main() {
	var t, n int
	var s string
	fmt.Scan(&t)
	for ; t > 0; t-- {
		fmt.Scan(&n, &s)
		start := strings.Index(s, "8")
		if start < 0 || n-start < 11 {
			fmt.Println("NO")
		} else {
			fmt.Println("YES")
		}
	}

}

package main

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

func solve(j Jam) {
	t := j.Int()
	for i := int64(0); i < t; i++ {
		n, s := j.Int(), j.Str()

		if n >= 11 && strings.IndexRune(s[0:len(s)-10], '8') >= 0{
			fmt.Printf("YES\n")
		} else {
			fmt.Printf("NO\n")
		}
	}
}

func main() {
	jam, closeFunc := JamNew()
	defer closeFunc()
	solve(jam)
}

type Jam interface {
	Scanner() *bufio.Scanner
	Writer() *bufio.Writer
	Close()

	Str() string
	Int() int64
	Float() float64

	P(format string, values ...interface{})
	PF(format string, values ...interface{})
}

func JamNew() (Jam, func()) {
	if len(os.Args) > 1 {
		panic("running with input file path is not supported")
	}

	var scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 0, 1024*1024), 1024*1024)

	var writer = bufio.NewWriter(os.Stdout)
	jam := &jam{scanner, writer}
	return jam, jam.Close
}

type jam struct {
	sc *bufio.Scanner
	wr *bufio.Writer
}

func (j *jam) Close() {
	if err := j.wr.Flush(); err != nil {
		panic(err)
	}
}

func (j *jam) Scanner() *bufio.Scanner {
	return j.sc
}

func (j *jam) Writer() *bufio.Writer {
	return j.wr
}

func (j *jam) Str() string {
	if !j.sc.Scan() {
		panic("failed to scan next token")
	}

	return j.sc.Text()
}

func (j *jam) Int() int64 {
	if !j.sc.Scan() {
		panic("failed to scan next token")
	}

	res, err := strconv.ParseInt(j.sc.Text(), 10, 64)
	if err != nil {
		panic(err)
	}

	return res
}

func (j *jam) Float() float64 {
	j.sc.Scan()
	res, err := strconv.ParseFloat(j.sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return res
}

func (j *jam) P(format string, values ...interface{}) {
	_, err := fmt.Fprintf(j.wr, format, values...)
	if err != nil {
		panic(err)
	}
}

func (j *jam) PF(format string, values ...interface{}) {
	_, err := fmt.Fprintf(j.wr, format, values...)
	if err != nil {
		panic(err)
	}
	if err = j.wr.Flush(); err != nil {
		panic(err)
	}
}

package main

import "fmt"

func main() {
	var t int
	fmt.Scan(&t);
	for i:=1; i<=t; i++ {
		var n int
		var s string
		fmt.Scan(&n, &s);
		switch {
		case n>=11:
			for _, char := range s {
				if (char=='8' && n>=11) {
					fmt.Println("YES")
					break;
				}
				n--;
				if (n<11) {
					fmt.Println("NO");
					break;
				}
			}
		case n<=11:
			fmt.Println("NO")
		}
	}
}

package main

import "fmt"

func answer(s string)(res bool)  {
	var ans int

	for i := range s{
		if(s[i] =='8'){
			break;
		}
		ans ++;
	}
	if(len(s) - ans >= 11){
		res = true
	}else{
		res = false;
	}
	return
}

func main(){
	var n int
	fmt.Scan(&n)
	for ;n >= 1;n--{
	var s string
	fmt.Scan(&s)
	fmt.Scan(&s)
		if(answer(s) == true){
			fmt.Println("YES")
		}else{
			fmt.Println("NO")
		}
	}
}

package main

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

func CheckPhone(len int, phone string) bool {
	for i,val := range(phone) {
		if int(val) -48 == 8 {
			if len - i >= 11{
				fmt.Println("YES")
				return true
			}
		}
	}
	fmt.Println("NO")
	return false
}

func main() {
	var testcase int
	reader := bufio.NewReader(os.Stdin)
	text, _ := reader.ReadString('\n')
	text =  strings.TrimRight(text,"\r\n")
	testcase,_ = strconv.Atoi(text)
	numbers := []string{}
	lens := []int{}
	for i:=0 ;i <testcase;i++ {
		text, _ := reader.ReadString('\n')
		text =  strings.TrimRight(text,"\r\n")
		lenz,_ := strconv.Atoi(text)
		lens = append(lens,lenz)
		text, _ = reader.ReadString('\n')
		text =  strings.TrimRight(text,"\r\n")
		numbers = append(numbers,text)
	}
	for i,_ := range(lens) {
		CheckPhone(lens[i],numbers[i])
	}
}

package main

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

func main() {
    input := bufio.NewScanner(os.Stdin)
    input.Split(bufio.ScanWords)

    input.Scan()
    t, _ := strconv.Atoi(input.Text())

    for kase := 0; kase < t; kase++ {
        input.Scan()
        n, _ := strconv.Atoi(input.Text())

        input.Scan()
        s := input.Text()

        ok := false
        for i, ch := range s {
            if ch == '8' && n - i >= 11 {
                ok = true
                break
            }
        }

        if ok {
            fmt.Println("YES")
        } else {
            fmt.Println("NO")
        }
    }
}

        package main

        import "fmt"

        func isTelephoneNumber(length int, number string) bool {
        	if length < 11 {
        		return false
        	}
        	for index, value := range number {
        		if value == '8' && length-index >= 11 {
        			return true
        		}

        	}
        	return false
        }
        func main() {
        	var countCheck int
        	var length int
        	var number string
        	fmt.Scan(&countCheck)
        	for i := 0; i < countCheck; i++ {
        		fmt.Scan(&length)
        		fmt.Scan(&number)
        		if isTelephoneNumber(length, number) {
        			fmt.Println("YES")
        		} else {
        		    fmt.Println("NO")
        		}
        	}
        }

package main

import (
	"fmt"
)

func isTelephoneNumber(len int ,number string) bool  {
	if len <11 {
		return false
	}
	for index, value := range number{
		if value == '8'{
			if len - index >=11{
				return true
			}
		}
	}
	return false
}
func main()  {
	var num_of_check int
	var len int
	var number string
	fmt.Scan(&num_of_check)
	for i := 0 ; i< num_of_check; i++ {
		fmt.Scan(&len)
		fmt.Scan(&number)
		if isTelephoneNumber(len, number){
			fmt.Println("YES")
		}else {
			fmt.Println("NO")
		}
	}

}

package main

import (
	"fmt"
)

func isTelephoneNumber(len int, number string) bool {
	if len < 11 {
		return false
	}
	for index, value := range number {
		if value == '8' && len-index >= 11 {
			return true
		}

	}
	return false
}
func main() {
	var num_of_check int
	var len int
	var number string
	fmt.Scan(&num_of_check)
	for i := 0; i < num_of_check; i++ {
		fmt.Scan(&len)
		fmt.Scan(&number)
		if isTelephoneNumber(len, number) {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}

}

package main

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

var reader = bufio.NewReader(os.Stdin)
var 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 main() {
	defer writer.Flush()

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

		index := -1
		for j := 0; j < l; j++ {
			if x[j] == '8' {
				index = j
				break
			}
		}

		if index != -1 && l-index > 10 {
			printf("YES\n")
			continue
		}
		printf("NO\n")
		continue
	}
}

package main

import "fmt"

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

		flag := false
		for j := 0; j < n-10; j++ {
			if tel[j] == '8' && n-j >= 11 {
				flag = true
				break
			}
		}

		if flag {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import (
	"fmt"
	"strings"
)

type Number struct {
	Len int
	Num string
}

func main() {
	var caseNum int
	fmt.Scan(&caseNum)
	numbers := make([]Number, caseNum)
	for i := 0; i < caseNum; i++ {
		fmt.Scan(&numbers[i].Len)
		fmt.Scan(&numbers[i].Num)
	}
	for _, number := range numbers {
		if !(strings.Contains(number.Num, "8")) {
			fmt.Println("NO")
			continue
		}
		if number.Len-strings.Index(number.Num, "8") >= 11 {
			fmt.Println("YES")
			continue
		}
		fmt.Println("NO")
	}
}

package main

import (
	"fmt"
	"log"
	"strings"
)

type Number struct {
	Len int
	Num string
}

func main() {
	var caseNum int
	_, err := fmt.Scanf("%d\n", &caseNum)
	if err != nil {
		log.Fatal(err)
	}
	numbers := make([]Number, caseNum)
	for i := 0; i < caseNum; i += 1 {
		var slen int
		var snum string
		_, err = fmt.Scanf("%d\n", &slen)
		if err != nil {
			log.Fatal(err)
		}
		_, err = fmt.Scanf("%s\n", &snum)
		if err != nil {
			log.Fatal(err)
		}
		numbers[i] = Number{slen, snum}
	}
	for _, element := range numbers {
		if (strings.Contains(element.Num, "8")) {
			if element.Len-strings.Index(element.Num, "8") >= 11 {
				fmt.Println("YES")
			} else {
				fmt.Println("NO")
			}
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import (
	"fmt"
	"strings"
)

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 t int
	fmt.Scanln(&t)
	for i := 0;i < t ;i++  {
		var n int
		var s string
		fmt.Scanln(&n)
		fmt.Scanln(&s)
		c := strings.IndexAny(s, "8")
		if c < 0 || n -c <11{
			fmt.Println("NO")
		} else{
			fmt.Println("YES")
		}
	}
}

package main

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

const YES = "YES"
const NO = "NO"

func main() {
	reader := getReader()
	reader.Scan()
	for reader.Scan() {
		cnt, _ := strconv.ParseInt(reader.Text(), 0, 64)
		reader.Scan()
		str := reader.Text()
		if cnt < 11 {
			fmt.Println(NO)
		} else if isPhone(str) {
			fmt.Println(YES)
		} else {
			fmt.Println(NO)
		}
	}
}

func isPhone(str string) bool {
	ind := strings.Index(str, "8")
	if ind < 0 {
		return false
	}
	length := len(str)

	return (length - ind) > 10
}

func getReader() *bufio.Scanner {
	if isOnline() {
		return bufio.NewScanner(os.Stdin)
	}
	file, _ := os.Open("data.txt")
	return bufio.NewScanner(file)
}

func isOnline() bool {
	env := os.Getenv("ONLINE_JUDGE")
	return env != "false"
}

package main

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

const YES = "YES"

const NO = "NO"

func main() {
	reader := getReader()
	reader.Scan()
	for reader.Scan() {
		cnt, _ := strconv.ParseInt(reader.Text(), 0, 64)
		reader.Scan()
		str := reader.Text()
		if cnt < 11 {
			fmt.Println(NO)
		} else if isPhone(str) {
			fmt.Println(YES)
		} else {
			fmt.Println(NO)
		}
	}
}

func isPhone(str string) bool {
	ind := strings.Index(str, "8")
	if ind < 0 {
		return false
	}
	length := len(str)

	return (length - ind) > 10
}

func getReader() *bufio.Scanner {
	if isOnline() {
		return bufio.NewScanner(os.Stdin)
	}
	file, _ := os.Open("data.txt")
	return bufio.NewScanner(file)
}

func isOnline() bool {
	_, b := os.LookupEnv("LAVRUHIN_HOME")
	return !b
}

package main

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

const YES = "YES"

const NO = "NO"

func main() {
	reader := getReader()
	reader.Scan()
	for reader.Scan() {
		cnt, _ := strconv.ParseInt(reader.Text(), 0, 64)
		reader.Scan()
		str := reader.Text()
		if cnt < 11 {
			fmt.Println(NO)
		} else if isPhone(str) {
			fmt.Println(YES)
		} else {
			fmt.Println(NO)
		}
	}
}

func isPhone(str string) bool {
	ind := strings.Index(str, "8")
	if ind < 0 {
		return false
	}
	length := len(str)

	return (length - ind) > 10
}

func getReader() *bufio.Scanner {
	if isOnline() {
		return bufio.NewScanner(os.Stdin)
	}
	file, _ := os.Open("data.txt")
	return bufio.NewScanner(file)
}

func isOnline() bool {
	//env := os.Getenv("ONLINE_JUDGE")
	return true
}

package main

import "fmt"

func check(length int, data string) {
	pos := -1

	for i := range data {
		if data[i] == '8' {
			pos = i
			break
		}
	}

	if pos >= 0 && length-pos > 10 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

func main() {

	var numOfTests, length int
	var data string

	fmt.Scan(&numOfTests)

	for i := 0; i < numOfTests; i++ {
		fmt.Scan(&length)
		fmt.Scan(&data)
		check(length, data)
	}
}

package main

import (
	"fmt"
	"strconv"
)

func main() {
	var t, n int
	var str string
	var can bool
	fmt.Scanln(&str)
	t, _ = strconv.Atoi(str)
	for i := 0; i < t; i++ {
		can = false
		fmt.Scanln(&str)
		n, _ = strconv.Atoi(str)
		fmt.Scanln(&str)
		//fmt.Printf("string was: %s with length: %d", str, n)
		for j := 0; j < n-10; j++ {
			if str[j] == '8' {
				can = true
				break
			}
		}
		if can {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import (
	"bufio"
	"os"
	"strings"
	"fmt"
)
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 readLine()(string,error) 			{ return reader.ReadString('\n') }

func main() {
	defer writer.Flush()
	var n int
	scanf("%d\n", &n)
	for i := 0; i < n; i++ {
		var t int
		var s string
		scanf("%d\n", &t)
		scanf("%s\n", &s)
		j := strings.Index(s,"8")
		if (j != -1 && t - j > 10) {
			printf("YES\n")
		} else {
			printf("NO\n")
		}
	}
}

package main

import (
	"fmt"
	"strings"
)

func main() {
	t := 0
	fmt.Scanf("%d\n", &t)
	for ; t != 0; t-- {
		n := 0
		s := ""
		fmt.Scanf("%d\n%s\n", &n, &s)
		if p := strings.IndexByte(s, '8'); p < 0 || p+11 > len(s) {
			fmt.Printf("NO\n")
		} else {
			fmt.Printf("YES\n")
		}
	}
}

package main

import (
	"fmt"
	"strings"
)

func main() {
	t := 0
	n := 0
	s := ""
	fmt.Scanf("%d\n", &t)
	for true {
		t--

		fmt.Scanf("%d\n%s\n", &n, &s)
		if n < 11 {
			fmt.Printf("NO\n")
		} else if n == 11 {
			if s[0] != '8' {
				fmt.Printf("NO\n")
			} else {
				fmt.Printf("YES\n")
			}
		} else {
			if p := strings.IndexByte(s, '8'); p < 0 || p+11 > len(s) {
				fmt.Printf("NO\n")
			} else {
				fmt.Printf("YES\n")
			}
		}

		if t == 0 {
			break
		}
	}
}

package main

import (
	"fmt"
	"strings"
)

func main() {
	var t, n int
	var s string
	fmt.Scan(&t)
	for ; t > 0; t-- {
		fmt.Scan(&n, &s)
		start := strings.Index(s, "7")
		if start < 0 || n-start < 11 {
			fmt.Println("NO")
		} else {
			fmt.Println("YES")
		}
	}

}

package main

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

func CheckPhone(len int, phone string) bool {
	for i,val := range(phone) {
		if int(val) -48 == 8 {
			if len - i -1 > 11{
				fmt.Println("YES")
				return true
			}
		}
	}
	fmt.Println("NO")
	return false
}

func main() {
	var testcase int
	reader := bufio.NewReader(os.Stdin)
	text, _ := reader.ReadString('\n')
	text =  strings.TrimRight(text,"\r\n")
	testcase,_ = strconv.Atoi(text)
	numbers := []string{}
	lens := []int{}
	for i:=0 ;i <testcase;i++ {
		text, _ := reader.ReadString('\n')
		text =  strings.TrimRight(text,"\r\n")
		lenz,_ := strconv.Atoi(text)
		lens = append(lens,lenz)
		text, _ = reader.ReadString('\n')
		text =  strings.TrimRight(text,"\r\n")
		numbers = append(numbers,text)
	}
	for i,_ := range(lens) {
		CheckPhone(lens[i],numbers[i])
	}
}

package main

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

func CheckPhone(len int, phone string) bool {
	for i,val := range(phone) {
		if int(val) == 8 {
			if len - i -1 > 11{
				fmt.Println("YES")
				return true
			}
		}
	}
	fmt.Println("NO")
	return false
}

func main() {
	var testcase int
	reader := bufio.NewReader(os.Stdin)
	text, _ := reader.ReadString('\n')
	text =  strings.TrimRight(text,"\r\n")
	testcase,_ = strconv.Atoi(text)
	numbers := []string{}
	lens := []int{}
	for i:=0 ;i <testcase;i++ {
		text, _ := reader.ReadString('\n')
		text =  strings.TrimRight(text,"\r\n")
		lenz,_ := strconv.Atoi(text)
		lens = append(lens,lenz)
		text, _ = reader.ReadString('\n')
		text =  strings.TrimRight(text,"\r\n")
		numbers = append(numbers,text)
	}
	for i,_ := range(lens) {
		CheckPhone(lens[i],numbers[i])
	}
}

package main

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

func CheckPhone(len int, phone string) bool {
	for i,val := range(phone) {
		if int(val) -48 == 8 {
			if len - i -1 >= 11{
				fmt.Println("YES")
				return true
			}
		}
	}
	fmt.Println("NO")
	return false
}

func main() {
	var testcase int
	reader := bufio.NewReader(os.Stdin)
	text, _ := reader.ReadString('\n')
	text =  strings.TrimRight(text,"\r\n")
	testcase,_ = strconv.Atoi(text)
	numbers := []string{}
	lens := []int{}
	for i:=0 ;i <testcase;i++ {
		text, _ := reader.ReadString('\n')
		text =  strings.TrimRight(text,"\r\n")
		lenz,_ := strconv.Atoi(text)
		lens = append(lens,lenz)
		text, _ = reader.ReadString('\n')
		text =  strings.TrimRight(text,"\r\n")
		numbers = append(numbers,text)
	}
	for i,_ := range(lens) {
		CheckPhone(lens[i],numbers[i])
	}
}

package main

import (
	"fmt"
	"math"
)

func isTelephoneNumber(len,number int) bool  {
	if len <11 {
		return false
	}
	for i:= 0; i<len; i++{
		term := math.Mod(float64(number),10)
		number /= 10
		if int(term)==8{
			if i+1 >=11 {
				return true
			}
		}
	}
	return false
}
func main()  {
	var num_of_check int
	fmt.Scan(&num_of_check)
	listLenNumber := make([][]int, num_of_check)
	for i := range listLenNumber {
		listLenNumber[i] = make([]int, num_of_check)
	}
	for i:=0; i<num_of_check; i++{
		fmt.Scan(&listLenNumber[i][0])
		fmt.Scan(&listLenNumber[i][1])
		}

	for i:=0; i<num_of_check; i++{
		if isTelephoneNumber(listLenNumber[i][0],listLenNumber[i][1]){
			fmt.Println("YES")
		}else {
			fmt.Println("NO")
		}
}

}

package main

import (
	"fmt"
	"math"
)

func isTelephoneNumber(len,number int) bool  {
	if len <11 {
		return false
	}
	for i:= 0; i<len; i++{
		term := math.Mod(float64(number),10)
		number = number/10
		if int(term)==8{
			if i+1 >=11 {
				return true
			}
		}
	}
	return false
}
func main()  {
	var num_of_check int
	fmt.Scan(&num_of_check)
	listLenNumber := make([][]int, num_of_check)
	for i := range listLenNumber {
		listLenNumber[i] = make([]int, num_of_check)
	}
	for i:=0; i<num_of_check; i++{
		fmt.Scan(&listLenNumber[i][0])
		fmt.Scan(&listLenNumber[i][1])
		}

	for i:=0; i<num_of_check; i++{
		if isTelephoneNumber(listLenNumber[i][0],listLenNumber[i][1]){
			fmt.Println("YES")
		}else {
			fmt.Println("NO")
		}
}

}

package main

import (
	"fmt"
	"math"
)

func isTelephoneNumber(len,number int) bool  {
	if len <11 {
		return false
	}
	for i:= 0; i<len; i++{
		term := math.Mod(float64(number),10)
		number = number/10
		if int(term)==8{
			if i+1 >=11 {
				return true
			}else {
				return false
			}
		}
	}
	return false
}
func main()  {
	var num_of_check int
	fmt.Scan(&num_of_check)
	listLenNumber := make([][]int, num_of_check)
	for i := range listLenNumber {
		listLenNumber[i] = make([]int, num_of_check)
	}
	for i:=0; i<num_of_check; i++{
		fmt.Scan(&listLenNumber[i][0])
		fmt.Scan(&listLenNumber[i][1])
		}

	for i:=0; i<num_of_check; i++{
		if isTelephoneNumber(listLenNumber[i][0],listLenNumber[i][1]){
			fmt.Println("YES")
		}else {
			fmt.Println("NO")
		}
}

}

package main

import (
	"fmt"
	"math"
)

func isTelephoneNumber(len,number int) bool  {
	if len <11 {
		return false
	}
	for i:= 0; i<len; i++{
		term := math.Mod(float64(number),10)
		number /= 10
		if int(term)==8{
			if i+1 >=11 {
				return true
			}
		}
	}
	return false
}
func main()  {
	var num_of_check int
	fmt.Scan(&num_of_check)
	listLenNumber := make([][]int, num_of_check)
	for i := range listLenNumber {
		listLenNumber[i] = make([]int, num_of_check)
	}
	for i:=0; i<num_of_check; i++{
		fmt.Scan(&listLenNumber[i][0])
		fmt.Scan(&listLenNumber[i][1])
		}

	for i:=0; i<num_of_check; i++{
		if isTelephoneNumber(listLenNumber[i][0],listLenNumber[i][1]){
			fmt.Println("YESsssss")
		}else {
			fmt.Println("NOooooooo")
		}
}

}

package main

import (
	"fmt"
	"strings"
)

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 t int
	fmt.Scanln(&t)
	for i := 0;i < t ;i++  {
		var n int
		var s string
		fmt.Scanln(&n)
		fmt.Scanln(&s)
		c := strings.IndexAny(s, "8")
		if c <= 0 || len(s) -c <12{
			fmt.Println("NO")
		} else{
			fmt.Println("YES")
		}
	}
}

package main

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

const YES = "YES"

const NO = "NO"

func main() {
	reader := getReader()
	reader.Scan()
	for reader.Scan() {
		cnt, _ := strconv.ParseInt(reader.Text(), 0, 64)
		reader.Scan()
		str := reader.Text()
		if cnt < 11 {
			fmt.Println(NO)
		}
		if isPhone(str) {
			fmt.Println(YES)
		} else {
			fmt.Println(NO)
		}
	}
}

func isPhone(str string) bool {
	ind := strings.Index(str, "8")
	if ind < 0 {
		return false
	}
	length := len(str)

	return (length - ind) > 10
}

func getReader() *bufio.Scanner {
	if isOnline() {
		return bufio.NewScanner(os.Stdin)
	}
	file, _ := os.Open("data.txt")
	return bufio.NewScanner(file)
}

func isOnline() bool {
	env := os.Getenv("ONLINE_JUDGE")
	return env != ""
}

package main

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

const YES = "YES"
const NO = "NO"

func main() {
	reader := getReader()
	reader.Scan()
	for reader.Scan() {
		cnt, _ := strconv.ParseInt(reader.Text(), 0, 64)
		reader.Scan()
		str := reader.Text()
		if cnt < 11 {
			fmt.Println(NO)
		} else if isPhone(str) {
			fmt.Println(YES)
		} else {
			fmt.Println(NO)
		}
	}
}

func isPhone(str string) bool {
	ind := strings.Index(str, "8")
	if ind < 0 {
		return false
	}
	length := len(str)

	return (length - ind) > 10
}

func getReader() *bufio.Scanner {
	if isOnline() {
		return bufio.NewScanner(os.Stdin)
	}
	file, _ := os.Open("data.txt")
	return bufio.NewScanner(file)
}

func isOnline() bool {
	env := os.Getenv("ONLINE_JUDGE")
	return env == "true"
}

package main

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

const YES = "YES"

const NO = "NO"

func main() {
	reader := getReader()
	reader.Scan()
	for reader.Scan() {
		cnt, _ := strconv.ParseInt(reader.Text(), 0, 64)
		reader.Scan()
		str := reader.Text()
		if cnt < 11 {
			fmt.Println(NO)
		} else if isPhone(str) {
			fmt.Println(YES)
		} else {
			fmt.Println(NO)
		}
	}
}

func isPhone(str string) bool {
	ind := strings.Index(str, "8")
	if ind < 0 {
		return false
	}
	length := len(str)

	return (length - ind) > 10
}

func getReader() *bufio.Scanner {
	if isOnline() {
		return bufio.NewScanner(os.Stdin)
	}
	file, _ := os.Open("data.txt")
	return bufio.NewScanner(file)
}

func isOnline() bool {
	_, b := os.LookupEnv("ONLINE_JUDGE")
	return b
}

package main

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

const YES = "YES"

const NO = "NO"

func main() {
	reader := getReader()
	reader.Scan()
	for reader.Scan() {
		cnt, _ := strconv.ParseInt(reader.Text(), 0, 64)
		reader.Scan()
		str := reader.Text()
		if cnt < 11 {
			fmt.Println(NO)
		} else if isPhone(str) {
			fmt.Println(YES)
		} else {
			fmt.Println(NO)
		}
	}
}

func isPhone(str string) bool {
	ind := strings.Index(str, "8")
	if ind < 0 {
		return false
	}
	length := len(str)

	return (length - ind) > 10
}

func getReader() *bufio.Scanner {
	if isOnline() {
		return bufio.NewScanner(os.Stdin)
	}
	file, _ := os.Open("data.txt")
	return bufio.NewScanner(file)
}

func isOnline() bool {
	env := os.Getenv("ONLINE_JUDGE")
	return env != ""
}

package main

import "fmt"

func check(length int, data string) {
	pos := -1

	for i := range data {
		if data[i] == '8' {
			pos = i
			break
		}
	}

	if pos > 0 && (pos >= 10 || length-pos >= 10) {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

func main() {

	var numOfTests, length int
	var data string

	fmt.Scan(&numOfTests)

	for i := 0; i < numOfTests; i++ {
		fmt.Scan(&length)
		fmt.Scan(&data)
		check(length, data)
	}
}

package main

import "fmt"

func check(length int, data string) {
	pos := -1

	for i := range data {
		if data[i] == '8' {
			pos = i
			break
		}
	}

	if pos >= 0 && length-pos >= 10 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

func main() {

	var numOfTests, length int
	var data string

	fmt.Scan(&numOfTests)

	for i := 0; i < numOfTests; i++ {
		fmt.Scan(&length)
		fmt.Scan(&data)
		check(length, data)
	}
}

package main

import "fmt"

func check(length int, data string) {
	pos := -1

	for i := range data {
		if data[i] == '8' {
			pos = i
			break
		}
	}

	if pos >= 0 && (pos >= 10 || length-pos >= 10) {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

func main() {

	var numOfTests, length int
	var data string

	fmt.Scan(&numOfTests)

	for i := 0; i < numOfTests; i++ {
		fmt.Scan(&length)
		fmt.Scan(&data)
		check(length, data)
	}
}

package main

import (
	"fmt"
)

func main() {
	var t, n int
	var str string
	var can bool
	fmt.Scanf("%d", &t)
	for i := 0; i < t; i++ {
		can = false
		fmt.Scanf("%d", &n)
		fmt.Scanln(&str)
		for j := 0; j < len(str)-10; j++ {
			if str[j] == '8' {
				can = true
				break
			}
		}
		if can {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import (
	"fmt"
	"strconv"
)

func main() {
	var t, n int
	var str string
	var can bool
	fmt.Scanln(&str)
	t, _ = strconv.Atoi(str)
	for i := 0; i < t; i++ {
		can = false
		fmt.Scanln(&str)
		n, _ = strconv.Atoi(str)
		fmt.Scanln(&str)
		fmt.Printf("string was: %s with length: %d", str, n)
		for j := 0; j < n-10; j++ {
			if str[j] == '8' {
				can = true
				break
			}
		}
		if can {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import (
	"fmt"
	"strings"
)

func main() {
	t := 0
	n := 0
	s := ""
	fmt.Scanf("%d\n", &t)
	for true {
		t--

		fmt.Scanf("%d\n%s\n", &n, &s)
		if n < 11 {
			fmt.Printf("NO\n")
		} else if n == 11 {
			if s[0] != '8' {
				fmt.Printf("NO\n")
			} else {
				fmt.Printf("YES\n")
			}
		} else {
			if p := strings.IndexByte(s, '8'); p < 0 || p+7 > len(s) {
				fmt.Printf("NO\n")
			} else {
				fmt.Printf("YES\n")
			}
		}

		if t == 0 {
			break
		}
	}
}

package main

import (
	"fmt"
	"strings"
)

func main() {
	t := 0
	fmt.Scan(&t)
	for ; t != 0; t-- {
		n := 0
		s := ""
		fmt.Scanf("%d\n%s\n", &n, &s)
		if p := strings.IndexByte(s, '8'); p < 0 || p+11 > len(s) {
			fmt.Printf("NO\n")
		} else {
			fmt.Printf("YES\n")
		}
	}
}

package main

import (
	"fmt"
	"strings"
)

func main() {
	t := 0
	fmt.Scan("%d\n", &t)
	for ; t != 0; t-- {
		n := 0
		s := ""
		fmt.Scanf("%d\n%s\n", &n, &s)
		if p := strings.IndexByte(s, '8'); p < 0 || p+11 > len(s) {
			fmt.Printf("NO\n")
		} else {
			fmt.Printf("YES\n")
		}
	}
}

package main

import (
	"fmt"
	"strings"
)

func main() {
	t := 0
	n := 0
	s := ""
	fmt.Scanf("%d\n", &t)
	for true {
		t--

		fmt.Scanf("%d\n%s\n", &n, &s)
		if n < 11 {
			fmt.Printf("NO\n")
		} else if n == 11 {
			if s[0] != '8' {
				fmt.Printf("NO\n")
			} else {
				fmt.Printf("YES\n")
			}
		} else {
			if p := strings.IndexByte(s, '8'); p < 0 || p+10 > len(s) {
				fmt.Printf("NO\n")
			} else {
				fmt.Printf("YES\n")
			}
		}

		if t == 0 {
			break
		}
	}
}


Maria participates in a bicycle race.The speedway takes place on the shores of Lake Lucerne, just repeating its contour. As you know, the lake shore consists only of straight sections, directed to the north, south, east or west.Let's introduce a system of coordinates, directing the Ox axis from west to east, and the Oy axis from south to north. As a starting position of the race the southernmost point of the track is selected (and if there are several such points, the most western among them). The participants start the race, moving to the north. At all straight sections of the track, the participants travel in one of the four directions (north, south, east or west) and change the direction of movement only in bends between the straight sections. The participants, of course, never turn back, that is, they do not change the direction of movement from north to south or from east to west (or vice versa).Maria is still young, so she does not feel confident at some turns. Namely, Maria feels insecure if at a failed or untimely turn, she gets into the water. In other words, Maria considers the turn dangerous if she immediately gets into the water if it is ignored.Help Maria get ready for the competition — determine the number of dangerous turns on the track.

The first line of the input contains an integer n (4 ≤ n ≤ 1000) — the number of straight sections of the track. The following (n + 1)-th line contains pairs of integers (xi, yi) ( - 10 000 ≤ xi, yi ≤ 10 000). The first of these points is the starting position. The i-th straight section of the track begins at the point (xi, yi) and ends at the point (xi + 1, yi + 1). It is guaranteed that:   the first straight section is directed to the north;  the southernmost (and if there are several, then the most western of among them) point of the track is the first point;  the last point coincides with the first one (i.e., the start position);  any pair of straight sections of the track has no shared points (except for the neighboring ones, they share exactly one point);  no pair of points (except for the first and last one) is the same;  no two adjacent straight sections are directed in the same direction or in opposite directions.

Print a single integer — the number of dangerous turns on the track.

NoteThe first sample corresponds to the picture:  The picture shows that you can get in the water under unfortunate circumstances only at turn at the point (1, 1). Thus, the answer is 1.

// Codeforces 659 D cheating solution
package main

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

func main() {
	// reading n
    var n int
	in := bufio.NewReader(os.Stdin)
	s, err := in.ReadString('\n')
	if err != nil {
		fmt.Println("first read failure", err)
		return
	}
	ss := strings.Split(strings.Trim(s, " \n\r"), " ")
	n, err = strconv.Atoi(ss[0])
	if err != nil {
		fmt.Println("n atoi failure", err)
		return
	}
    // skipping lines with coordinates
    for i:=0; i<n+1; i++ {
        s, err = in.ReadString('\n')
        if err != nil {
            fmt.Println("read failure", err)
            return
        }
    }

    // result
    nd := (n-4) / 2
    fmt.Println(nd)
}

package main

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

var N int

type Pair struct {
	x int
	y int
}

func main() {
	fsc := NewFastScanner()
	N = fsc.NextInt()

	points := make([]Pair, 0)
	var ty, tx int
	ty = -1000000
	tx = -1000000
	for i := 0; i < N+1; i++ {
		var x, y int
		x, y = fsc.NextInt(), fsc.NextInt()
		points = append(points, Pair{x: x, y: y})
		if ty < y {
			ty = y
		}
		if tx < x {
			tx = x
		}
	}
	var sy, sx int
	sx = points[0].x
	sy = points[0].y

	var py, px int
	px = sx
	py = sy
	ans := 0
	dir := 0
	for i := 1; i < N+1; i++ {
		var ny, nx int
		ny = points[i].y
		nx = points[i].x

		if py < ny { //north
			if dir == 1 {
				ans++
			}
			dir = 0
		} else if py > ny { //south
			if dir == 3 {
				ans++
			}
			dir = 2
		} else if px < nx { //east
			if dir == 2 {
				ans++
			}
			dir = 1
		} else if px > nx { //west
			if dir == 0 {
				ans++
			}
			dir = 3
		}

		py = ny
		px = nx
	}
	fmt.Println(ans)
}

//template
type FastScanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewFastScanner() *FastScanner {
	rdr := bufio.NewReaderSize(os.Stdin, 2028)
	return &FastScanner{r: rdr}
}

func (s *FastScanner) Next() string {
	s.Pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}

func (s *FastScanner) NextInt() int {
	val, err := strconv.Atoi(s.Next())
	if err != nil {
		panic(err)
	}
	return val
}
func (s *FastScanner) NextInt64() int64 {
	val, err := strconv.ParseInt(s.Next(), 10, 64)
	if err != nil {
		panic(err)
	}
	return val
}
func (s *FastScanner) Pre() {
	if s.p >= len(s.buf) {
		s.ReadLine()
		s.p = 0
	}
}

func (s *FastScanner) ReadLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, err := s.r.ReadLine()
		if err != nil {
			panic(err.Error())
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


On the board, Bob wrote $$$n$$$ positive integers in base $$$10$$$ with sum $$$s$$$ (i. e. in decimal numeral system). Alice sees the board, but accidentally interprets the numbers on the board as base-$$$11$$$ integers and adds them up (in base $$$11$$$).What numbers should Bob write on the board, so Alice's sum is as large as possible?

The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The description of the test cases follows. The only line of each test case contains two integers $$$s$$$ and $$$n$$$ ($$$1 \leq s \leq 10^9$$$; $$$1 \leq n \leq \min(100, s)$$$) — the sum and amount of numbers on the board, respectively. Numbers $$$s$$$ and $$$n$$$ are given in decimal notation (base $$$10$$$).

For each test case, output $$$n$$$ positive integers — the numbers Bob should write on the board, so Alice's sum is as large as possible. If there are multiple answers, print any of them.

NoteIn the first test case, $$$70_{10} + 27_{10} = 97_{10}$$$, and Alice's sum is $$$$$$70_{11} + 27_{11} = 97_{11} = 9 \cdot 11 + 7 = 106_{10}.$$$$$$ (Here $$$x_b$$$ represents the number $$$x$$$ in base $$$b$$$.) It can be shown that it is impossible for Alice to get a larger sum than $$$106_{10}$$$.In the second test case, Bob can only write a single number on the board, so he must write $$$17$$$.In the third test case, $$$3_{10} + 4_{10} + 100_{10} + 4_{10} = 111_{10}$$$, and Alice's sum is $$$$$$3_{11} + 4_{11} + 100_{11} + 4_{11} = 110_{11} = 1 \cdot 11^2 + 1 \cdot 11 = 132_{10}.$$$$$$ It can be shown that it is impossible for Alice to get a larger sum than $$$132_{10}$$$.

package main

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

/*type IntArray []int

func (p IntArray) Len() int           { return len(p) }
func (p IntArray) Less(i, j int) bool { return p[i] < p[j] }
func (p IntArray) Swap(i, j int)      { p[i], p[j] = p[j], p[i] }*/

const SIZE = 111

var res [SIZE]int

func main() {
	var t int
	r := bufio.NewReader(os.Stdin)
	Fscan(r, &t)
	for te := 0; te < t; te++ {
		var s, n int
		Fscan(r, &s)
		Fscan(r, &n)
		for i := 0; i < n; i++ {
			res[i] = 1
		}
		s -= n
		for i := 0; i < n; i++ {
			for j := 9; s >= j; j *= 10 {
				res[i] += j
				s -= j
			}
		}
		for i := 0; i < n; i++ {
			Printf("%d ", res[i]+s)
			s = 0
		}
		Println()
	}
}

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1567D(in io.Reader, _w io.Writer) {
	out := bufio.NewWriter(_w)
	defer out.Flush()
	var T, s, n int
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &s, &n)
		x := int(math.Pow10(len(strconv.Itoa(s)) - 1))
		for i := 1; i < n; i++ {
			for s-x < n-i {
				x /= 10
			}
			Fprint(out, x, " ")
			s -= x
		}
		Fprintln(out, s)
	}
}

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

package main

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

/*type IntArray []int

func (p IntArray) Len() int           { return len(p) }
func (p IntArray) Less(i, j int) bool { return p[i] < p[j] }
func (p IntArray) Swap(i, j int)      { p[i], p[j] = p[j], p[i] }*/

const SIZE = 111

var res [SIZE]int

func main() {
	var t int
	r := bufio.NewReader(os.Stdin)
	Fscan(r, &t)
	for te := 0; te < t; te++ {
		var s, n int
		Fscan(r, &s)
		Fscan(r, &n)
		for i := 0; i < n; i++ {
			res[i] = 1
		}
		s -= n
		for i := 0; i < n; i++ {
			for j := 9; s > j; j *= 10 {
				res[i] += j
				s -= j
			}
		}
		for i := 0; i < n; i++ {
			Printf("%d ", res[i]+s)
			s = 0
		}
		Println()
	}
}


Given a set of integers (it can contain equal elements).You have to split it into two subsets $$$A$$$ and $$$B$$$ (both of them can contain equal elements or be empty). You have to maximize the value of $$$mex(A)+mex(B)$$$.Here $$$mex$$$ of a set denotes the smallest non-negative integer that doesn't exist in the set. For example:   $$$mex(\{1,4,0,2,2,1\})=3$$$  $$$mex(\{3,3,2,1,3,0,0\})=4$$$  $$$mex(\varnothing)=0$$$ ($$$mex$$$ for empty set) The set is splitted into two subsets $$$A$$$ and $$$B$$$ if for any integer number $$$x$$$ the number of occurrences of $$$x$$$ into this set is equal to the sum of the number of occurrences of $$$x$$$ into $$$A$$$ and the number of occurrences of $$$x$$$ into $$$B$$$.

The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1\leq t\leq 100$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$1\leq n\leq 100$$$) — the size of the set. The second line of each testcase contains $$$n$$$ integers $$$a_1,a_2,\dots a_n$$$ ($$$0\leq a_i\leq 100$$$) — the numbers in the set.

For each test case, print the maximum value of $$$mex(A)+mex(B)$$$.

NoteIn the first test case, $$$A=\left\{0,1,2\right\},B=\left\{0,1,5\right\}$$$ is a possible choice.In the second test case, $$$A=\left\{0,1,2\right\},B=\varnothing$$$ is a possible choice.In the third test case, $$$A=\left\{0,1,2\right\},B=\left\{0\right\}$$$ is a possible choice.In the fourth test case, $$$A=\left\{1,3,5\right\},B=\left\{2,4,6\right\}$$$ is a possible choice.

package main

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

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

	for t := io.NextInt(); t > 0; t-- {
		n := io.NextInt()
		a := io.NextInts(n)

		sort.Ints(a)
		mex, mex2 := 0, 0
		for _, x := range a {
			if x == mex {
				mex++
			} else if x > mex {
				break
			} else if x == mex2 {
				mex2++
			}
		}
		io.Println(mex + mex2)
	}
}

type FastIO struct {
	*bufio.Writer
	r    io.Reader
	buf  [8192]byte
	i, n int
}

func NewFastIO(r io.Reader, w io.Writer) *FastIO {
	return &FastIO{r: r, Writer: bufio.NewWriter(w)}
}

func (f *FastIO) readC() byte {
	if f.i == f.n {
		f.n, _ = f.r.Read(f.buf[:])
		if f.n == 0 {
			panic("EOF")
		}
		f.i = 0
	}
	f.i++
	return f.buf[f.i-1]
}

func (f *FastIO) NextInt() int {
	c := f.readC()
	for ; c <= ' '; c = f.readC() {
	}
	neg := false
	if c == '-' {
		neg = true
		c = f.readC()
	}
	n := 0
	for ; '0' <= c && c <= '9'; c = f.readC() {
		n = n*10 + int(c) - '0'
	}
	if neg {
		return -n
	}
	return n
}

func (f *FastIO) NextInts(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = f.NextInt()
	}
	return a
}

func (f *FastIO) Println(a ...interface{}) {
	fmt.Fprintln(f, a...)
}

package main

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

func maxM(arr []int) int {
	a := make([]int, 101)
	for _, el := range arr {
		a[el] += 1
	}

	i := 0
	for ; i < len(a) && a[i] >= 2; i ++ {

	}

	j := i
	for ; j < len(a) && a[j] >= 1; j++ {

	}

	return i + j
}

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 main() {
	defer writer.Flush()
	var t int
	scanf("%d\n", &t)
	for i := 0; i < t; i ++ {
		var N int
		scanf("%d\n", &N)

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

package main

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

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 main() {
	defer writer.Flush()

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

	for t > 0 {

		var n int

		scanf("%d\n", &n)
		arr := make([]int, n)

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

		scanf("\n")

		sort.Ints(arr)
		mexA := 0
		mexB := 0
		ans := 0
		for i := 0; i < n; i++ {
			if arr[i] == mexA {
				mexA++
			} else {
				if arr[i] == mexB {
					mexB++
				}
			}
		}

		ans = mexA + mexB

		// printf("%v\n", arr)
		printf("%d\n", ans)
		t--
	}
}

/*
URL:
https://codeforces.com/contest/1406/problem/A
*/

package main

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

var (
	t int

	n    int
	A    []int
	cnts [100 + 5]int
)

func main() {
	defer stdout.Flush()

	t = readi()
	for tc := 0; tc < t; tc++ {
		n = readi()
		A = readis(n)

		solve()
	}
}

func solve() {
	cnts = [100 + 5]int{}
	// for i := 0; i <= 100; i++ {
	// 	cnts[i] = 0
	// }

	for _, a := range A {
		cnts[a]++
	}

	C, D := []int{}, []int{}
	for i := 0; i <= 100; i++ {
		if cnts[i] == 0 {
			break
		}

		if cnts[i] == 1 {
			C = append(C, i)
		} else if cnts[i] >= 2 {
			C = append(C, i)
			D = append(D, i)
		}
	}

	cmemo, dmemo := [100 + 5]int{}, [100 + 5]int{}
	for _, c := range C {
		cmemo[c]++
	}
	for _, d := range D {
		dmemo[d]++
	}

	a, b := 0, 0
	for i := 0; i <= 101; i++ {
		if cmemo[i] == 0 {
			a = i
			break
		}
	}
	for i := 0; i <= 101; i++ {
		if dmemo[i] == 0 {
			b = i
			break
		}
	}

	fmt.Println(a + b)
}

/*******************************************************************/

/********** common constants **********/

const (
	MOD = 1000000000 + 7
	// MOD          = 998244353
	ALPH_N  = 26
	INF_I64 = math.MaxInt64
	INF_B60 = 1 << 60
	INF_I32 = math.MaxInt32
	INF_B30 = 1 << 30
	NIL     = -1
)

// modi can calculate a right residual whether value is positive or negative.
func modi(val, m int) int {
	res := val % m
	if res < 0 {
		res += m
	}
	return res
}

// modll can calculate a right residual whether value is positive or negative.
func modll(val, m int64) int64 {
	res := val % m
	if res < 0 {
		res += m
	}
	return res
}

/********** bufio setting **********/

func init() {
	// bufio.ScanWords <---> bufio.ScanLines
	reads = newReadString(os.Stdin, bufio.ScanWords)
	stdout = bufio.NewWriter(os.Stdout)
}

/********** FAU standard libraries **********/

//fmt.Sprintf("%b\n", 255) 	// binary expression

/********** I/O usage **********/

//str := reads()
//i := readi()
//X := readis(n)
//S := readrs()
//a := readf()
//A := readfs(n)

//str := ZeroPaddingRuneSlice(num, 32)
//str := PrintIntsLine(X...)

/*********** Input ***********/

var (
	// reads returns a WORD string.
	reads  func() string
	stdout *bufio.Writer
)

func newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	r.Split(sf)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

// readi returns an integer.
func readi() int {
	return int(_readInt64())
}
func readi2() (int, int) {
	return int(_readInt64()), int(_readInt64())
}
func readi3() (int, int, int) {
	return int(_readInt64()), int(_readInt64()), int(_readInt64())
}
func readi4() (int, int, int, int) {
	return int(_readInt64()), int(_readInt64()), int(_readInt64()), int(_readInt64())
}

// readll returns as integer as int64.
func readll() int64 {
	return _readInt64()
}
func readll2() (int64, int64) {
	return _readInt64(), _readInt64()
}
func readll3() (int64, int64, int64) {
	return _readInt64(), _readInt64(), _readInt64()
}
func readll4() (int64, int64, int64, int64) {
	return _readInt64(), _readInt64(), _readInt64(), _readInt64()
}

func _readInt64() int64 {
	i, err := strconv.ParseInt(reads(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// readis returns an integer slice that has n integers.
func readis(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readi()
	}
	return b
}

// readlls returns as int64 slice that has n integers.
func readlls(n int) []int64 {
	b := make([]int64, n)
	for i := 0; i < n; i++ {
		b[i] = readll()
	}
	return b
}

// readf returns an float64.
func readf() float64 {
	return float64(_readFloat64())
}

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

// ReadFloatSlice returns an float64 slice that has n float64.
func readfs(n int) []float64 {
	b := make([]float64, n)
	for i := 0; i < n; i++ {
		b[i] = readf()
	}
	return b
}

// readrs returns a rune slice.
func readrs() []rune {
	return []rune(reads())
}

/*********** Output ***********/

// PrintIntsLine returns integers string delimited by a space.
func PrintIntsLine(A ...int) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.Itoa(A[i])
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintIntsLine returns integers string delimited by a space.
func PrintInts64Line(A ...int64) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.FormatInt(A[i], 10) // 64bit int version
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// Printf is function for output strings to buffered os.Stdout.
// You may have to call stdout.Flush() finally.
func printf(format string, a ...interface{}) {
	fmt.Fprintf(stdout, format, a...)
}

/*********** Debugging ***********/

// debugf is wrapper of fmt.Fprintf(os.Stderr, format, a...)
func debugf(format string, a ...interface{}) {
	fmt.Fprintf(os.Stderr, format, a...)
}

// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.
// For debugging use.
func ZeroPaddingRuneSlice(n, digitsNum int) []rune {
	sn := fmt.Sprintf("%b", n)

	residualLength := digitsNum - len(sn)
	if residualLength <= 0 {
		return []rune(sn)
	}

	zeros := make([]rune, residualLength)
	for i := 0; i < len(zeros); i++ {
		zeros[i] = '0'
	}

	res := []rune{}
	res = append(res, zeros...)
	res = append(res, []rune(sn)...)

	return res
}

package main

import (
	"fmt"
)

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

	for t != 0 {
		fmt.Scan(&n)
		var arr []int = make([]int, n)
		var count [101]int
		for i := 0; i < n; i++ {
			fmt.Scan(&arr[i])
			count[arr[i]]++
		}
		mexa := 0
		mexb := 0
		for i := 0; i < 101; i++ {
			if count[i] == 0 {
				mexa = i
				break
			}
		}
		for i := 0; i < 101; i++ {
			if count[i] <= 1 {
				mexb = i
				break
			}
		}
		fmt.Println(mexa + mexb)
		t--
	}
}

// 0 1 2 3
// 2 0 1 0

package main

import (
	"fmt"
	"sort"
)

func main() {
	var t int
	fmt.Scanf("%d\n", &t)
	for i := 0; i < t; i++ {
		var n int
		fmt.Scanf("%d\n", &n)
		var a []int
		for j := 0; j < n; j++ {
			var g int
			fmt.Scanf("%d", &g)
			a = append(a, g)
			if j != n-1 {
				fmt.Scan(" ")
			} else {
				fmt.Scanln()
			}
		}
		sort.Ints(a)
		l := -1
		r := -1
		for _, el := range a {
			if el == l+1 {
				l++
			} else {
				if el == r+1 {
					r++
				}
			}
		}
		fmt.Printf("%d\n", l+r+2)
	}
}

package main

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

var rw = NewFastIO(os.Stdin, os.Stdout)

func main() {
	defer rw.Flush()
	tt := rw.NextInt()
	for i := 0; i < tt; i++ {
		solveCase()
	}
}

func solveCase() {
	n := rw.NextInt()
	a := rw.NextInts(n)
	sort.Slice(a[:], func(i, j int) bool { return a[i] < a[j] })
	x, y := 0, 0
	for _, e := range a {
		if e == x {
			x++
		} else if e == y {
			y++
		}
	}
	rw.Println(x + y)
}

// @meooow template uwu
type FastIO struct {
	*bufio.Writer
	r    io.Reader
	buf  [8192]byte
	i, n int
}

func NewFastIO(r io.Reader, w io.Writer) *FastIO {
	return &FastIO{r: r, Writer: bufio.NewWriter(w)}
}

func (f *FastIO) readC() byte {
	if f.i == f.n {
		f.n, _ = f.r.Read(f.buf[:])
		if f.n == 0 {
			panic("EOF")
		}
		f.i = 0
	}
	f.i++
	return f.buf[f.i-1]
}

func (f *FastIO) Next() string {
	c := f.readC()
	for ; c <= ' '; c = f.readC() {
	}
	var s []byte
	for ; c > ' '; c = f.readC() {
		s = append(s, c)
	}
	return string(s)
}

func (f *FastIO) NextInt() int {
	c := f.readC()
	for ; c <= ' '; c = f.readC() {
	}
	neg := false
	if c == '-' {
		neg = true
		c = f.readC()
	}
	n := 0
	for ; '0' <= c && c <= '9'; c = f.readC() {
		n = n*10 + int(c) - '0'
	}
	if neg {
		return -n
	}
	return n
}
func (f *FastIO) NextInt64() int64 {
	c := f.readC()
	for ; c <= ' '; c = f.readC() {
	}
	neg := false
	if c == '-' {
		neg = true
		c = f.readC()
	}
	n := int64(0)
	for ; '0' <= c && c <= '9'; c = f.readC() {
		n = n*10 + int64(c) - '0'
	}
	if neg {
		return -n
	}
	return n
}

func (f *FastIO) NextInts(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = f.NextInt()
	}
	return a
}
func (f *FastIO) NextInt64s(n int) []int64 {
	a := make([]int64, n)
	for i := 0; i < n; i++ {
		a[i] = f.NextInt64()
	}
	return a
}

func (f *FastIO) Println(a ...interface{}) {
	fmt.Fprintln(f, a...)
}

func (f *FastIO) Print(a ...interface{}) {
	fmt.Fprint(f, a...)
}
func (f *FastIO) PrintInts(a ...int) {
	if len(a) > 0 {
		f.Print(a[0])
		for _, x := range a[1:] {
			f.Print(" ", x)
		}
	}
}
func (f *FastIO) PrintlnInts(a ...int) {
	f.PrintInts(a...)
	f.Println()
}
func (f *FastIO) PrintInt64s(a ...int64) {
	if len(a) > 0 {
		f.Print(a[0])
		for _, x := range a[1:] {
			f.Print(" ", x)
		}
	}
}
func (f *FastIO) PrintlnInt64s(a ...int64) {
	f.PrintInt64s(a...)
	f.Println()
}

package main

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

func subsetMex(a []int, n int) int {
	countArr := make([]int, 101)
	for _, ai := range a {
		countArr[ai] += 1
	}
	mexA := 0
	for ; mexA <= 100 && countArr[mexA] >= 2; mexA++ {
	}
	if mexA > 100 || countArr[mexA] == 0 {
		return mexA << 1
	}
	mexB := mexA + 1
	for ; mexB <= 100 && countArr[mexB] >= 1; mexB++ {
	}
	return mexA + mexB
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	var n, t, ans int
	fmt.Fscanln(reader, &t)
	for i := 0; i < t; i++ {
		fmt.Fscanln(reader, &n)
		a := make([]int, n)
		for i := 0; i < n-1; i++ {
			fmt.Fscanf(reader, "%d ", &a[i])
		}
		fmt.Fscanf(reader, "%d\n", &a[n-1])
		ans = subsetMex(a, n)
		fmt.Fprintln(writer, ans)
	}
}

package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	testCasesCount, _ := strconv.Atoi(scanner.Text())
	for i := 0; i < testCasesCount; i++ {
		scanner.Scan()
		scanner.Scan()
		buffer := scanner.Text()
		stringSlices := strings.Split(buffer, " ")

		input := make([]int, 101)
		for _, str := range stringSlices {
			v, _ := strconv.Atoi(str)
			input[v]++
		}
		mexs := make([]int, 0)
		for j := 0; j < 102; j++ {
			if input[j] == 0 {
				mexs = append(mexs, j)
				mexs = append(mexs, j)
			} else if input[j] == 1 && len(mexs) == 0 {
				mexs = append(mexs, j)
			}
			if len(mexs) >= 2 {
				break
			}
		}
		result := 0
		for idx, mex := range mexs {
			if idx >= 2 {
				break
			}
			result += mex
		}
		fmt.Println(result)
	}
}

package main

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

const (
	SCANNER_BUF_SIZE = 2 << 20

	INF = int64(math.MaxInt64)
	MOD = 1e9 + 7
)

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

func init() {
	writer = bufio.NewWriter(os.Stdout)
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, SCANNER_BUF_SIZE), SCANNER_BUF_SIZE)
}

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

func sint64() int64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := int64(0)
	if bb[0] == '-' {
		for _, b := range bb[1:] {
			i *= 10
			i -= int64(b - '0')
		}
		return i
	}
	for _, b := range bb {
		i *= 10
		i += int64(b - '0')
	}
	return i
}

func suint64() uint64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := uint64(0)
	for _, b := range bb {
		i *= 10
		i += uint64(b - '0')
	}
	return i
}

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

func gcd(a, b int64) int64 {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

func lcm(a, b int64) int64 {
	return a * b / gcd(a, b)
}

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

func min(a int64, rest ...int64) int64 {
	for _, r := range rest {
		if r < a {
			a = r
		}
	}
	return a
}

func max(a int64, rest ...int64) int64 {
	for _, r := range rest {
		if r > a {
			a = r
		}
	}
	return a
}

func main() {
	defer writer.Flush()
	t := sint64()
	for ; t > 0; t-- {
		n := sint64()
		a := make([]int64, n)
		for i := range a {
			a[i] = sint64()
		}
		printf("%d\n", sol(a))
	}
}

func sol(a []int64) int64 {
	m := map[int64]int64{}
	for i := range a {
		m[a[i]]++
	}
	ret1 := int64(0)
	ret2 := int64(0)
	for i := int64(0); ; i++ {
		if m[i] >= 2 {
			if ret1 == i {
				ret1 = i+1
			}
			if ret2 == i {
				ret2 = i+1
			}
			continue
		}
		if m[i] == 1 {
			if ret1 == i {
				ret1 = i+1
			}
			continue
		}
		break
	}
	return ret1 + ret2
}

package main

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

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 main() {
	defer writer.Flush()

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

	for t > 0 {

		var n int

		scanf("%d\n", &n)
		arr := make([]int, n)

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

		scanf("\n")

		sort.Ints(arr)
		mexA := 0
		mexB := 0
		ans := 0
		for i := 0; i < n; i++ {
			if arr[i] == mexA {
				mexA++
			} else {
				if arr[i] == mexB {
					mexB++
				}
			}
		}

		ans = mexA + mexB

		printf("%v\n", arr)
		printf("%d\n", ans)
		t--
	}
}

package main

import (
	"fmt"
	"sort"
)

func mex(a []int) int {
	var arr = make([]int, len(a))
	copy(arr, a)
	if len(arr) == 0 {
		return 0
	}
	sort.Ints(arr)
	var i, j int = 0, 0
	for i < len(arr) {
		if j == arr[i] {
			for i < len(arr) && arr[i] == j {
				i++
			}
			j++
		} else {
			break
		}
	}
	return j
}

// 0013
func main() {
	var t, n int
	fmt.Scan(&t)

	for t != 0 {
		fmt.Scan(&n)
		var arr []int = make([]int, n)
		// var count map[int]int = make(map[int]int)
		for i := 0; i < n; i++ {
			fmt.Scan(&arr[i])
			// count[arr[i]]++
		}
		maxmex := 0
		for i := 0; i < n; i++ {
			// if count[arr[i]]%2 == 0 {
			// fmt.Println(arr[:i+1], mex(arr[:i+1]))
			// fmt.Println(arr[i+1:], mex(arr[i+1:]))
			mex := mex(arr[:i+1]) + mex(arr[i+1:])
			if maxmex < mex {
				maxmex = mex
			}
			// }
		}
		fmt.Println(maxmex)
		t--
	}
}

package main

import (
	"fmt"
	"sort"
)

func main() {
	var t int
	fmt.Scanf("%d\n", &t)
	for i := 0; i < t; i++ {
		var n int
		fmt.Scanf("%d\n", &n)
		var a []int
		for j := 0; j < n; j++ {
			var g int
			fmt.Scanf("%d", &g)
			a = append(a, g)
			if j != n-1 {
				fmt.Scan(" ")
			} else {
				fmt.Scan("\n")
			}
		}
		sort.Ints(a)
		l := -1
		r := -1
		for _, el := range a {
			if el == l+1 {
				l++
			} else {
				if el == r+1 {
					r++
				}
			}
		}
		fmt.Printf("%d\n", l+r+2)
	}
}


Bob is an avid fan of the video game "League of Leesins", and today he celebrates as the League of Leesins World Championship comes to an end! The tournament consisted of $$$n$$$ ($$$n \ge 5$$$) teams around the world. Before the tournament starts, Bob has made a prediction of the rankings of each team, from $$$1$$$-st to $$$n$$$-th. After the final, he compared the prediction with the actual result and found out that the $$$i$$$-th team according to his prediction ended up at the $$$p_i$$$-th position ($$$1 \le p_i \le n$$$, all $$$p_i$$$ are unique). In other words, $$$p$$$ is a permutation of $$$1, 2, \dots, n$$$.As Bob's favorite League player is the famous "3ga", he decided to write down every $$$3$$$ consecutive elements of the permutation $$$p$$$. Formally, Bob created an array $$$q$$$ of $$$n-2$$$ triples, where $$$q_i = (p_i, p_{i+1}, p_{i+2})$$$ for each $$$1 \le i \le n-2$$$. Bob was very proud of his array, so he showed it to his friend Alice.After learning of Bob's array, Alice declared that she could retrieve the permutation $$$p$$$ even if Bob rearranges the elements of $$$q$$$ and the elements within each triple. Of course, Bob did not believe in such magic, so he did just the same as above to see Alice's respond.For example, if $$$n = 5$$$ and $$$p = [1, 4, 2, 3, 5]$$$, then the original array $$$q$$$ will be $$$[(1, 4, 2), (4, 2, 3), (2, 3, 5)]$$$. Bob can then rearrange the numbers within each triple and the positions of the triples to get $$$[(4, 3, 2), (2, 3, 5), (4, 1, 2)]$$$. Note that $$$[(1, 4, 2), (4, 2, 2), (3, 3, 5)]$$$ is not a valid rearrangement of $$$q$$$, as Bob is not allowed to swap numbers belong to different triples.As Alice's friend, you know for sure that Alice was just trying to show off, so you decided to save her some face by giving her any permutation $$$p$$$ that is consistent with the array $$$q$$$ she was given.

The first line contains a single integer $$$n$$$ ($$$5 \le n \le 10^5$$$) — the size of permutation $$$p$$$. The $$$i$$$-th of the next $$$n-2$$$ lines contains $$$3$$$ integers $$$q_{i, 1}$$$, $$$q_{i, 2}$$$, $$$q_{i, 3}$$$ ($$$1 \le q_{i, j} \le n$$$) — the elements of the $$$i$$$-th triple of the rearranged (shuffled) array $$$q_i$$$, in random order. Remember, that the numbers within each triple can be rearranged and also the positions of the triples can be rearranged. It is guaranteed that there is at least one permutation $$$p$$$ that is consistent with the input.

Print $$$n$$$ distinct integers $$$p_1, p_2, \ldots, p_n$$$ ($$$1 \le p_i \le n$$$) such that $$$p$$$ is consistent with array $$$q$$$.  If there are multiple answers, print any.

package main

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

/*********** I/O ***********/

var (
	// ReadString returns a WORD string.
	ReadString func() string
	stdout     *bufio.Writer
)

func init() {
	ReadString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	// r.Buffer(make([]byte, 1024), int(1e+11)) // for AtCoder
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	// Split sets the split function for the Scanner. The default split function is ScanLines.
	// Split panics if it is called after scanning has started.
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

// ReadInt returns an integer.
func ReadInt() int {
	return int(readInt64())
}
func ReadInt2() (int, int) {
	return int(readInt64()), int(readInt64())
}
func ReadInt3() (int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64())
}
func ReadInt4() (int, int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())
}

// ReadInt64 returns as integer as int64.
func ReadInt64() int64 {
	return readInt64()
}
func ReadInt64_2() (int64, int64) {
	return readInt64(), readInt64()
}
func ReadInt64_3() (int64, int64, int64) {
	return readInt64(), readInt64(), readInt64()
}
func ReadInt64_4() (int64, int64, int64, int64) {
	return readInt64(), readInt64(), readInt64(), readInt64()
}

func readInt64() int64 {
	i, err := strconv.ParseInt(ReadString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// ReadIntSlice returns an integer slice that has n integers.
func ReadIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt()
	}
	return b
}

// ReadInt64Slice returns as int64 slice that has n integers.
func ReadInt64Slice(n int) []int64 {
	b := make([]int64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt64()
	}
	return b
}

// ReadFloat64 returns an float64.
func ReadFloat64() float64 {
	return float64(readFloat64())
}

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

// ReadFloatSlice returns an float64 slice that has n float64.
func ReadFloat64Slice(n int) []float64 {
	b := make([]float64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadFloat64()
	}
	return b
}

// ReadRuneSlice returns a rune slice.
func ReadRuneSlice() []rune {
	return []rune(ReadString())
}

/*********** Debugging ***********/

// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.
// For debugging use.
func ZeroPaddingRuneSlice(n, digitsNum int) []rune {
	sn := fmt.Sprintf("%b", n)

	residualLength := digitsNum - len(sn)
	if residualLength <= 0 {
		return []rune(sn)
	}

	zeros := make([]rune, residualLength)
	for i := 0; i < len(zeros); i++ {
		zeros[i] = '0'
	}

	res := []rune{}
	res = append(res, zeros...)
	res = append(res, []rune(sn)...)

	return res
}

/*********** DP sub-functions ***********/

// ChMin accepts a pointer of integer and a target value.
// If target value is SMALLER than the first argument,
//	then the first argument will be updated by the second argument.
func ChMin(updatedValue *int, target int) bool {
	if *updatedValue > target {
		*updatedValue = target
		return true
	}
	return false
}

// ChMax accepts a pointer of integer and a target value.
// If target value is LARGER than the first argument,
//	then the first argument will be updated by the second argument.
func ChMax(updatedValue *int, target int) bool {
	if *updatedValue < target {
		*updatedValue = target
		return true
	}
	return false
}

// NthBit returns nth bit value of an argument.
// n starts from 0.
func NthBit(num, nth int) int {
	return num >> uint(nth) & 1
}

// OnBit returns the integer that has nth ON bit.
// If an argument has nth ON bit, OnBit returns the argument.
func OnBit(num, nth int) int {
	return num | (1 << uint(nth))
}

// OffBit returns the integer that has nth OFF bit.
// If an argument has nth OFF bit, OffBit returns the argument.
func OffBit(num, nth int) int {
	return num & ^(1 << uint(nth))
}

// PopCount returns the number of ON bit of an argument.
func PopCount(num int) int {
	res := 0

	for i := 0; i < 70; i++ {
		if ((num >> uint(i)) & 1) == 1 {
			res++
		}
	}

	return res
}

/*********** Arithmetic ***********/

// Max returns the max integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func Max(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m < integer {
			m = integer
		}
	}
	return m
}

// Min returns the min integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func Min(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m > integer {
			m = integer
		}
	}
	return m
}

// Sum returns multiple integers sum.
func Sum(integers ...int) int {
	s := 0

	for _, i := range integers {
		s += i
	}

	return s
}

// PowInt is integer version of math.Pow
// PowInt calculate a power by Binary Power (二分累乗法(O(log e))).
func PowInt(a, e int) int {
	if a < 0 || e < 0 {
		panic(errors.New("[argument error]: PowInt does not accept negative integers"))
	}

	if e == 0 {
		return 1
	}

	if e%2 == 0 {
		halfE := e / 2
		half := PowInt(a, halfE)
		return half * half
	}

	return a * PowInt(a, e-1)
}

// AbsInt is integer version of math.Abs
func AbsInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

// Gcd returns the Greatest Common Divisor of two natural numbers.
// Gcd only accepts two natural numbers (a, b >= 1).
// 0 or negative number causes panic.
// Gcd uses the Euclidean Algorithm.
func Gcd(a, b int) int {
	if a <= 0 || b <= 0 {
		panic(errors.New("[argument error]: Gcd only accepts two NATURAL numbers"))
	}
	if a < b {
		a, b = b, a
	}

	// Euclidean Algorithm
	for b > 0 {
		div := a % b
		a, b = b, div
	}

	return a
}

// Lcm returns the Least Common Multiple of two natural numbers.
// Lcd only accepts two natural numbers (a, b >= 1).
// 0 or negative number causes panic.
// Lcd uses the Euclidean Algorithm indirectly.
func Lcm(a, b int) int {
	if a <= 0 || b <= 0 {
		panic(errors.New("[argument error]: Gcd only accepts two NATURAL numbers"))
	}

	// a = a'*gcd, b = b'*gcd, a*b = a'*b'*gcd^2
	// a' and b' are relatively prime numbers
	// gcd consists of prime numbers, that are included in a and b
	gcd := Gcd(a, b)

	// not (a * b / gcd), because of reducing a probability of overflow
	return (a / gcd) * b
}

// Strtoi is a wrapper of strconv.Atoi().
// If strconv.Atoi() returns an error, Strtoi calls panic.
func Strtoi(s string) int {
	if i, err := strconv.Atoi(s); err != nil {
		panic(errors.New("[argument error]: Strtoi only accepts integer string"))
	} else {
		return i
	}
}

// PrintIntsLine returns integers string delimited by a space.
func PrintIntsLine(A ...int) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.Itoa(A[i])
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintIntsLine returns integers string delimited by a space.
func PrintInts64Line(A ...int64) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.FormatInt(A[i], 10) // 64bit int version
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

/********** FAU standard libraries **********/

//fmt.Sprintf("%b\n", 255) 	// binary expression

/********** I/O usage **********/

//str := ReadString()
//i := ReadInt()
//X := ReadIntSlice(n)
//S := ReadRuneSlice()
//a := ReadFloat64()
//A := ReadFloat64Slice(n)

//str := ZeroPaddingRuneSlice(num, 32)
//str := PrintIntsLine(X...)

/*******************************************************************/

const MOD = 1000000000 + 7
const ALPHABET_NUM = 26
const INF_INT64 = math.MaxInt64
const INF_BIT60 = 1 << 60

var n int
var T [][]int

type Triple struct {
	key     int
	a, b, c int
}
type TripleList []*Triple
type byKey struct {
	TripleList
}

func (l TripleList) Len() int {
	return len(l)
}
func (l TripleList) Swap(i, j int) {
	l[i], l[j] = l[j], l[i]
}

func (l byKey) Less(i, j int) bool {
	return l.TripleList[i].key < l.TripleList[j].key
}

// how to use
// L := make(TripleList, 0, 200000+5)
// L = append(L, &Triple{key: intValue})
// sort.Stable(byKey{ L })                // Stable ASC
// sort.Stable(sort.Reverse(byKey{ L }))  // Stable DESC

// L := make(TripleList, 0)
// for i := 0; i < n-2; i++ {
// 	sort.Sort(sort.IntSlice(T[i]))
// 	L = append(L, &Triple{key: T[i][0], a: T[i][0], b: T[i][1], c: T[i][2]})
// }
// sort.Stable(byKey{L})

var book [100000 + 5][][]int

func main() {
	n = ReadInt()
	for i := 0; i < n-2; i++ {
		T = append(T, ReadIntSlice(3))
	}

	memo := make([]int, n+1)
	for i := 0; i < n-2; i++ {
		for j := 0; j < 3; j++ {
			q := T[i][j]
			memo[q]++
		}
	}

	ones := []int{}
	twos := []int{}
	for i := 1; i < n+1; i++ {
		if memo[i] == 1 {
			ones = append(ones, i)
		} else if memo[i] == 2 {
			twos = append(twos, i)
		}
	}

	for i := 0; i < n-2; i++ {
		a, b, c := T[i][0], T[i][1], T[i][2]
		book[a] = append(book[a], []int{a, b, c})
		book[b] = append(book[b], []int{a, b, c})
		book[c] = append(book[c], []int{a, b, c})
	}

	// 先頭のトリプルを見つける
	targetInt := ones[0]
	firstTriple := book[targetInt][0]
	answers := make([]int, 3)
	for i := 0; i < 3; i++ {
		tmp := firstTriple[i]
		if memo[tmp] == 1 {
			answers[0] = tmp
		} else if memo[tmp] == 2 {
			answers[1] = tmp
		} else {
			answers[2] = tmp
		}
	}

	// answersが完成するまでループ
	for len(answers) < n {
		l := len(answers)
		ex, inc1, inc2 := answers[l-3], answers[l-2], answers[l-1]
		// 最大3つの中から該当するものを見つける
		for _, tri := range book[inc2] {
			if sub(tri, ex, inc1, inc2) {
				// inc1, inc2以外の値をanswersに追加する
				answers = append(answers, subsubsub(tri, inc1, inc2))
				break
			}
		}
	}

	fmt.Println(PrintIntsLine(answers...))
}

// triが目的のものだったらtrue
func sub(tri []int, ex, inc1, inc2 int) bool {
	// exを含んだらfalse
	if subsub(tri, ex) {
		return false
	}

	// inc1を含まないならfalse
	if !subsub(tri, inc1) {
		return false
	}
	// inc2を含まないならfalse
	if !subsub(tri, inc2) {
		return false
	}

	return true
}

// triがtargetを含んだらtrue
func subsub(tri []int, target int) bool {
	for _, v := range tri {
		if v == target {
			return true
		}
	}
	return false
}

// inc1, inc2以外の値を返す
func subsubsub(tri []int, inc1, inc2 int) int {
	for _, v := range tri {
		if v != inc1 && v != inc2 {
			return v
		}
	}
	return -1
}

/*
- MODは最後にとりましたか？
- ループを抜けた後も処理が必要じゃありませんか？
- 和・積・あまりを求められたらint64が必要ではありませんか？
*/

/*******************************************************************/

package main

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

/*********** I/O ***********/

var (
	// ReadString returns a WORD string.
	ReadString func() string
	stdout     *bufio.Writer
)

func init() {
	ReadString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	// r.Buffer(make([]byte, 1024), int(1e+11)) // for AtCoder
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	// Split sets the split function for the Scanner. The default split function is ScanLines.
	// Split panics if it is called after scanning has started.
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

// ReadInt returns an integer.
func ReadInt() int {
	return int(readInt64())
}
func ReadInt2() (int, int) {
	return int(readInt64()), int(readInt64())
}
func ReadInt3() (int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64())
}
func ReadInt4() (int, int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())
}

// ReadInt64 returns as integer as int64.
func ReadInt64() int64 {
	return readInt64()
}
func ReadInt64_2() (int64, int64) {
	return readInt64(), readInt64()
}
func ReadInt64_3() (int64, int64, int64) {
	return readInt64(), readInt64(), readInt64()
}
func ReadInt64_4() (int64, int64, int64, int64) {
	return readInt64(), readInt64(), readInt64(), readInt64()
}

func readInt64() int64 {
	i, err := strconv.ParseInt(ReadString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// ReadIntSlice returns an integer slice that has n integers.
func ReadIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt()
	}
	return b
}

// ReadInt64Slice returns as int64 slice that has n integers.
func ReadInt64Slice(n int) []int64 {
	b := make([]int64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt64()
	}
	return b
}

// ReadFloat64 returns an float64.
func ReadFloat64() float64 {
	return float64(readFloat64())
}

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

// ReadFloatSlice returns an float64 slice that has n float64.
func ReadFloat64Slice(n int) []float64 {
	b := make([]float64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadFloat64()
	}
	return b
}

// ReadRuneSlice returns a rune slice.
func ReadRuneSlice() []rune {
	return []rune(ReadString())
}

/*********** Debugging ***********/

// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.
// For debugging use.
func ZeroPaddingRuneSlice(n, digitsNum int) []rune {
	sn := fmt.Sprintf("%b", n)

	residualLength := digitsNum - len(sn)
	if residualLength <= 0 {
		return []rune(sn)
	}

	zeros := make([]rune, residualLength)
	for i := 0; i < len(zeros); i++ {
		zeros[i] = '0'
	}

	res := []rune{}
	res = append(res, zeros...)
	res = append(res, []rune(sn)...)

	return res
}

/*********** DP sub-functions ***********/

// ChMin accepts a pointer of integer and a target value.
// If target value is SMALLER than the first argument,
//	then the first argument will be updated by the second argument.
func ChMin(updatedValue *int, target int) bool {
	if *updatedValue > target {
		*updatedValue = target
		return true
	}
	return false
}

// ChMax accepts a pointer of integer and a target value.
// If target value is LARGER than the first argument,
//	then the first argument will be updated by the second argument.
func ChMax(updatedValue *int, target int) bool {
	if *updatedValue < target {
		*updatedValue = target
		return true
	}
	return false
}

// NthBit returns nth bit value of an argument.
// n starts from 0.
func NthBit(num, nth int) int {
	return num >> uint(nth) & 1
}

// OnBit returns the integer that has nth ON bit.
// If an argument has nth ON bit, OnBit returns the argument.
func OnBit(num, nth int) int {
	return num | (1 << uint(nth))
}

// OffBit returns the integer that has nth OFF bit.
// If an argument has nth OFF bit, OffBit returns the argument.
func OffBit(num, nth int) int {
	return num & ^(1 << uint(nth))
}

// PopCount returns the number of ON bit of an argument.
func PopCount(num int) int {
	res := 0

	for i := 0; i < 70; i++ {
		if ((num >> uint(i)) & 1) == 1 {
			res++
		}
	}

	return res
}

/*********** Arithmetic ***********/

// Max returns the max integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func Max(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m < integer {
			m = integer
		}
	}
	return m
}

// Min returns the min integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func Min(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m > integer {
			m = integer
		}
	}
	return m
}

// Sum returns multiple integers sum.
func Sum(integers ...int) int {
	s := 0

	for _, i := range integers {
		s += i
	}

	return s
}

// PowInt is integer version of math.Pow
// PowInt calculate a power by Binary Power (二分累乗法(O(log e))).
func PowInt(a, e int) int {
	if a < 0 || e < 0 {
		panic(errors.New("[argument error]: PowInt does not accept negative integers"))
	}

	if e == 0 {
		return 1
	}

	if e%2 == 0 {
		halfE := e / 2
		half := PowInt(a, halfE)
		return half * half
	}

	return a * PowInt(a, e-1)
}

// AbsInt is integer version of math.Abs
func AbsInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

// Gcd returns the Greatest Common Divisor of two natural numbers.
// Gcd only accepts two natural numbers (a, b >= 1).
// 0 or negative number causes panic.
// Gcd uses the Euclidean Algorithm.
func Gcd(a, b int) int {
	if a <= 0 || b <= 0 {
		panic(errors.New("[argument error]: Gcd only accepts two NATURAL numbers"))
	}
	if a < b {
		a, b = b, a
	}

	// Euclidean Algorithm
	for b > 0 {
		div := a % b
		a, b = b, div
	}

	return a
}

// Lcm returns the Least Common Multiple of two natural numbers.
// Lcd only accepts two natural numbers (a, b >= 1).
// 0 or negative number causes panic.
// Lcd uses the Euclidean Algorithm indirectly.
func Lcm(a, b int) int {
	if a <= 0 || b <= 0 {
		panic(errors.New("[argument error]: Gcd only accepts two NATURAL numbers"))
	}

	// a = a'*gcd, b = b'*gcd, a*b = a'*b'*gcd^2
	// a' and b' are relatively prime numbers
	// gcd consists of prime numbers, that are included in a and b
	gcd := Gcd(a, b)

	// not (a * b / gcd), because of reducing a probability of overflow
	return (a / gcd) * b
}

// Strtoi is a wrapper of strconv.Atoi().
// If strconv.Atoi() returns an error, Strtoi calls panic.
func Strtoi(s string) int {
	if i, err := strconv.Atoi(s); err != nil {
		panic(errors.New("[argument error]: Strtoi only accepts integer string"))
	} else {
		return i
	}
}

// PrintIntsLine returns integers string delimited by a space.
func PrintIntsLine(A ...int) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.Itoa(A[i])
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintIntsLine returns integers string delimited by a space.
func PrintInts64Line(A ...int64) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.FormatInt(A[i], 10) // 64bit int version
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

/********** FAU standard libraries **********/

//fmt.Sprintf("%b\n", 255) 	// binary expression

/********** I/O usage **********/

//str := ReadString()
//i := ReadInt()
//X := ReadIntSlice(n)
//S := ReadRuneSlice()
//a := ReadFloat64()
//A := ReadFloat64Slice(n)

//str := ZeroPaddingRuneSlice(num, 32)
//str := PrintIntsLine(X...)

/*******************************************************************/

const MOD = 1000000000 + 7
const ALPHABET_NUM = 26
const INF_INT64 = math.MaxInt64
const INF_BIT60 = 1 << 60

var n int
var T [][]int

var book [100000 + 5][][]int // バケット

func main() {
	n = ReadInt()
	for i := 0; i < n-2; i++ {
		T = append(T, ReadIntSlice(3))
	}

	// 頻度をカウント
	memo := make([]int, n+1)
	for i := 0; i < n-2; i++ {
		for j := 0; j < 3; j++ {
			q := T[i][j]
			memo[q]++
		}
	}

	ones := []int{}
	twos := []int{}
	for i := 1; i < n+1; i++ {
		if memo[i] == 1 {
			ones = append(ones, i)
		} else if memo[i] == 2 {
			twos = append(twos, i)
		}
	}

	// バケットでtripleを管理
	for i := 0; i < n-2; i++ {
		a, b, c := T[i][0], T[i][1], T[i][2]
		book[a] = append(book[a], []int{a, b, c})
		book[b] = append(book[b], []int{a, b, c})
		book[c] = append(book[c], []int{a, b, c})
	}

	// 先頭のトリプルを見つけ、元の配列の3番目までを復元する
	targetInt := ones[0]
	firstTriple := book[targetInt][0]
	answers := make([]int, 3)
	for i := 0; i < 3; i++ {
		tmp := firstTriple[i]
		if memo[tmp] == 1 {
			answers[0] = tmp
		} else if memo[tmp] == 2 {
			answers[1] = tmp
		} else {
			answers[2] = tmp
		}
	}

	// 完全に復元されるまでループ
	for len(answers) < n {
		l := len(answers)
		ex, inc1, inc2 := answers[l-3], answers[l-2], answers[l-1]
		// 高々3個のtripleから該当するものを見つける
		for _, tri := range book[inc2] {
			if sub(tri, ex, inc1, inc2) {
				// inc1, inc2以外の値をanswersに追加する
				answers = append(answers, subsubsub(tri, inc1, inc2))
				break
			}
		}
	}

	fmt.Println(PrintIntsLine(answers...))
}

// triが目的のものだったらtrue
func sub(tri []int, ex, inc1, inc2 int) bool {
	// exを含んだらfalse
	if subsub(tri, ex) {
		return false
	}

	// inc1を含まないならfalse
	if !subsub(tri, inc1) {
		return false
	}
	// inc2を含まないならfalse
	if !subsub(tri, inc2) {
		return false
	}

	return true
}

// triがtargetを含んだらtrue
func subsub(tri []int, target int) bool {
	for _, v := range tri {
		if v == target {
			return true
		}
	}
	return false
}

// inc1, inc2以外の値を返す
func subsubsub(tri []int, inc1, inc2 int) int {
	for _, v := range tri {
		if v != inc1 && v != inc2 {
			return v
		}
	}
	return -1
}

/*
- MODは最後にとりましたか？
- ループを抜けた後も処理が必要じゃありませんか？
- 和・積・あまりを求められたらint64が必要ではありませんか？
*/

/*******************************************************************/

package main

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

// github.com/EndlessCheng/codeforces-go
func Sol1255C(reader io.Reader, writer io.Writer) {
	in := bufio.NewReader(reader)
	out := bufio.NewWriter(writer)
	defer out.Flush()
	orderP3 := [6][3]int{{0, 1, 2}, {0, 2, 1}, {1, 0, 2}, {1, 2, 0}, {2, 0, 1}, {2, 1, 0}}

	var n int
	Fscan(in, &n)
	mp := make(map[[2]int][]int, 6*(n-2))
	q := make([][3]int, n-2)
	for i := range q {
		Fscan(in, &q[i][0], &q[i][1], &q[i][2])
		for j, order := range orderP3 {
			pair := [2]int{q[i][order[0]], q[i][order[1]]}
			mp[pair] = append(mp[pair], 6*i+j)
		}
	}

	g := make([][]int, 6*(n-2))
	inDeg := make([]int, len(g))
	for i, qi := range q {
		for j, order := range orderP3 {
			if ws, ok := mp[[2]int{qi[order[1]], qi[order[2]]}]; ok {
				v := 6*i + j
				for _, w := range ws {
					if w/6 != i {
						g[v] = append(g[v], w)
						inDeg[w]++
					}
				}
			}
		}
	}

	vOrder := make([]int, len(inDeg))
	fa := make([]int, len(inDeg))
	for i := range fa {
		fa[i] = -1
	}
	queue := []int{}
	for i, deg := range inDeg {
		if deg == 0 {
			queue = append(queue, i)
		}
	}
	var end int
	for len(queue) > 0 {
		var v int
		v, queue = queue[0], queue[1:]
		for _, w := range g[v] {
			inDeg[w]--
			if inDeg[w] == 0 {
				queue = append(queue, w)
				vOrder[w] = vOrder[v] + 1
				if vOrder[w] == n-3 {
					end = w
				}
				fa[w] = v
			}
		}
	}
	vs := make([]int, 0, n-2)
	for v := end; v != -1; v = fa[v] {
		vs = append(vs, v)
	}
	v := vs[len(vs)-1]
	q0, order0 := q[v/6], orderP3[v%6]
	Fprint(out, q0[order0[0]], q0[order0[1]])
	for i := len(vs) - 1; i >= 0; i-- {
		v = vs[i]
		qv, orderV := q[v/6], orderP3[v%6]
		Fprint(out, " ", qv[orderV[2]])
	}
}

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

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

	m := make(map[int][][2]int)
	cnt := make(map[int]int)

	var a, b, c int
	for i := 0; i < n - 2; i++ {
		fmt.Fscan(in, &a, &b, &c)
		//fmt.Println(m, a, b, c)
		m[a] = append(m[a], [2]int{b, c})
		m[b] = append(m[b], [2]int{a, c})
		m[c] = append(m[c], [2]int{a, b})
		cnt[a]++
		cnt[b]++
		cnt[c]++
	}
	//fmt.Println(m, a, b, c)

	for k, v := range cnt {
		if v == 1 {
			a = k
			if len(m[m[a][0][0]]) == 2 {
				b = m[a][0][0]
				c = m[a][0][1]
			} else {
				b = m[a][0][1]
				c = m[a][0][0]
			}
			break
		}
	}

	fmt.Fprintf(out, "%d %d %d ", a, b, c)
	//fmt.Println(a, b, c)
	for len(m[c]) != 1 {
		for _, arr := range m[b] {
			if arr[0] == c && arr[1] != a {
				a, b, c = b, c, arr[1]
				break
			} else if arr[1] == c && arr[0] != a {
				a, b, c = b, c, arr[0]
				break
			}
		}
		fmt.Fprintf(out, "%d ", c)
	}
	fmt.Fprintln(out)
}