Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.

The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.

For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).

10

5

Timur

5

miurT

5

Trumi

5

mriTu

5

timur

4

Timr

6

Timuur

10

codeforces

10

TimurTimur

5

TIMUR

package main

import (
	"fmt"
	"sort"
)

func main() {
	// Timru是对字符Timur的升序排列
	var name = "Timru"
	// 对name字符串排序
	// 类似c++的sort，升序排列
	//b := []byte(name)
	//sort.Slice(b, func(i, j int) bool { return b[i] < b[j] })
	//name = string(b)
	//fmt.Println(name)
	var n int
	fmt.Scanf("%d\n", &n)
	for i := 0; i < n; i++ {
		var m int
		fmt.Scanf("%d\n", &m)
		var s string
		fmt.Scanf("%s\n", &s)
		b1 := []byte(s)
		sort.Slice(b1, func(i, j int) bool { return b1[i] < b1[j] })
		s = string(b1)
		//fmt.Println(s)
		//fmt.Println(i)
		if name == s {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main
import(
    "fmt"
    "strings"
)
func main() {
	var t int
	fmt.Scan(&t)
	for i:=0;i<t;i++{
		x:= "Timur"
		var (
			n,tally int
			input string
		)
		fmt.Scan(&n,&input)
		if n == 5 {
			for k:=0;k<5;k++{
				if strings.Count(input, string(x[k])) == 1 {
					tally++
				}
			}
			if tally == 5 {
				fmt.Println("YES")
				continue
			}
		}
		fmt.Println("NO")
	}
}

package main

import (
	"fmt"
	"sort"
)

type runes []rune

func (s runes) Less(i, j int) bool {
	return s[i] < s[j]
}

func (s runes) Swap(i, j int) {
	s[i], s[j] = s[j], s[i]
}

func (s runes) Len() int {
	return len(s)
}

func SortString(s string) string {
	r := []rune(s)
	sort.Sort(runes(r))
	return string(r)
}

func main() {
	var t int
	fmt.Scanf("%d\n", &t)
	for t > 0 {
		t--
		var n int
		var s string
		fmt.Scanf("%d\n", &n)
		fmt.Scanf("%s\n", &s)
		if n != 5 {
			fmt.Println("NO")
			continue
		}
		if "Timru" == SortString(s) {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

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

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

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

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

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

/**
Run solve the problem CF1722A
Date: 9/2/2022
User: wotan
URL: https://codeforces.com/problemset/problem/1722/A
Problem: CF1722A
**/
func (in *CF1722A) Run() {
	for t := in.NextInt(); t > 0; t-- {
		mapa := map[uint8]int{
			'T': 1,
			'i': 1,
			'm': 1,
			'u': 1,
			'r': 1,
		}
		n := in.NextInt()
		str := in.NextString()
		ans := true
		if n == len(mapa) {
			for i := 0; i < n; i++ {
				if v, e := mapa[str[i]]; e && v == 1 {
					mapa[str[i]] = 0
					continue
				} else {
					ans = false
					break
				}
			}
		} else {
			ans = false
		}
		if ans {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

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

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

package main

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

func main() {
	r := readerStdin()

	name := []byte("Timur")
	sort.Slice(name, func(i, j int) bool { return name[i] < name[j] })
	for cases := readInt(r); cases != 0; cases-- {
		strLen, str := readInt(r), []byte(readString(r))
		if strLen != 5 {
			fmt.Println("NO")
			continue
		}

		sort.Slice(str, func(i, j int) bool { return str[i] < str[j] })

		if string(name) == string(str) {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

func readerStdin() *bufio.Reader {
	return bufio.NewReader(os.Stdin)
}

func readString(r *bufio.Reader) (s string) {
	s, _ = r.ReadString('\n')
	s = strings.ReplaceAll(s, "\n", "")
	s = strings.ReplaceAll(s, "\r", "")
	return
}

func readInt(r *bufio.Reader) (i int) {
	str := readString(r)
	i, _ = strconv.Atoi(str)
	return
}

package main

import (
	"fmt"
	"sort"
)

type sortRunes []rune

func (s sortRunes) Less(i, j int) bool {
	return s[i] < s[j]
}

func (s sortRunes) Swap(i, j int) {
	s[i], s[j] = s[j], s[i]
}

func (s sortRunes) Len() int {
	return len(s)
}

func SortString(s string) string {
	r := []rune(s)
	sort.Sort(sortRunes(r))
	return string(r)
}

func solve() {
	var n int32
	fmt.Scan(&n)
	var s string

	fmt.Scan(&s)
	s = SortString(s)
	// fmt.Println(s)
	if n != 5 || len(s) != 5 || s != "Timru" {
		fmt.Println("NO")
		return
	}
	fmt.Println("YES")
}

func main() {
	var t int32
	fmt.Scan(&t)

	for ; t > 0; t-- {
		solve()
	}
}

package main

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

func main() {
	var (
		t    int
		n    int
		s    string
		good []string
	)
	good = append(good, "T", "i", "m", "r", "u")
	//}
	fmt.Scanf("%d\n", &t)
	for i := 0; i < t; i++ {
		c := 0
		fmt.Scanf("%d\n", &n)
		fmt.Scanf("%s\n", &s)
		sl := strings.Split(s, "")
		sort.Strings(sl)
		if len(sl) == len(good) {
			for j := 0; j < n; j++ {
				if sl[j] == good[j] {
					c++
				}
			}
		}
		if c == 5 {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	var t, n int
	o := []byte{'T', 'i', 'm', 'u', 'r'}
	sort.Slice(o, func(i, j int) bool {
		return o[i] < o[j]
	})
	so := string(o)
	fmt.Fscan(in, &t)
	for t > 0 {
		t--
		var s []byte
		fmt.Fscan(in, &n, &s)
		if n > 5 || n < 5 {
			fmt.Println("No")
		} else {
			sort.Slice(s, func(i, j int) bool {
				return s[i] < s[j]
			})
			ss := string(s)
			if so == ss {
				fmt.Println("Yes")
			} else {
				fmt.Println("No")
			}
		}

	}
}

package main

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

func sort_string(s string) string {
	ns := strings.Split(s, "")
	sort.Strings(ns)
	return strings.Join(ns, "")
}

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

	var input string
	var t, n int

	for fmt.Fscan(r, &t); t > 0; t-- {
		fmt.Fscan(r, &n, &input)

		if sort_string(input) == sort_string("Timur") {
			fmt.Fprintln(w, "YES")
		} else {
			fmt.Fprintln(w, "NO")
		}
	}
}

package main

import (
	"fmt"
	"strings"
)

func main() {
	var T int
	var N int
	var s string
	var flag bool
	fmt.Scan(&T)
	for T > 0 {
		fmt.Scan(&N)
		fmt.Scan(&s)
		flag = strings.Contains(s, "T") && strings.Contains(s, "i") && strings.Contains(s, "m") && strings.Contains(s, "u") && strings.Contains(s, "r") && len(s) == 5
		if flag {
			fmt.Println("YES")

		} else {
			fmt.Println("NO")
		}
		T--
	}
}

package main

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

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanws(a ...interface{})           { fmt.Fscan(reader, a...) }

func main() {

	defer writer.Flush()

	var t int
	scanws(&t)

	var l int
	var s []byte

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

		l, s = 0, nil
		scanws(&l)
		scanws(&s)

		f := 0
		timur := []byte("Timur")

		if l != 5 {
			printf("\nNO")
			continue
		}

		for j := 0; j < l; j++ {

			index := bytes.IndexByte(timur, s[j])
			if  index >= 0 {
				timur[index] = 0
			} else {
				printf("\nNO")
				f = 1
				break
			}
		}

		if f == 0 {
			printf("\nYES")
		}

	}

}

package main

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

func solve(r *bufio.Reader) {
	var n int
	var s string
	fmt.Fscan(r, &n, &s)
	if n != 5 {
		fmt.Println("NO")
		return
	}

	m := make(map[rune]bool)
	for _, l := range s {
		m[l] = true
	}

	for _, l := range "Timur" {
		if !m[l] {
			fmt.Println("NO")
			return
		}
	}
	fmt.Println("YES")
	return
}
func main() {
	r := bufio.NewReader(os.Stdin)
	var n int
	fmt.Fscan(r, &n)
	for i := 0; i < n; i++ {
		solve(r)
	}
}

package main

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

type sortRunes []rune

func (s sortRunes) Less(i, j int) bool {
	return s[i] < s[j]
}

func (s sortRunes) Swap(i, j int) {
	s[i], s[j] = s[j], s[i]
}

func (s sortRunes) Len() int {
	return len(s)
}

func SortString(s string) string {
	r := []rune(s)
	sort.Sort(sortRunes(r))
	return string(r)
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	nrTests, _ := strconv.Atoi(scanner.Text())
	for i := 0; i < nrTests; i++ {
		scanner.Scan()
		nrSym, _ := strconv.Atoi(scanner.Text())
		scanner.Scan()
		line1 := scanner.Text()
		good := true
		if nrSym != 5 {
			good = false
		} else {
			if SortString(line1) != "Timru" {
				good = false
			}
		}
		if good {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import (
	"fmt"
	"sort"
)

func main() {
	var ts , m int
	var name string
	fmt.Scan(&ts)
	for ts > 0 {
		fmt.Scan(&m)
		fmt.Scan(&name)
		if m == 5 {
			s := []rune(name)
			sort.Slice(s , func(i int , j int) bool { return s[i] < s[j] })
			if string(s) == "Timru" {
				fmt.Println("Yes")
			} else {
				fmt.Println("No")
			}
		} else {
			fmt.Println("No")
		}
		ts--
	}
}

package main

import "fmt";

func main (){

    var tc int;
    timur := "Timur";

    fmt.Scanln(&tc);
    for t := 1; t<=tc; t++{
        var n int;
        var s string;
        fmt.Scanln(&n);
        fmt.Scanln(&s);
        check := true;
        if(n != 5){
            check=false;
        }
        for i := 0; i < 5; i++{
            valid := false;
            for j := 0; j < n; j++{
                if(timur[i]==s[j]){
                    valid = true;
                }
            }
            if(valid==false){
                check=false;
            }
        }
        if(check==false){
            fmt.Println("NO");
        } else {
            fmt.Println("YES");
        }
    }
}

package main

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

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

func checkPerm(n, m int, x, y string) bool {
	if n != m {
		return false
	}
	var v, w = []rune(x), []rune(y)
	sort.Slice(v, func(i, j int) bool {
		return v[i] < v[j]
	})
	sort.Slice(w, func(i, j int) bool {
		return w[i] < w[j]
	})
	for i := range v {
		if v[i] != w[i] {
			return false
		}
	}
	return true
}

func solve(n int, s string) string {
	if checkPerm(n, 5, s, "Timur") {
		return "YES"
	}
	return "NO"
}

func main() {
	fmt.Fscan(reader, &t)
	for ; t > 0; t-- {
		fmt.Fscan(reader, &n, &s)
		fmt.Println(solve(n, s))
	}
}

package main

import (
	"fmt"
	"sort"
)

func Solve_1722A() {
	var t, n int
	var name string
	fmt.Scan(&t)
	for t > 0 {
		fmt.Scan(&n)
		fmt.Scan(&name)
		if n != 5 {
			fmt.Println("NO")
		} else {
			na := []byte(name)
			sort.Slice(na, func(i, j int) bool { return na[i] < na[j] })
			if string(na) == "Timru" {
				fmt.Println("YES")
			} else {
				fmt.Println("NO")
			}
		}
		t--
	}
}

func main() {
	Solve_1722A()
}

package main

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

func main(){
	cin := bufio.NewReader(os.Stdin)
	var t int
	fmt.Fscan(cin, &t)
	for i := 0; i < t; i++ {
		var n int
		var s string
		fmt.Fscan(cin, &n)
		fmt.Fscan(cin, &s)
		if n != 5 {
			fmt.Println("NO")
			continue
		}

		ref := map[byte]int{
			'T': 1,
			'i': 1,
			'm': 1,
			'u': 1,
			'r': 1,
		}

		ok := true
		for i := 0; i < 5; i++ {
			if ref[s[i]] > 0 {
				ref[s[i]] -= 1
			}else {
				ok = false
				break
			}
		}

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

package main

import "fmt"

var name string = "Timur"

func findAns(str string, n int) bool {
	if n != 5 {
		fmt.Println("NO")
		return false
	}
	arr := make([]int, 58)
	for i := 0; i < len(str); i++ {
		arr[str[i]-65] = 1
	}
	for i := 0; i < 5; i++ {
		if arr[name[i]-65] != 1 {
			fmt.Println("NO")
			return false
		}
	}
	fmt.Println("YES")
	return true
}

func main() {
	t, n := 0, 0
	fmt.Scan(&t)
	for t > 0 {
		fmt.Scan(&n)
		tmp := ""
		fmt.Scan(&tmp)
		findAns(tmp, n)
		t--
	}
}

package main
import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strings"
)

const TargetName string = "Timur"

func main() {
	defer writer.Flush()
	var t, n, nameLen uint32
	var name, sortName, sortKnown string
	nameLen = uint32(len(TargetName))
	sortKnown = sortString(TargetName)

	scanws(&t)

	for ; t > 0; t-- {
		scanws(&n)
		scanws(&name)
		sortName = sortString(name)
		switch {
		case n != nameLen || strings.Compare(sortKnown, sortName) != 0:
			printf("NO\n")
		default:
			printf("YES\n")
		}
	}
}

func sortString(checkName string) string {
	var newString string
	var tmp []string
	newString = checkName
	tmp = strings.SplitAfter(newString, "")
	sort.Strings(tmp)
	return strings.Join(tmp, "")
}

func yesNoMap(b uint8) string {
	return map[uint8]string{0: "NO", 1: "YES"}[b]
}

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanws(a ...interface{}) { fmt.Fscan(reader, a...) }

package main

import (
	"fmt"
)

func main() {
	var t int
	fmt.Scan(&t)
	for j := 0; j < t; j++ {
		var n int
		fmt.Scan(&n)
		var s string
		fmt.Scan(&s)
		if n > 5 || n < 5 {
			fmt.Printf("NO\n")
		} else {
			map1 := map[string]int{
				"T": 1, "i": 1, "m": 1, "u": 1, "r": 1,
			}
			flag := 1
			//fmt.Printf("%v\n",s)
			for i := 0; i < len(s); i++ {
				if _, found := map1[string(s[i])]; found {
					delete(map1, string(s[i]))
				} else {
					flag = 0
					break
				}
				//fmt.Printf("map1==> %v\n",map1)
			}
			if flag == 1 {
				fmt.Printf("YES\n")
			} else {
				fmt.Printf("NO\n")
			}
		}
	}
}

package main

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

var (
	in   *bufio.Reader = bufio.NewReader(os.Stdin)
	t, n int
	s    string
	mp   map[byte]int = map[byte]int{
		'T': 1,
		'i': 1,
		'm': 1,
		'u': 1,
		'r': 1,
	}
)

func main() {
	fmt.Fscan(in, &t)
	for t > 0 {
		fmt.Fscan(in, &n, &s)
		solve()
		t--
	}
}

func solve() {
	if n != 5 {
		fmt.Println("NO")
	} else {
		c := map[byte]int{}
		for i := range s {
			c[s[i]]++
		}
		for key := range c {
			if c[key] != mp[key] {
				fmt.Println("NO")
				return
			}
		}
		fmt.Println("YES")
	}
}

package main

import (
	"fmt"
	"strings"
)

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

	s := make([]string, t)
	n := make([]int, t)

	for i := 0; i < t; i++ {
		fmt.Scan(&n[i])
		fmt.Scan(&s[i])
	}
	for i := 0; i < t; i++ {
		if !strings.Contains(s[i], "T") || n[i] != 5 || !strings.Contains(s[i], "i") || !strings.Contains(s[i], "m") || !strings.Contains(s[i], "u") || !strings.Contains(s[i], "r") {
			fmt.Println("NO")
		} else {
			fmt.Println("YES")
		}
	}
}

package main

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

type float = float32
type double = float64
type long = int64
type ulong = uint64

type Readable interface {
	bool | int | uint64 | int64 | double | float | byte
}

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

func print(arg ...interface{})            { fmt.Fprint(out, arg...) }
func println(arg ...interface{})          { fmt.Fprintln(out, arg...) }
func printf(f string, arg ...interface{}) { fmt.Fprintf(out, f, arg...) }
func scanf(f string, arg ...interface{})  { fmt.Fscanf(in, f, arg...) }

func readLn() string {
	ln, err := in.ReadString('\n')
	if err != nil {
		panic(err)
	}

	return strings.Trim(ln, " \n\r")
}

func readString() string {
	return readLn()
}

func readStrings() []string {
	return strings.Split(readLn(), " ")
}

func read[T Readable](f func(string) (T, error), input ...string) T {
	if len(input) == 0 {
		input = []string{readLn()}
	}

	res, err := f(input[0])
	if err != nil {
		panic(err)
	}

	return res
}

func readMany[T Readable](f func(...string) T) []T {
	input := readStrings()
	arr := make([]T, len(input))
	for i := 0; i < len(arr); i++ {
		arr[i] = f(input[i])
	}

	return arr
}

func readBool(input ...string) bool {
	return read(strconv.ParseBool, input...)
}

func readInt(input ...string) int {
	return read(strconv.Atoi, input...)
}

func readByte(input ...string) byte {
	return byte(read(func(s string) (uint64, error) {
		return strconv.ParseUint(s, 10, 8)
	}, input...))
}

func readDouble(input ...string) double {
	return read(func(s string) (float64, error) {
		return strconv.ParseFloat(s, 64)
	}, input...)
}

func readFloat(input ...string) float {
	return float32(read(func(s string) (float64, error) {
		return strconv.ParseFloat(s, 32)
	}, input...))
}

func readLong(input ...string) long {
	return read(func(s string) (int64, error) {
		return strconv.ParseInt(s, 10, 64)
	}, input...)
}

func readULong(input ...string) ulong {
	return read(func(s string) (uint64, error) {
		return strconv.ParseUint(s, 10, 64)
	}, input...)
}

func readBinary(input ...string) long {
	return read(func(s string) (int64, error) {
		return strconv.ParseInt(s, 2, 64)
	}, input...)
}

func readBools() []bool {
	return readMany(readBool)
}

func readInts() []int {
	return readMany(readInt)
}

func readBytes() []byte {
	return readMany(readByte)
}

func readDoubles() []double {
	return readMany(readDouble)
}

func readFloats() []float {
	return readMany(readFloat)
}

func readLongs() []long {
	return readMany(readLong)
}

func readULongs() []ulong {
	return readMany(readULong)
}

func main() {
	defer out.Flush()

	// solution
	t := readInt()
	ans := make([]string, t)
	for i := 0; i < t; i++ {
		n := readInt()
		s := readString()
		if n != 5 {
			ans[i] = "NO"
			continue
		}
		r := "Timur"
		arr := make([]int, 52)
		for i := 0; i < 5; i++ {
			if 'a' <= r[i] && r[i] <= 'z' {
				arr[r[i]-'a']++
			} else {
				arr[r[i]-'A'+26]++
			}
		}
		for i := 0; i < n; i++ {
			if 'a' <= s[i] && s[i] <= 'z' {
				arr[s[i]-'a']--
			} else {
				arr[s[i]-'A'+26]--
			}
		}
		f := true
		for _, v := range arr {
			if v != 0 {
				ans[i] = "NO"
				f = false
				break
			}
		}
		if f {
			ans[i] = "YES"
		}
	}
	for i := 0; i < t; i++ {
		println(ans[i])
	}
}

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

	return x
}

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

	return y
}

func min(x, y long) long {
	if x > y {
		return y
	}

	return x
}

package main

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

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

	var T int
	fmt.Fscan(in, &T)
	for t := 0; t < T; t++ {
		var n int
		var s []byte
		fmt.Fscan(in, &n, &s)

		sort.Slice(s, func(i, j int) bool { return s[i] < s[j] })
		if n != 5 || string(s) != "Timru" {
			fmt.Fprintln(out, "NO")
		} else {
			fmt.Fprintln(out, "YES")
		}
	}
}

package main

import (
	"fmt"
	"sort"
)

func main() {
	// Timru是对字符Timur的升序排列
	var name = "Timru"
	// 对name字符串排序
	// 类似c++的sort，升序排列
	//b := []byte(name)
	//sort.Slice(b, func(i, j int) bool { return b[i] < b[j] })
	//name = string(b)
	//fmt.Println(name)
	var n int
	fmt.Scanf("%d", &n)
	for i := 0; i < n; i++ {
		var m int
		fmt.Scanf("%d\n", &m)
		var s string
		fmt.Scanf("%s\n", &s)
		b1 := []byte(s)
		sort.Slice(b1, func(i, j int) bool { return b1[i] < b1[j] })
		s = string(b1)
		//fmt.Println(s)
		//fmt.Println(i)
		if name == s {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import (
	"fmt"
	"sort"
)

func main() {
	// Timru是对字符Timur的升序排列
	var name = "Timru"
	// 对name字符串排序
	// 类似c++的sort，升序排列
	//b := []byte(name)
	//sort.Slice(b, func(i, j int) bool { return b[i] < b[j] })
	//name = string(b)
	//fmt.Println(name)
	var n int
	fmt.Scanf("%d", &n)
	for i := 0; i < n; i++ {
		var m int
		fmt.Scanf("%d", &m)
		var s string
		fmt.Scanf("%s", &s)
		b1 := []byte(s)
		sort.Slice(b1, func(i, j int) bool { return b1[i] < b1[j] })
		s = string(b1)
		fmt.Println(s)
		fmt.Println(i)
		if name == s {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import (
	"fmt"
	"sort"
)

func main() {
	// Timru是对字符Timur的升序排列
	var name = "Timru"
	// 对name字符串排序
	// 类似c++的sort，升序排列
	//b := []byte(name)
	//sort.Slice(b, func(i, j int) bool { return b[i] < b[j] })
	//name = string(b)
	//fmt.Println(name)
	var n int
	fmt.Scanf("%d", &n)
	for i := 0; i < n; i++ {
		var m int
		fmt.Scanf("%d", &m)
		var s string
		fmt.Scanf("%s", &s)
		b1 := []byte(s)
		sort.Slice(b1, func(i, j int) bool { return b1[i] < b1[j] })
		s = string(b1)
		//fmt.Println(s)
		fmt.Println(i)
		if name == s {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import (
	"fmt"
	"sort"
)

func main() {
	// Timru是对字符Timur的升序排列
	var name = "Timru"
	// 对name字符串排序
	// 类似c++的sort，升序排列
	//b := []byte(name)
	//sort.Slice(b, func(i, j int) bool { return b[i] < b[j] })
	//name = string(b)
	//fmt.Println(name)
	var n int
	fmt.Scanf("%d", &n)
	for i := 0; i < n; i++ {
		var m int
		fmt.Scanf("%d", &m)
		var s string
		fmt.Scanf("%s", &s)
		b1 := []byte(s)
		sort.Slice(b1, func(i, j int) bool { return b1[i] < b1[j] })
		s = string(b1)
		//fmt.Println(s)
		if name == s {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import (
	"fmt"
	"sort"
)

func main() {
	// Timru是对字符Timur的升序排列
	var name = "Timru"
	// 对name字符串排序
	// 类似c++的sort，升序排列
	//b := []byte(name)
	//sort.Slice(b, func(i, j int) bool { return b[i] < b[j] })
	//name = string(b)
	//fmt.Println(name)
	var n int
	fmt.Scanf("%d", &n)
	for i := 0; i < n; i++ {
		var m int
		fmt.Scanf("%d", &m)
		var s string
		fmt.Scanf("%s", &s)
		b1 := []byte(s)
		sort.Slice(b1, func(i, j int) bool { return b1[i] < b1[j] })
		s = string(b1)
		fmt.Println(s)
		if name == s {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import (
	"fmt"
	"sort"
)

func main() {
	var name = "Timru"
	// 对name字符串排序
	// 类似c++的sort，升序排列
	//b := []byte(name)
	//sort.Slice(b, func(i, j int) bool { return b[i] < b[j] })
	//name = string(b)
	//fmt.Println(name)
	var n int
	fmt.Scanf("%d", &n)
	for i := 0; i < n; i++ {
		var m int
		fmt.Scanf("%d", &m)
		var s string
		fmt.Scanf("%s", &s)
		b1 := []byte(s)
		sort.Slice(b1, func(i, j int) bool { return b1[i] < b1[j] })
		s = string(b1)
		fmt.Println(s)
		if name == s {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import (
	"fmt"
	"sort"
)

func main() {
	var name = "Timru"
	// 对name字符串排序
	// 类似c++的sort，升序排列
	//b := []byte(name)
	//sort.Slice(b, func(i, j int) bool { return b[i] < b[j] })
	//name = string(b)
	//fmt.Println(name)
	var n int
	fmt.Scanf("%d", &n)
	for i := 0; i < n; i++ {
		var m int
		fmt.Scanf("%d", &m)
		var s string
		fmt.Scanf("%s", &s)
		b1 := []byte(s)
		sort.Slice(b1, func(i, j int) bool { return b1[i] < b1[j] })
		s = string(b1)
		if name == s {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import (
	"fmt"
	"sort"
)

func main() {
	var name = "Timur"
	// 对name字符串排序
	// 类似c++的sort，升序排列
	b := []byte(name)
	sort.Slice(b, func(i, j int) bool { return b[i] < b[j] })
	name = string(b)
	var n int
	fmt.Scanf("%d", &n)
	for i := 0; i < n; i++ {
		var m int
		fmt.Scanf("%d", &m)
		var s string
		fmt.Scanf("%s", &s)
		b1 := []byte(s)
		sort.Slice(b1, func(i, j int) bool { return b1[i] < b1[j] })
		s = string(b1)
		if name == s {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main
import(
    "fmt"
)
func main() {
	var t int
	fmt.Scan(&t)
	for i:=0;i<t;i++{
		var n int
		fmt.Scan(&n)
		var reference string = "Timur"
		var word string
		fmt.Scan(&word)
		tally:=0
		for j:=0;j<len(word);j++{
			for k:=0;k<5;k++{
				if string(word[j]) == string(reference[k]) {
					reference = string(reference[:k])+string(reference[k:])
					tally++
					break
				}
			}
		}
		if tally == 5 {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main
import(
    "fmt"
)
func main() {
	var t int
	fmt.Scan(&t)
	for i:=0;i<t;i++{
		var n int
		var reference string = "Timur"
		var word string
		fmt.Scan(&n)
		fmt.Scan(&word)
		if len(word) != 5 {
			fmt.Println("NO")
		} else {
			tally:=0
			for j:=0;j<len(word);j++{	// miurT
				for k:=0;k<len(word);k++{
					if string(word[j]) == string(reference[k]) {
						reference = string(reference[:k])+string(reference[k:])
						tally++
						break
					}
				}
			}
			if tally == 5 {
				fmt.Println("YES")
			} else {
				fmt.Println("NO")
			}
		}
	}
}

package main
import(
    "fmt"
)
func main() {
	var t int
	fmt.Scan(&t)
	for i:=0;i<t;i++{
		var n int
		var reference string = "Timur"
		var word string
		fmt.Scan(&n)
		fmt.Scan(&word)
		if len(word) != 5 {
			fmt.Println("NO")
		} else {
			tally:=0
			for j:=0;j<n;j++{	// miurT
				for k:=0;k<n;k++{
					if string(word[j]) == string(reference[k]) {
						reference = string(reference[:k])+string(reference[k:])
						tally++
						break
					}
				}
			}
			if tally == 5 {
				fmt.Println("YES")
			} else {
				fmt.Println("NO")
			}
		}
	}
}

package main
import(
    "fmt"
)
func main() {
	var t int
	fmt.Scan(&t)
	for i:=0;i<t;i++{
		var n int
		var reference string = "Timur"
		var word string
		fmt.Scan(&n)
		fmt.Scan(&word)
		if n != 5 {
			fmt.Println("NO")
		} else {
			tally:=0
			for j:=0;j<n;j++{	// miurT
				for k:=0;k<n;k++{
					if string(word[j]) == string(reference[k]) {
						reference = string(reference[:k])+string(reference[k:])
						tally++
						break
					}
				}
			}
			if tally == 5 {
				fmt.Println("YES")
			} else {
				fmt.Println("NO")
			}
		}
	}
}

package main

import (
	"fmt"
)

func main() {
	var t int
	fmt.Scanf("%d\n", &t)
	for t > 0 {
		t--
		var n int
		var s string
		fmt.Scanf("%d\n", &n)
		fmt.Scanf("%s\n", &s)
		if n != 5 {
			fmt.Println("NO")
			continue
		}
		var sum int
		for _, c := range s {
			sum += int(c)
		}
		if sum != 529 {
			fmt.Println("NO")
		} else {
			fmt.Println("YES")
		}
	}
}

package main

import (
	"fmt"
)

func main() {
	var t int
	fmt.Scanf("%d", &t)
	results := make([]string, t)
	for t > 0 {
		t--
		var n int
		var s string
		fmt.Scanf("%d", &n)
		fmt.Scanf("%s", &s)
		if n != 5 {
			results = append(results, "NO")
			continue
		}
		var sum int
		for _, c := range s {
			sum += int(c)
		}
		if sum != 529 {
			results = append(results, "NO")
		} else {
			results = append(results, "YES")
		}
	}
	for _, v := range results {
		fmt.Println(v)
	}
}

package main

import (
	"fmt"
)

func main() {
	var t int
	fmt.Scanf("%d", &t)
	for t > 0 {
		t--
		var n int
		var s string
		fmt.Scanf("%d", &n)
		fmt.Scanf("%s", &s)
		if n != 5 {
			fmt.Println("NO")
			continue
		}
		var sum int
		for _, c := range s {
			sum += int(c)
		}
		if sum != 529 {
			fmt.Println("NO")
		} else {
			fmt.Println("YES")
		}
	}
}

package main

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

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

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

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

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

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

/**
Run solve the problem CF1722A
Date: 9/2/2022
User: wotan
URL: https://codeforces.com/problemset/problem/1722/A
Problem: CF1722A
**/
func (in *CF1722A) Run() {
	name := "Timur"
	for t := in.NextInt(); t > 0; t-- {
		n := in.NextInt()
		str := in.NextString()
		ans := true
		if n == len(name) {
			for i := 0; i < n; i++ {
				if strings.Contains(name, string(str[i])) {
					continue
				} else {
					ans = false
					break
				}
			}
		} else {
			ans = false
		}
		if ans {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

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

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

package main

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

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

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

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

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

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

/**
Run solve the problem CF1722A
Date: 9/2/2022
User: wotan
URL: https://codeforces.com/problemset/problem/1722/A
Problem: CF1722A
**/
func (in *CF1722A) Run() {
	name := "Timur"
	for t := in.NextInt(); t > 0; t-- {
		n := in.NextInt()
		str := in.NextString()
		ans := true
		if n == len(name) {
			for i := 0; i < n; i++ {
				if strings.Contains(name, string(str[i])) {
					continue
				} else {
					ans = false
					break
				}
			}
		}
		if ans {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

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

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

package main

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

var hash = map[rune]bool{
	'T': true, 'i': true,
	'u': true, 'm': true,
	'r': true,
}

func main() {
	r := readerStdin()

	for cases := readInt(r); cases != 0; cases-- {
		strLen, str := readInt(r), readString(r)
		if strLen != 5 {
			fmt.Println("NO")
			continue
		}

		for _, char := range str {
			if _, ok := hash[char]; !ok {
				fmt.Println("NO")
				goto Next
			}
		}

		fmt.Println("YES")
	Next:
	}
}

func readerStdin() *bufio.Reader {
	return bufio.NewReader(os.Stdin)
}

func readString(r *bufio.Reader) (s string) {
	s, _ = r.ReadString('\n')
	s = strings.ReplaceAll(s, "\n", "")
	s = strings.ReplaceAll(s, "\r", "")
	return
}

func readInt(r *bufio.Reader) (i int) {
	str := readString(r)
	i, _ = strconv.Atoi(str)
	return
}

package main

import (
	"fmt"
	"strings"
)

func solve() {
	var n int32
	fmt.Scan(&n)
	var s string

	fmt.Scan(&s)
	if n != 5 || len(s) != 5 || strings.Contains(s, "T") || strings.Contains(s, "i") || strings.Contains(s, "m") || strings.Contains(s, "u") || strings.Contains(s, "r") {
		fmt.Println("NO")
		return
	}
	fmt.Println("YES")
}

func main() {
	var t int32
	fmt.Scan(&t)

	for ; t > 0; t-- {
		solve()
	}
}


You are given a string $$$s$$$ consisting of lowercase letters of the English alphabet. You must perform the following algorithm on $$$s$$$:  Let $$$x$$$ be the length of the longest prefix of $$$s$$$ which occurs somewhere else in $$$s$$$ as a contiguous substring (the other occurrence may also intersect the prefix). If $$$x = 0$$$, break. Otherwise, remove the first $$$x$$$ characters of $$$s$$$, and repeat. A prefix is a string consisting of several first letters of a given string, without any reorders. An empty prefix is also a valid prefix. For example, the string "abcd" has 5 prefixes: empty string, "a", "ab", "abc" and "abcd".For instance, if we perform the algorithm on $$$s =$$$ "abcabdc",   Initially, "ab" is the longest prefix that also appears somewhere else as a substring in $$$s$$$, so $$$s =$$$ "cabdc" after $$$1$$$ operation.  Then, "c" is the longest prefix that also appears somewhere else as a substring in $$$s$$$, so $$$s =$$$ "abdc" after $$$2$$$ operations.  Now $$$x=0$$$ (because there are no non-empty prefixes of "abdc" that also appear somewhere else as a substring in $$$s$$$), so the algorithm terminates. Find the final state of the string after performing the algorithm.

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. This is followed by $$$t$$$ lines, each containing a description of one test case. Each line contains a string $$$s$$$. The given strings consist only of lowercase letters of the English alphabet and have lengths between $$$1$$$ and $$$2 \cdot 10^5$$$ inclusive. It is guaranteed that the sum of the lengths of $$$s$$$ over all test cases does not exceed $$$2 \cdot 10^5$$$.

For each test case, print a single line containing the string $$$s$$$ after executing the algorithm. It can be shown that such string is non-empty.

6
abcabdc
a
bbbbbbbbbb
codeforces
cffcfccffccfcffcfccfcffccffcfccf
zyzyzwxxyyxxyyzzyzzxxwzxwywxwzxxyzzw

NoteThe first test case is explained in the statement.In the second test case, no operations can be performed on $$$s$$$.In the third test case,   Initially, $$$s =$$$ "bbbbbbbbbb".  After $$$1$$$ operation, $$$s =$$$ "b". In the fourth test case,   Initially, $$$s =$$$ "codeforces".  After $$$1$$$ operation, $$$s =$$$ "odeforces".  After $$$2$$$ operations, $$$s =$$$ "deforces".

package main

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

func main() {

	reader := bufio.NewReader(os.Stdin)
	writter := bufio.NewWriter(os.Stdout)
	defer writter.Flush()

	t := 0
	fmt.Fscan(reader, &t)

	for t > 0 {
		s := ""
		fmt.Fscan(reader, &s)

		// a := make([]int, n)
		// for i := range a {
		// 	fmt.Fscan(reader, &a[i])
		// }

		// result := solve(n, a)

		// for i := range result {
		// 	fmt.Fprintf(writter, "%d ", result[i])
		// }

		fmt.Fprintln(writter, solve(s))

		t--
	}

	// s := "abcabdc"
	// fmt.Println(s)
	// fmt.Println(solve(s))

}

func solve(s string) string {

	pos := [26]int{}
	for i := len(s) - 1; i >= 0; i-- {
		if b := s[i] - 'a'; pos[b] == 0 {
			pos[b] = i + 1
		}
	}

	//fmt.Println(pos)

	minP := len(s)
	for _, p := range pos {
		if p > 0 && p < minP {
			minP = p
		}
	}

	return s[minP-1:]
}

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

// 	var T int
// 	var s string
// 	for Fscan(in, &T); T > 0; T-- {
// 		Fscan(in, &s)
// 		pos := [26]int{}
// 		for i := len(s) - 1; i >= 0; i-- {
// 			if b := s[i] - 'a'; pos[b] == 0 {
// 				pos[b] = i + 1
// 			}
// 		}
// 		minP := len(s)
// 		for _, p := range pos {
// 			if p > 0 && p < minP {
// 				minP = p
// 			}
// 		}
// 		Fprintln(out, s[minP-1:])
// 	}
// }

package main

import (
	"fmt"
	"strings"
)

var x []string

func main() {
	times := 0
	fmt.Scanf("%d\n", &times)
	x = make([]string, times)
	for i := 0; i < times; i++ {
		fmt.Scanf("%v", &x[i])
		fmt.Scanln()
	}
	for i := 0; i < times; i++ {
		fmt.Println(solution(x[i]))
	}
}

func solution(s string) string {
	i := 0
	for strings.Contains(s[i+1:], s[i:i+1]) {
		i++
	}
	return s[i:]
}

package main

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

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

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

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

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

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

var mapa map[uint8]int

/**
Run solve the problem CF1654B
Date: 9/18/2022
User: wotan
URL: https://codeforces.com/problemset/problem/1654/B
Problem: CF1654B
**/
func (in *CF1654B) Run() {
	var ans strings.Builder
	for t := in.NextInt(); t > 0; t-- {
		mapa = map[uint8]int{}
		str := in.NextString()
		for i := 0; i < len(str); i++ {
			mapa[str[i]]++
		}
		for maxp := maxPrefix(str); maxp != -1; {
			str = str[maxp:]
			maxp = maxPrefix(str)

		}
		ans.WriteString(str + "\n")
	}
	fmt.Print(ans.String())
}

func maxPrefix(str string) int {
	pre := false
	str += "-"
	preMap := map[uint8]int{}
	for i := 1; i < len(str); i++ {
		preMap[str[i-1]]++
		if exist(preMap) {
			mapa[str[i-1]]--
			pre = true
			continue
		} else {
			if pre {
				return i - 1
			}
			break
		}
	}
	return -1
}

func exist(preMap map[uint8]int) bool {
	for k, v := range preMap {
		value, e := mapa[k]
		if !e {
			return false
		}
		if value <= v {
			return false
		}
	}
	return true
}

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

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

package main

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

func main() {
	var (
		t int
	)

	reader := bufio.NewReader(os.Stdin)
	fmt.Scanf("%d\n", &t)

	for t > 0 {
		t--

		s, _ := reader.ReadString('\n')
		if s[len(s)-1] == 10 {
			s = s[:len(s)-1]
		}
		if s[len(s)-1] == 13 {
			s = s[:len(s)-1]
		}
		n := len(s)
		k := 0
		for i := 0; i < n-1; i++ {
			done := false
			for j := i+1; j < n; j++ {
				if s[i] == s[j] {
					done = true
					k = i+1
					break
				}
			}
			if done == false {
				break
			}
		}

		fmt.Println(s[k:])
	}
}

package main

import (
	"fmt"
	"strings"
)

func main() {
	var t int
	fmt.Scanln(&t)
	i:=0
	for i<t{
		var s,sub string

	    fmt.Scanln(&s)
		for j:=0;j<len(s);j++{
			sub=s[j+1:len(s)]

			if strings.Contains(sub,string(s[j]))!=true {
              s=s[j:len(s)]
			  break
			}

		}
	    fmt.Println(s)
		i++
	}

}

package main

import (
	"fmt"
	"strings"
)

func main() {
	var t int
	fmt.Scanln(&t)
	i:=0
	for i<t{
		var s,sub,pre string
		var b bool
	    fmt.Scanln(&s)
		for j:=0;j<len(s);j++{
			sub=s[j+1:len(s)+1-1]
			 b=strings.Contains(sub,string(s[j]))
			if b {
			  pre=sub
			}else{
              pre=s[j:len(s)+1-1]
			  break
			}

		}
	    fmt.Println(pre)
		i++
	}

}

// https://codeforces.com/problemset/problem/1654/B

// 1654B - Prefix Removals

// You are given a string s consisting of lowercase letters of the English alphabet. You must perform the following algorithm on s:
//  • Let x be the length of the longest prefix of s which occurs somewhere else in s as a contiguous substring (the other occurrence may also intersect the prefix). If x=0, break. Otherwise, remove the first x characters of s, and repeat.
// A prefix is a string consisting of several first letters of a given string, without any reorders. An empty prefix is also a valid prefix. For example, the string "abcd" has 5 prefixes: empty string, "a", "ab", "abc" and "abcd".
// For instance, if we perform the algorithm on s= "abcabdc",
//  • Initially, "ab" is the longest prefix that also appears somewhere else as a substring in s, so s= "cabdc" after 1 operation.
//  • Then, "c" is the longest prefix that also appears somewhere else as a substring in s, so s= "abdc" after 2 operations.
//  • Now x=0 (because there are no non-empty prefixes of "abdc" that also appear somewhere else as a substring in s), so the algorithm terminates.
// Find the final state of the string after performing the algorithm.

// Input
// The first line contains a single integer t (1≤t≤10^4) — the number of test cases.
// This is followed by t lines, each containing a description of one test case. Each line contains a string s. The given strings consist only of lowercase letters of the English alphabet and have lengths between 1 and 2⋅10^5 inclusive.
// It is guaranteed that the sum of the lengths of s over all test cases does not exceed 2⋅10^5.

// Output
// For each test case, print a single line containing the string s after executing the algorithm. It can be shown that such string is non-empty.

// Example
// input
// 6
// abcabdc
// a
// bbbbbbbbbb
// codeforces
// cffcfccffccfcffcfccfcffccffcfccf
// zyzyzwxxyyxxyyzzyzzxxwzxwywxwzxxyzzw
// output
// abdc
// a
// b
// deforces
// cf
// xyzzw

// Note

// The first test case is explained in the statement.
// In the second test case, no operations can be performed on s.
// In the third test case,
//  • Initially, s= "bbbbbbbbbb".
//  • After 1 operation, s= "b".
// In the fourth test case,
//  • Initially, s= "codeforces".
//  • After 1 operation, s= "odeforces".
//  • After 2 operations, s= "deforces".

// Hints

// Are there any characters that you can never remove?
// You can't remove the rightmost occurrence of each letter. Can you remove the other characters?
// If you can remove s1,s2,…,si−1 and si is not the rightmost occurrence of a letter, you can also remove si.

// Tutorial

// Let a be the initial string. For a string z, let's define z(l,r)=zlzl+1…zr, i.e., the substring of z from l to r. The final string is a(k,n) for some k.
// In the final string, x=0, so the first character doesn't appear anywhere else in s. This means that ak≠ak+1,ak+2,…,an. In other words, ak is the rightmost occurrence of a letter in s.
// Can you ever remove ai, if ai≠ai+1,ai+2,…,an? Notice that you would need to remove a(l,r) (l≤i≤r): this means that there must exist a(l′,r′)=a(l,r) for some l′>l. So, ai+l′−l=ai, and this is a contradiction.
// Therefore, k is the smallest index such that ak≠ak+1,ak+2,…,an.
// You can find k by iterating over the string from right to left and updating the frequency of each letter. Indeed ai≠ai+1,ai+2,…,an if and only if the frequency of the letter ai is 0 up to now (in the iteration from right to left we are performing). The value of k is the minimum such index i.
// Complexity: O(n)

package main

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

func main() {
	var reader = bufio.NewReader(os.Stdin)
	var writer = bufio.NewWriter(os.Stdout)
	var c, i int
	var t uint
	var s string
	var frequency map[rune]int
	var x rune

	for c, _ = fmt.Fscan(reader, &t); c == 1; c, _ = fmt.Fscan(reader, &t) {
		for ; t > 0; t-- {
			fmt.Fscan(reader, &s)
			frequency = make(map[rune]int)

			for _, x = range s {
				frequency[x]++
			}

			for i, x = range s {
				frequency[x]--

				if frequency[x] == 0 {
					break
				}
			}

			fmt.Fprintln(writer, s[i:])
		}
	}

	writer.Flush()
}

package main

import (
	"fmt"
	"strings"
)

func main() {
	var t int
	_, err := fmt.Scanln(&t)
	if err != nil {
		return
	}
	i := 0
	for i < t {
		var s, sub string

		_, err := fmt.Scanln(&s)
		if err != nil {
			return
		}
		for j := 0; j < len(s); j++ {
			sub = s[j+1 : len(s)]

			if strings.Contains(sub, string(s[j])) != true {
				s = s[j:len(s)]
				break
			}

		}
		fmt.Println(s)
		i++
	}

}

package main

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

func main() {
	in, out := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		var s string
		fmt.Fscan(in, &s)
		m := [26]int{}
		cur := [26]int{}
		for j := 0; j < len(s); j++ {
			m[s[j]-'a']++
		}
		j := 0
		for ; j < len(s); j++ {
			cur[s[j]-'a']++
			if cur[s[j]-'a'] == m[s[j]-'a'] {
				break
			}
		}
		fmt.Fprintln(out, s[j:])
	}
}

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 T int
	var s string
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &s)
		pos := [26]int{}
		for i := len(s) - 1; i >= 0; i-- {
			if b := s[i] - 'a'; pos[b] == 0 {
				pos[b] = i + 1
			}
		}
		minP := len(s)
		for _, p := range pos {
			if p > 0 && p < minP {
				minP = p
			}
		}
		Fprintln(out, s[minP-1:])
	}
}

package main

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

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

	var T int
	fmt.Fscan(in, &T)
	for t := 0; t < T; t++ {
		var s string
		fmt.Fscan(in, &s)

		m := make([]int, 26)
		for i, v := range s {
			m[v-'a'] = i
		}

		var idx int
		for i, v := range s {
			if i == m[v-'a'] {
				idx = i
				break
			}
		}

		fmt.Fprintln(out, s[idx:])
	}
}

package main

import (
	"fmt"
)

func xuli() {
	var (
		n int
		s string
		m = map[byte]bool{}
	)
	fmt.Scan(&s)
	n = len(s)
	vt := n - 1
	for i := n - 1; i >= 0; i-- {
		x := s[i]
		if !m[x] {
			m[x] = true
			vt = i
			//fmt.Println(i)
		}
	}
	fmt.Println(s[vt:])
}

func main() {
	var (
		t int
	)
	for fmt.Scan(&t); t > 0; t-- {
		xuli()
	}
}

package main

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

/*
2
asdfsghf
babssb
---
asdfsghf
abssb
====
3
a
aa
aba
---
a
a
ba
*/

//goland:noinspection GoUnhandledErrorResult
func solve() {
	var s string
	scanf("%s\n", &s)

	rnToCnt := make(map[rune]int)

	for _, rn := range s {
		rnToCnt[rn]++
	}

	for i, rn := range s {
		if rnToCnt[rn] > 1 {
			rnToCnt[rn]--
		} else {
			fmt.Fprintln(writer, s[i:])
			return
		}
	}
}

//goland:noinspection GoUnhandledErrorResult
func main() {
	defer writer.Flush()

	t := 1
	scanf("%d\n", &t)

	for ; t > 0; t-- {
		solve()
	}
}

const maxUint = ^uint(0)

//goland:noinspection GoUnusedConst
const minUint = 0
const maxInt = int(maxUint >> 1)

//goland:noinspection GoUnusedConst
const minInt = -maxInt - 1

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

func scanf(f string, a ...interface{}) {
	if _, err := fmt.Fscanf(reader, f, a...); err != nil {
		panic(err)
	}
}

//goland:noinspection GoUnusedFunction
func reversed(s string) string {
	input := []rune(s)
	li := len(input)
	ret := make([]rune, li)
	for i, r := range input {
		ret[li-i-1] = r
	}
	return string(ret)
}

//goland:noinspection GoUnusedFunction
func divCeil(num, div int64) int64 {
	quot := num / div
	if num%div > 0 {
		quot++
	} else if num%div < 0 {
		quot--
	}
	return quot
}

//goland:noinspection GoUnusedFunction
func min(nums ...int64) int64 {
	minNumIdx := 0
	for i, num := range nums {
		if num < nums[minNumIdx] {
			minNumIdx = i
		}
	}

	return nums[minNumIdx]
}

//goland:noinspection GoUnusedFunction
func maxIdx(nums ...int) int {
	maxNumIdx := 0
	for i, num := range nums {
		if num > nums[maxNumIdx] {
			maxNumIdx = i
		}
	}

	return maxNumIdx
}

//goland:noinspection GoUnusedFunction
func abs(num int) int {
	if num < 0 {
		return -num
	}
	return num
}

//goland:noinspection GoUnusedFunction
func isPrime(num int) bool {
	if num == 2 || num == 3 {
		return true
	}

	if num <= 1 || num%2 == 0 || num%3 == 0 {
		return false
	}

	for i := 5; i*i <= num; i += 6 {
		if num%i == 0 || num%(i+2) == 0 {
			return false
		}
	}

	return true
}

//goland:noinspection GoUnusedFunction
func gcd(a, b int) int {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

//goland:noinspection GoUnusedFunction
func lcm(a, b int) int {
	return abs(a) / gcd(a, b) * abs(b)
}

// Examples:
//	digitAt(1234, -1) -> panic!
//	digitAt(1234, 0) -> 4
//	digitAt(1234, 1) -> 3
//	digitAt(1234, 2) -> 2
//	digitAt(1234, 3) -> 1
//	digitAt(1234, 4) -> panic!
//goland:noinspection GoUnusedFunction
func digitAt(num, pos int) int {
	if num == 0 {
		return 0
	}

	num = abs(num)

	lenNum := int(math.Log10(float64(num))) + 1
	if pos < 0 || pos >= lenNum {
		err := fmt.Sprintf("Out of bound access for digit. Position passed %d, number %d", pos, num)
		panic(err)
	}

	rem := num % int(math.Pow10(pos+1))
	return rem / int(math.Pow10(pos))
}

package main

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

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}
func main() {
	_r, _w := os.Stdin, os.Stdout
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	var solve func()

	/*-------------------------------Todo-----------------------------------------*/

	solve = func() {
		var s string
		Fscan(in, &s)
		var n int = len(s)
		pos := map[byte]int{}
		for i := 0; i < n; i++ {
			pos[s[i]] = i
		}
		var i int
		for i < n {
			if i < pos[s[i]] {
				i++
			} else {
				break
			}
		}
		Fprintln(out, s[i:])
	}

	/*----------------------------------------------------------------------------*/
	var T int = 1
	Fscan(in, &T)
	for i := 0; i < T; i++ {
		solve()
	}
}

package main

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

func main() {

	reader := bufio.NewReader(os.Stdin)
	writter := bufio.NewWriter(os.Stdout)
	defer writter.Flush()

	t := 0
	fmt.Fscan(reader, &t)

	for t > 0 {
		s := ""
		fmt.Fscan(reader, &s)

		// a := make([]int, n)
		// for i := range a {
		// 	fmt.Fscan(reader, &a[i])
		// }

		// result := solve(n, a)

		// for i := range result {
		// 	fmt.Fprintf(writter, "%d ", result[i])
		// }

		fmt.Fprintln(writter, solve(s))

		t--
	}

	// s := "abcabdc"
	// fmt.Println(s)
	// fmt.Println(solve(s))

}

func solve(s string) string {

	pos := [26]int{}
	for i := len(s) - 1; i >= 0; i-- {
		if b := s[i] - 'a'; pos[b] == 0 {
			pos[b] = i + 1
		}
	}

	fmt.Println(pos)

	minP := len(s)
	for _, p := range pos {
		if p > 0 && p < minP {
			minP = p
		}
	}

	return s[minP-1:]
}

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

// 	var T int
// 	var s string
// 	for Fscan(in, &T); T > 0; T-- {
// 		Fscan(in, &s)
// 		pos := [26]int{}
// 		for i := len(s) - 1; i >= 0; i-- {
// 			if b := s[i] - 'a'; pos[b] == 0 {
// 				pos[b] = i + 1
// 			}
// 		}
// 		minP := len(s)
// 		for _, p := range pos {
// 			if p > 0 && p < minP {
// 				minP = p
// 			}
// 		}
// 		Fprintln(out, s[minP-1:])
// 	}
// }

package main

import (
	"fmt"
	"strings"
)

var x []string

func main() {
	times := 0
	fmt.Scanf("%d\n", &times)
	x = make([]string, times)
	for i := 0; i < times; i++ {
		fmt.Scanf("%v", &x[i])
		fmt.Scanln()
	}
	for i := 0; i < times; i++ {
		fmt.Println(solution(x[i]))
	}
}

func solution(s string) string {
	for n := len(s); n > 2; {
		n = len(s)
		for i := (n - 1) / 2; i >= 0; i-- {
			if i == 0 {
				return s
			}
			if strings.Contains(s[i:], s[0:i]) {
				s = s[i:]
				break
			}
		}
	}
	return s
}

package main

import (
	"fmt"
	"strings"
)

var x []string

func main() {
	times := 0
	fmt.Scanf("%d\n", &times)
	x = make([]string, times)
	for i := 0; i < times; i++ {
		fmt.Scanf("%v", &x[i])
		fmt.Scanln()
	}
	for i := 0; i < times; i++ {
		fmt.Println(solution(x[i]))
	}
}

func solution(s string) string {
	for n := len(s); n > 1; {
		n = len(s)
		for i := (n - 1) / 2; i >= 0; i-- {
			if i == 0 {
				return s
			}
			if strings.Contains(s[i:], s[0:i]) {
				s = s[i:]
				break
			}
		}
	}
	return s
}

package main

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

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

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

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

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

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

/**
Run solve the problem CF1654B
Date: 9/18/2022
User: wotan
URL: https://codeforces.com/problemset/problem/1654/B
Problem: CF1654B
**/
func (in *CF1654B) Run() {
	var ans strings.Builder
	for t := in.NextInt(); t > 0; t-- {
		str := in.NextString()
		for maxp := maxPrefix(str); maxp != -1; {
			str = str[maxp:]
			maxp = maxPrefix(str)

		}
		ans.WriteString(str + "\n")
	}
	fmt.Print(ans.String())
}

func maxPrefix(str string) int {
	pre := false
	prefix := ""
	for i := 1; i < len(str); i++ {
		prefix += string(str[i-1])
		if strings.Contains(str[i:], prefix) {

			pre = true
			continue
		} else {
			if pre {

				return i
			}
		}
	}
	return -1
}

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

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


Omkar has a pie tray with $$$k$$$ ($$$2 \leq k \leq 20$$$) spots. Each spot in the tray contains either a chocolate pie or a pumpkin pie. However, Omkar does not like the way that the pies are currently arranged, and has another ideal arrangement that he would prefer instead.To assist Omkar, $$$n$$$ elves have gathered in a line to swap the pies in Omkar's tray. The $$$j$$$-th elf from the left is able to swap the pies at positions $$$a_j$$$ and $$$b_j$$$ in the tray.In order to get as close to his ideal arrangement as possible, Omkar may choose a contiguous subsegment of the elves and then pass his pie tray through the subsegment starting from the left. However, since the elves have gone to so much effort to gather in a line, they request that Omkar's chosen segment contain at least $$$m$$$ ($$$1 \leq m \leq n$$$) elves.Formally, Omkar may choose two integers $$$l$$$ and $$$r$$$ satisfying $$$1 \leq l \leq r \leq n$$$ and $$$r - l + 1 \geq m$$$ so that first the pies in positions $$$a_l$$$ and $$$b_l$$$ will be swapped, then the pies in positions $$$a_{l + 1}$$$ and $$$b_{l + 1}$$$ will be swapped, etc. until finally the pies in positions $$$a_r$$$ and $$$b_r$$$ are swapped.Help Omkar choose a segment of elves such that the amount of positions in Omkar's final arrangement that contain the same type of pie as in his ideal arrangement is the maximum possible. Note that since Omkar has a big imagination, it might be that the amounts of each type of pie in his original arrangement and in his ideal arrangement do not match.

The first line contains three integers $$$n$$$, $$$m$$$, and $$$k$$$ ($$$1 \leq m \leq n \leq 10^6$$$ and $$$2 \leq k \leq 20$$$)  — the number of elves, the minimum subsegment length, and the number of spots in Omkar's tray respectively.  The second and third lines each contain a string of length $$$k$$$ consisting of $$$0$$$s and $$$1$$$s that represent initial arrangement of pies and ideal arrangement of pies; the $$$j$$$-th character in each string is equal to $$$0$$$ if the $$$j$$$-th spot in the arrangement contains a chocolate pie and is equal to $$$1$$$ if the $$$j$$$-th spot in the arrangement contains a pumpkin pie. It is not guaranteed that the two strings have the same amount of $$$0$$$s or the same amount of $$$1$$$s. $$$n$$$ lines follow. The $$$j$$$-th of these lines contains two integers $$$a_j$$$ and $$$b_j$$$ ($$$1 \leq a_j, b_j \leq k$$$, $$$a_j \neq b_j$$$) which indicate that the $$$j$$$-th elf from the left can swap the pies at positions $$$a_j$$$ and $$$b_j$$$ in the tray.

Output two lines.  The first line should contain a single integer $$$s$$$ ($$$0 \leq s \leq k$$$) equal to the amount of positions that contain the same type of pie in Omkar's final arrangement and in Omkar's ideal arrangement; $$$s$$$ should be the maximum possible.  The second line should contain two integers $$$l$$$ and $$$r$$$ satisfying $$$1 \leq l \leq r \leq n$$$ and $$$r - l + 1 \geq m$$$, indicating that Omkar should pass his tray through the subsegment $$$l, l + 1, \dots, r$$$ to achieve a final arrangement with $$$s$$$ positions having the same type of pie as his ideal arrangement. If there are multiple answers you may output any of them.

NoteIn the first test case, the swaps will go like this:   Swap $$$1$$$ and $$$3$$$: 11000 becomes 01100  Swap $$$3$$$ and $$$5$$$: 01100 becomes 01001  Swap $$$4$$$ and $$$2$$$: 01001 becomes 00011  The final arrangement is the same as the ideal arrangement 00011, so there are $$$5$$$ positions with the same type of pie, which is optimal.In the second test case, the swaps will go like this:   Swap $$$1$$$ and $$$3$$$: 11000 becomes 01100  Swap $$$1$$$ and $$$5$$$: 01100 becomes 01100  Swap $$$4$$$ and $$$2$$$: 01100 becomes 00110  Swap $$$1$$$ and $$$5$$$: 00110 becomes 00110  The final arrangement has $$$3$$$ positions with the same type of pie as the ideal arrangement 00011, those being positions $$$1$$$, $$$2$$$, and $$$4$$$. In this case the subsegment of elves $$$(l, r) = (2, 3)$$$ is more optimal, but that subsegment is only length $$$2$$$ and therefore does not satisfy the constraint that the subsegment be of length at least $$$m = 3$$$.

package main

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

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

	n, m, k := readThreeNums(reader)

	a, _ := reader.ReadString('\n')
	b, _ := reader.ReadString('\n')

	swaps := make([][]int, n)

	for i := 0; i < n; i++ {
		swaps[i] = readNNums(reader, 2)
	}

	res := solve(n, m, k, a, b, swaps)

	fmt.Printf("%d\n", res[0])
	fmt.Printf("%d %d\n", res[1], res[2])
}

func readInt(bytes []byte, from int, val *int) int {
	i := from
	sign := 1
	if bytes[i] == '-' {
		sign = -1
		i++
	}
	tmp := 0
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + int(bytes[i]-'0')
		i++
	}
	*val = tmp * sign
	return i
}

func readNum(reader *bufio.Reader) (a int) {
	bs, _ := reader.ReadBytes('\n')
	readInt(bs, 0, &a)
	return
}

func readTwoNums(reader *bufio.Reader) (a int, b int) {
	res := readNNums(reader, 2)
	a, b = res[0], res[1]
	return
}

func readThreeNums(reader *bufio.Reader) (a int, b int, c int) {
	res := readNNums(reader, 3)
	a, b, c = res[0], res[1], res[2]
	return
}

func readNNums(reader *bufio.Reader, n int) []int {
	res := make([]int, n)
	x := 0
	bs, _ := reader.ReadBytes('\n')
	for i := 0; i < n; i++ {
		for x < len(bs) && (bs[x] < '0' || bs[x] > '9') && bs[x] != '-' {
			x++
		}
		x = readInt(bs, x, &res[i])
	}
	return res
}

func readUint64(bytes []byte, from int, val *uint64) int {
	i := from

	var tmp uint64
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + uint64(bytes[i]-'0')
		i++
	}
	*val = tmp

	return i
}

func solve(n, m, k int, s, t string, swaps [][]int) []int {
	K := 1 << k
	dp := make([]int, K)
	fp := make([]int, K)
	for i := 0; i < K; i++ {
		dp[i] = n
		fp[i] = -n
	}
	S := []byte(s)
	T := []byte(t)
	dp[getMask(S, k)] = 0
	fp[getMask(T, k)] = 0

	p := make([]int, k)
	for i := 0; i < k; i++ {
		p[i] = i
	}

	for i := 1; i <= n; i++ {
		l, r := swaps[i-1][0], swaps[i-1][1]
		l--
		r--
		p[l], p[r] = p[r], p[l]
		for j := 0; j < k; j++ {
			S[p[j]] = s[j]
			T[p[j]] = t[j]
		}
		mask := getMask(S, k)
		dp[mask] = min(dp[mask], i)
		mask = getMask(T, k)
		fp[mask] = i
	}
	x := countDigit(s, '1')
	y := countDigit(t, '1')
	var best int
	var left, right int = 1, 1
	for mask := K - 1; mask >= 0; mask-- {
		if fp[mask]-dp[mask] >= m {

			z := countDigitOne(mask)
			tmp := k - (x + y - 2*z)
			if tmp >= best {
				best = tmp
				left = dp[mask] + 1
				right = fp[mask]
			}
		}

		for j := 0; j < k; j++ {
			if mask&(1<<j) > 0 {
				dp[mask^(1<<j)] = min(dp[mask^(1<<j)], dp[mask])
				fp[mask^(1<<j)] = max(fp[mask^(1<<j)], fp[mask])
			}
		}
	}

	return []int{best, left, right}
}

func countDigitOne(num int) int {
	var res int
	for num > 0 {
		res++
		num -= num & -num
	}
	return res
}

func countDigit(s string, x byte) int {
	var res int
	for i := 0; i < len(s); i++ {
		if s[i] == x {
			res++
		}
	}
	return res
}

func getMask(s []byte, n int) int {
	var res int
	for i := 0; i < n; i++ {
		res |= int(s[i]-'0') << i
	}
	return res
}

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
}

package main

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

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

	n, m, k := readThreeNums(reader)

	a, _ := reader.ReadString('\n')
	b, _ := reader.ReadString('\n')

	swaps := make([][]int, n)

	for i := 0; i < n; i++ {
		swaps[i] = readNNums(reader, 2)
	}

	res := solve(n, m, k, a, b, swaps)

	fmt.Printf("%d\n", res[0])
	fmt.Printf("%d %d\n", res[1], res[2])
}

func readInt(bytes []byte, from int, val *int) int {
	i := from
	sign := 1
	if bytes[i] == '-' {
		sign = -1
		i++
	}
	tmp := 0
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + int(bytes[i]-'0')
		i++
	}
	*val = tmp * sign
	return i
}

func readNum(reader *bufio.Reader) (a int) {
	bs, _ := reader.ReadBytes('\n')
	readInt(bs, 0, &a)
	return
}

func readTwoNums(reader *bufio.Reader) (a int, b int) {
	res := readNNums(reader, 2)
	a, b = res[0], res[1]
	return
}

func readThreeNums(reader *bufio.Reader) (a int, b int, c int) {
	res := readNNums(reader, 3)
	a, b, c = res[0], res[1], res[2]
	return
}

func readNNums(reader *bufio.Reader, n int) []int {
	res := make([]int, n)
	x := 0
	bs, _ := reader.ReadBytes('\n')
	for i := 0; i < n; i++ {
		for x < len(bs) && (bs[x] < '0' || bs[x] > '9') && bs[x] != '-' {
			x++
		}
		x = readInt(bs, x, &res[i])
	}
	return res
}

func readUint64(bytes []byte, from int, val *uint64) int {
	i := from

	var tmp uint64
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + uint64(bytes[i]-'0')
		i++
	}
	*val = tmp

	return i
}

func solve(n, m, k int, s, t string, swaps [][]int) []int {
	K := 1 << k
	dp := make([]int, K)
	fp := make([]int, K)
	for i := 0; i < K; i++ {
		dp[i] = n
		fp[i] = -n
	}
	S := []byte(s)
	T := []byte(t)
	dp[getMask(S, k)] = 0
	fp[getMask(T, k)] = 0

	p := make([]int, k)
	for i := 0; i < k; i++ {
		p[i] = i
	}

	for i := 1; i <= n; i++ {
		l, r := swaps[i-1][0], swaps[i-1][1]
		l--
		r--
		p[l], p[r] = p[r], p[l]
		for j := 0; j < k; j++ {
			S[p[j]] = s[j]
			T[p[j]] = t[j]
		}
		mask := getMask(S, k)
		dp[mask] = min(dp[mask], i)
		mask = getMask(T, k)
		fp[mask] = i
	}
	x := countDigit(s, '1')
	y := countDigit(t, '1')
	var best int
	var left, right int
	for mask := K - 1; mask >= 0; mask-- {
		if fp[mask]-dp[mask] >= m {

			z := countDigitOne(mask)
			tmp := k - (x + y - 2*z)
			if tmp > best {
				best = tmp
				left = dp[mask] + 1
				right = fp[mask]
			}
		}

		for j := 0; j < k; j++ {
			if mask&(1<<j) > 0 {
				dp[mask^(1<<j)] = min(dp[mask^(1<<j)], dp[mask])
				fp[mask^(1<<j)] = max(fp[mask^(1<<j)], fp[mask])
			}
		}
	}

	return []int{best, left, right}
}

func countDigitOne(num int) int {
	var res int
	for num > 0 {
		res++
		num -= num & -num
	}
	return res
}

func countDigit(s string, x byte) int {
	var res int
	for i := 0; i < len(s); i++ {
		if s[i] == x {
			res++
		}
	}
	return res
}

func getMask(s []byte, n int) int {
	var res int
	for i := 0; i < n; i++ {
		res |= int(s[i]-'0') << i
	}
	return res
}

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
}


You are given a convex polygon P with n distinct vertices p1, p2, ..., pn. Vertex pi has coordinates (xi, yi) in the 2D plane. These vertices are listed in clockwise order.You can choose a real number D and move each vertex of the polygon a distance of at most D from their original positions.Find the maximum value of D such that no matter how you move the vertices, the polygon does not intersect itself and stays convex.

The first line has one integer n (4 ≤ n ≤ 1 000) — the number of vertices. The next n lines contain the coordinates of the vertices. Line i contains two integers xi and yi ( - 109 ≤ xi, yi ≤ 109) — the coordinates of the i-th vertex. These points are guaranteed to be given in clockwise order, and will form a strictly convex polygon (in particular, no three consecutive points lie on the same straight line).

Print one real number D, which is the maximum real number such that no matter how you move the vertices, the polygon stays convex. Your answer will be considered correct if its absolute or relative error does not exceed 10 - 6. Namely, let's assume that your answer is a and the answer of the jury is b. The checker program will consider your answer correct if .

NoteHere is a picture of the first sampleHere is an example of making the polygon non-convex.This is not an optimal solution, since the maximum distance we moved one point is  ≈ 0.4242640687, whereas we can make it non-convex by only moving each point a distance of at most  ≈ 0.3535533906.

package main

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

const eps = 1e-8

type vec struct {
	x, y float64
}

func (a vec) add(b vec) vec     { return vec{a.x + b.x, a.y + b.y} }
func (a vec) sub(b vec) vec     { return vec{a.x - b.x, a.y - b.y} }
func (a vec) mul(k float64) vec { return vec{a.x * k, a.y * k} }
func (a vec) len() float64      { return math.Hypot(a.x, a.y) }
func (a vec) dot(b vec) float64 { return a.x*b.x + a.y*b.y }
func (a vec) det(b vec) float64 { return a.x*b.y - a.y*b.x }

type line struct {
	p1, p2 vec
}

func (a vec) perpendicular(l line) line {
	return line{a, a.add(vec{l.p1.y - l.p2.y, l.p2.x - l.p1.x})}
}

func (a line) intersection(b line) vec {
	va, vb := a.p2.sub(a.p1), b.p2.sub(b.p1)
	k := vb.det(b.p1.sub(a.p1)) / vb.det(a.p2.sub(a.p1))
	return a.p1.add(va.mul(k))
}

func (a vec) onSeg(l line) bool {
	p1 := l.p1.sub(a)
	p2 := l.p2.sub(a)
	return p1.dot(p2) < eps
}

func (a vec) disToSeg(l line) (d float64, ok bool) {
	p := l.intersection(a.perpendicular(l))
	if !p.onSeg(l) {
		return
	}
	return a.sub(p).len(), true
}

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

	var n int
	Fscan(in, &n)
	ps := make([]vec, n, n+2)
	for i := range ps {
		Fscan(in, &ps[i].x, &ps[i].y)
	}
	ps = append(ps, ps[0], ps[1])
	ans := math.MaxFloat64
	for i := 1; i <= n; i++ {
		if d, ok := ps[i].disToSeg(line{ps[i-1], ps[i+1]}); ok && d < ans {
			ans = d
		}
	}
	Fprintf(out, "%.10f", ans/2)
}

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

package main

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

const eps = 1e-8

type vec struct {
	x, y float64
}

func (a vec) add(b vec) vec     { return vec{a.x + b.x, a.y + b.y} }
func (a vec) sub(b vec) vec     { return vec{a.x - b.x, a.y - b.y} }
func (a vec) mul(k float64) vec { return vec{a.x * k, a.y * k} }
func (a vec) len() float64      { return math.Hypot(a.x, a.y) }
func (a vec) dot(b vec) float64 { return a.x*b.x + a.y*b.y }
func (a vec) det(b vec) float64 { return a.x*b.y - a.y*b.x }

type line struct {
	p1, p2 vec
}

func (a vec) disToSeg(l line) (d float64, ok bool) {
	v, v1, v2 := l.p2.sub(l.p1), a.sub(l.p1), a.sub(l.p2)
	if v.dot(v1) < -eps || v.dot(v2) > eps {
		return
	}
	return math.Abs(v.det(v1)) / v.len(), true
}

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

	var n int
	Fscan(in, &n)
	ps := make([]vec, n, n+2)
	for i := range ps {
		Fscan(in, &ps[i].x, &ps[i].y)
	}
	ps = append(ps, ps[0], ps[1])
	ans := math.MaxFloat64
	for i := 1; i <= n; i++ {
		if d, ok := ps[i].disToSeg(line{ps[i-1], ps[i+1]}); ok && d < ans {
			ans = d
		}
	}
	Fprintf(out, "%.10f", ans/2)
}

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

package main

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

type vec struct {
	x, y float64
}

func (a vec) sub(b vec) vec     { return vec{a.x - b.x, a.y - b.y} }
func (a vec) len() float64      { return math.Hypot(a.x, a.y) }
func (a vec) det(b vec) float64 { return a.x*b.y - a.y*b.x }

type line struct {
	p1, p2 vec
}

func (a vec) disToLine(l line) float64 {
	v, u := l.p2.sub(l.p1), a.sub(l.p1)
	return math.Abs(v.det(u)) / v.len()
}

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

	var n int
	Fscan(in, &n)
	ps := make([]vec, n, n+2)
	for i := range ps {
		Fscan(in, &ps[i].x, &ps[i].y)
	}
	ps = append(ps, ps[0], ps[1])
	ans := math.MaxFloat64
	for i := 1; i <= n; i++ {
		if d := ps[i].disToLine(line{ps[i-1], ps[i+1]}); d < ans {
			ans = d
		}
	}
	Fprintf(out, "%.10f", ans/2)
}

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

package main

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

const eps = 1e-8

type vec struct {
	x, y float64
}

func (a vec) add(b vec) vec     { return vec{a.x + b.x, a.y + b.y} }
func (a vec) sub(b vec) vec     { return vec{a.x - b.x, a.y - b.y} }
func (a vec) mul(k float64) vec { return vec{a.x * k, a.y * k} }
func (a vec) len() float64      { return math.Hypot(a.x, a.y) }
func (a vec) dot(b vec) float64 { return a.x*b.x + a.y*b.y }
func (a vec) det(b vec) float64 { return a.x*b.y - a.y*b.x }

type line struct {
	p1, p2 vec
}

func (a vec) perpendicular(l line) line {
	return line{a, a.add(vec{l.p1.y - l.p2.y, l.p2.x - l.p1.x})}
}

func (a line) intersection(b line) vec {
	va, vb := a.p2.sub(a.p1), b.p2.sub(b.p1)
	k := vb.det(b.p1.sub(a.p1)) / vb.det(a.p2.sub(a.p1))
	return a.p1.add(va.mul(k))
}

func (a vec) onSeg(l line) bool {
	p1 := l.p1.sub(a)
	p2 := l.p2.sub(a)
	return math.Abs(p1.det(p2)) < eps && p1.dot(p2) < eps
}

func (a vec) disToSeg(l line) (d float64, ok bool) {
	p := l.intersection(a.perpendicular(l))
	if !p.onSeg(l) {
		return
	}
	return a.sub(p).len(), true
}

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

	var n int
	Fscan(in, &n)
	ps := make([]vec, n, n+2)
	for i := range ps {
		Fscan(in, &ps[i].x, &ps[i].y)
	}
	ps = append(ps, ps[0], ps[1])
	ans := math.MaxFloat64
	for i := 1; i <= n; i++ {
		if d, ok := ps[i].disToSeg(line{ps[i-1], ps[i+1]}); ok && d < ans {
			ans = d
		}
	}
	Fprintf(out, "%.10f", ans/2)
}

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


In the official contest this problem has a different statement, for which jury's solution was working incorrectly, and for this reason it was excluded from the contest. This mistake have been fixed and the current given problem statement and model solution corresponds to what jury wanted it to be during the contest.Vova and Lesha are friends. They often meet at Vova's place and compete against each other in a computer game named The Ancient Papyri: Swordsink. Vova always chooses a warrior as his fighter and Leshac chooses an archer. After that they should choose initial positions for their characters and start the fight. A warrior is good at melee combat, so Vova will try to make the distance between fighters as small as possible. An archer prefers to keep the enemy at a distance, so Lesha will try to make the initial distance as large as possible.There are n (n is always even) possible starting positions for characters marked along the Ox axis. The positions are given by their distinct coordinates x1, x2, ..., xn, two characters cannot end up at the same position.Vova and Lesha take turns banning available positions, Vova moves first. During each turn one of the guys bans exactly one of the remaining positions. Banned positions cannot be used by both Vova and Lesha. They continue to make moves until there are only two possible positions remaining (thus, the total number of moves will be n - 2). After that Vova's character takes the position with the lesser coordinate and Lesha's character takes the position with the bigger coordinate and the guys start fighting.Vova and Lesha are already tired by the game of choosing positions, as they need to play it before every fight, so they asked you (the developer of the The Ancient Papyri: Swordsink) to write a module that would automatically determine the distance at which the warrior and the archer will start fighting if both Vova and Lesha play optimally.

The first line on the input contains a single integer n (2 ≤ n ≤ 200 000, n is even) — the number of positions available initially. The second line contains n distinct integers x1, x2, ..., xn (0 ≤ xi ≤ 109), giving the coordinates of the corresponding positions.

Print the distance between the warrior and the archer at the beginning of the fight, provided that both Vova and Lesha play optimally.

NoteIn the first sample one of the optimum behavior of the players looks like that:  Vova bans the position at coordinate 15;  Lesha bans the position at coordinate 3;  Vova bans the position at coordinate 31;  Lesha bans the position at coordinate 1. After these actions only positions 0 and 7 will remain, and the distance between them is equal to 7.In the second sample there are only two possible positions, so there will be no bans.

package main

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

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

func main() {
    cin := bufio.NewReader(os.Stdin)
    n := 0
    var ns []int

    fmt.Fscanf(cin, "%d\n", &n)
    for i := 0; i < n; i++ {
        x := 0
        fmt.Fscanf(cin, "%d\n", &x)
        ns = append(ns, x)
    }

    sort.Ints(ns)

    ans := 0x3f3f3f3f
    for i := 0; i + n / 2 < n; i++ {
        a := ns[i]
        b := ns[i + n / 2]
        ans = min(ans, b - a)
    }

    fmt.Println(ans)
}