package main

import."fmt"
import"bufio"
import"os"
import."sort"

func main(){
	in:=bufio.NewReader(os.Stdin)
	var n int
	Fscan(in,&n)
	a:=make([]int,n)
	for i:=0;i<n;i++{
		Fscan(in,&a[i])
	}

	if n==1{
		Print(a[0])
		return
	}
	Ints(a)
	pos:=-1
	for i:=0;i<n;i++{
		if a[i]>=0{
			pos=i
			break
		}
	}
	ans:=int64(0)
	if pos==-1||pos==n-1{
		ans=int64(a[n-1])
		for i:=0;i<n-1;i++{
			ans-=int64(a[i])
		}
	}else if pos==0{
		ans=int64(a[0])
		for i:=1;i<n-1;i++{
			ans-=int64(a[i])
		}
		ans=int64(a[n-1])-ans
	}else{
		ans=int64(a[pos-1])
		for i:=pos;i<n-1;i++{
			ans-=int64(a[i])
		}
		ans=int64(a[n-1])-ans
		for i:=0;i<pos-1;i++{
			ans-=int64(a[i])
		}
	}
	Print(ans)
}

package main

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

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...) }

var db bool = false
const maxn int = 5*1e5

var n int
var a [maxn+2]int64

var LPM [maxn+2]int64 //left_pos_min
var LPS [maxn+2]int64 //left_pos_sum
var LNS [maxn+2]int64 //left_neg_sum

var RPM [maxn+2]int64 //right_pos_min
var RPS [maxn+2]int64 //right_pos_sum
var RNS [maxn+2]int64 //right_neg_sum

var ans, tans, lans, rans int64
var pos_min int64

func main() {
    defer writer.Flush()
    scanf("%d\n", &n)

    pos_min = 1e9+1

    for i := 1; i <= n; i++ {
        scanf("%d", &a[i])
        LPS[i], LNS[i] = LPS[i-1], LNS[i-1]
        if a[i] >= 0 {
            LPS[i] = LPS[i-1] + a[i]
            if a[i] < pos_min {
                pos_min = a[i]
            }
            LPM[i] = pos_min
        } else {
            LNS[i] = LNS[i-1] + a[i]
        }
    }

    pos_min = 1e9+1

    for i := n; i >= 1; i-- {
        RPS[i], RNS[i] = RPS[i+1], RNS[i+1]
        if a[i] >= 0 {
            RPS[i] = RPS[i+1] + a[i]
            if a[i] < pos_min {
                pos_min = a[i]
            }
            RPM[i] = pos_min
        } else {
            RNS[i] = RNS[i+1] + a[i]
        }
    }

    ans = -1 << 63
    for i := 1; i <= n; i++ {
        tans = a[i]
        lans, rans = 0, 0
        if i > 1 {
            //there is a possibility we can get some improvement from the LEFT portion
            if LNS[i-1] < 0 {
                //there was at least one neg num
                lans = -LNS[i-1] + LPS[i-1]
            } else {
                //all nums on the left are non-negative
                if i == 2 {
                    //there is only one num on the left and that num is non-negative
                    lans = -LPM[i-1]
                } else {
                    //there are only non-negative numbers[many] on the left
                    lans = LPS[i-1] - 2*LPM[i-1]
                }
            }
        }
        if i < n {
            //there is a possibility we can get some improvement from the RIGHT portion
            if RNS[i+1] < 0 {
                //there was at least one neg num
                rans = -RNS[i+1] + RPS[i+1]
            } else {
                //all nums are non-negative
                if i == n-1 {
                    //there is only one num on the right and that num is non-negative
                    rans = -RPM[i+1]
                } else {
                    //there are only non-negative numbers[many] on the right
                    rans = RPS[i+1] - 2*RPM[i+1]
                }
            }
        }
        tans += (lans + rans)
        if tans > ans {
            ans = tans
        }
    }
    printf("%d", ans)
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	s, err := in.ReadString('\n')
	if err != nil {
		log.Fatal(err)
	}
	str := strings.Fields(s)
	num, err := strconv.Atoi(str[0])
	if err != nil {
		log.Fatal(err)
	}
	s, err = in.ReadString('\n')
	if err != nil {
		log.Fatal(err)
	}
	str = strings.Fields(s)
	vals := make([]int, 0, num)
	//flag: 2(complex), 1(positive), -1(negative)
	flag := 0
	for _, v := range str {
		temp, err := strconv.Atoi(v)
		if err != nil {
			log.Fatal(err)
			continue
		}
		vals = append(vals, temp)
		if flag == 0 {
			if temp > 0 {
				flag = 1
			} else {
				flag = -1
			}
			continue
		} else if flag == 2 {
			continue
		} else {
			if flag*temp < 0 {
				flag = 2
			}
		}
	}
	out := bufio.NewWriter(os.Stdout)
	if num == 1 {
		fmt.Fprint(out, vals[0])
	} else if num == 2 {
		fmt.Fprint(out, int(math.Abs(float64(vals[0]-vals[1]))))
	} else {
		if flag == 0 {
			fmt.Fprint(out, 0)
		} else if flag == 1 {
			var sum int64
			min := vals[0]
			for _, v := range vals {
				sum += int64(v)
				if min > v {
					min = v
				}
			}
			fmt.Fprint(out, sum-int64(2*min))
		} else if flag == -1 {
			var sum int64
			max := vals[0]
			for _, v := range vals {
				sum += int64(v)
				if max < v {
					max = v
				}
			}
			fmt.Fprint(out, int64(2*max)-sum)
		} else {
			var sum int64
			for _, v := range vals {
				sum += int64(math.Abs(float64(v)))
			}
			fmt.Fprint(out, sum)
		}
	}
	out.Flush()
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	var n int
	Fscan(in, &n)
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		Fscan(in, &arr[i])
	}
	if n == 1 {
		Print(arr[0])
		return
	}
	sort.Ints(arr)
	ans := int64(arr[n-1] - arr[0])
	for i := 1; i < n-1; i++ {
		a := arr[i]
		if a < 0 {
			a = -a
		}
		ans += int64(a)
	}
	Print(ans)
}

package main

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

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...) }

const maxn int = 5*1e5

var n int
var a [maxn+2]int64

var LPM [maxn+2]int64 //left_pos_min
var LPS [maxn+2]int64 //left_pos_sum
var LNS [maxn+2]int64 //left_neg_sum

var RPM [maxn+2]int64 //right_pos_min
var RPS [maxn+2]int64 //right_pos_sum
var RNS [maxn+2]int64 //right_neg_sum

var ans, tans, lans, rans int64
var pos_min int64

func main() {
    defer writer.Flush()
    scanf("%d\n", &n)

    pos_min = 1e9+1
    //LPS[0] = 0
    //LNS[0] = 0
    //LPM[0] = pos_min

    for i := 1; i <= n; i++ {
        scanf("%d", &a[i])
        if a[i] >= 0 {
            LPS[i] = LPS[i-1] + a[i]
            if a[i] < pos_min {
                pos_min = a[i]
            }
            LPM[i] = pos_min
        } else {
            LNS[i] = LNS[i-1] + a[i]
        }
    }

    pos_min = 1e9+1
    //RPS[0] = 0
    //RNS[0] = 0
    //RPM[0] = pos_min

    for i := n; i >= 1; i-- {
        if a[i] >= 0 {
            RPS[i] = RPS[i+1] + a[i]
            if a[i] < pos_min {
                pos_min = a[i]
            }
            RPM[i] = pos_min
        } else {
            RNS[i] = RNS[i+1] + a[i]
        }
    }

    ans = -1 << 63
    for i := 1; i <= n; i++ {
        tans = a[i]
        lans, rans = 0, 0
        if i > 1 {
            //there is a possibility we can get some improvement from the LEFT portion
            if LNS[i-1] < 0 {
                //there was at least one neg num
                lans = -LNS[i-1] + LPS[i-1]
            } else {
                //all nums on the left are non-negative
                if i == 2 {
                    //there is only one num on the left and that num is non-negative
                    lans = -LPM[i-1]
                } else {
                    //there are only non-negative numbers[many] on the left
                    lans = LPS[i-1] - 2*LPM[i-1]
                }
            }
        }
        if i < n {
            //there is a possibility we can get some improvement from the RIGHT portion
            if RNS[i+1] < 0 {
                //there was at least one neg num
                rans = -RNS[i+1] + RPS[i+1]
            } else {
                //all nums are non-negative
                if i == n-1 {
                    //there is only one num on the right and that num is non-negative
                    rans = -RPM[i+1]
                } else {
                    //there are only non-negative numbers[many] on the right
                    rans = RPS[i+1] - 2*RPM[i+1]
                }
            }
        }
        tans += (lans + rans)
        if tans > ans {
            ans = tans
        }
    }
    printf("%d", ans)
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	s, err := in.ReadString('\n')
	if err != nil {
		log.Fatal(err)
	}
	str := strings.Fields(s)
	num, err := strconv.Atoi(str[0])
	if err != nil {
		log.Fatal(err)
	}
	s, err = in.ReadString('\n')
	if err != nil {
		log.Fatal(err)
	}
	str = strings.Fields(s)
	vals := make([]int, 0, num)
	var sum int64
	min, max := 0, 0
	for _, v := range str {
		temp, err := strconv.Atoi(v)
		if err != nil {
			log.Fatal(err)
			continue
		}
		vals = append(vals, temp)
		sum += int64(math.Abs(float64(temp)))
		if min > temp {
			min = temp
		}
		if max < temp {
			max = temp
		}
	}
	if min > 0 {
		sum -= int64(min * 2)
	}
	if max < 0 {
		sum += int64(max * 2)
	}
	out := bufio.NewWriter(os.Stdout)
	fmt.Fprint(out, sum)
	out.Flush()
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	s, err := in.ReadString('\n')
	if err != nil {
		log.Fatal(err)
	}
	str := strings.Fields(s)
	num, err := strconv.Atoi(str[0])
	if err != nil {
		log.Fatal(err)
	}
	s, err = in.ReadString('\n')
	if err != nil {
		log.Fatal(err)
	}
	str = strings.Fields(s)
	vals := make([]int, 0, num)
	//flag: 2(complex), 1(positive), -1(negative)
	flag := 0
	for _, v := range str {
		temp, err := strconv.Atoi(v)
		if err != nil {
			log.Fatal(err)
			continue
		}
		vals = append(vals, temp)
		if flag == 0 {
			if temp > 0 {
				flag = 1
			} else {
				flag = -1
			}
			continue
		} else if flag == 2 {
			continue
		} else {
			if flag*temp < 0 {
				flag = 2
			}
		}
	}
	out := bufio.NewWriter(os.Stdout)
	if num == 1 {
		fmt.Fprint(out, vals[0])
	} else if num == 2 {
		fmt.Fprint(out, int(math.Abs(float64(vals[0]-vals[1]))))
	} else {
		if flag == 0 {
			fmt.Fprint(out, 0)
		} else if flag == 1 {
			sum, min := 0, vals[0]
			for _, v := range vals {
				sum += v
				if min > v {
					min = v
				}
			}
			fmt.Fprint(out, sum-2*min)
		} else if flag == -1 {
			sum, max := 0, vals[0]
			for _, v := range vals {
				sum += v
				if max < v {
					max = v
				}
			}
			fmt.Fprint(out, 2*max-sum)
		} else {
			sum := 0
			for _, v := range vals {
				sum += int(math.Abs(float64(v)))
			}
			fmt.Fprint(out, sum)
		}
	}
	out.Flush()
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	s, err := in.ReadString('\n')
	if err != nil {
		log.Fatal(err)
	}
	str := strings.Fields(s)
	num, err := strconv.Atoi(str[0])
	if err != nil {
		log.Fatal(err)
	}
	s, err = in.ReadString('\n')
	if err != nil {
		log.Fatal(err)
	}
	str = strings.Fields(s)
	vals := make([]int, 0, num)
	var sum int64
	min, max := 0, 0
	for _, v := range str {
		temp, err := strconv.Atoi(v)
		if err != nil {
			log.Fatal(err)
			continue
		}
		vals = append(vals, temp)
		sum += int64(math.Abs(float64(temp)))
		if min > temp {
			min = temp
		}
		if max < temp {
			max = temp
		}
	}
	if min > 0 {
		sum -= int64(min * 2)
	}else if max < 0 {
		sum += int64(max * 2)
	}
	out := bufio.NewWriter(os.Stdout)
	fmt.Fprint(out, sum)
	out.Flush()
	//
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	s, err := in.ReadString('\n')
	if err != nil {
		log.Fatal(err)
	}
	str := strings.Fields(s)
	num, err := strconv.Atoi(str[0])
	if err != nil {
		log.Fatal(err)
	}
	s, err = in.ReadString('\n')
	if err != nil {
		log.Fatal(err)
	}
	str = strings.Fields(s)
	vals := make([]int, 0, num)
	var sum int64
	min, max := 0, 0
	for _, v := range str {
		temp, err := strconv.Atoi(v)
		if err != nil {
			log.Fatal(err)
			continue
		}
		vals = append(vals, temp)
		sum += int64(math.Abs(float64(temp)))
		if min > temp {
			min = temp
		}
		if max < temp {
			max = temp
		}
	}
	if min > 0 {
		sum -= int64(min * 2)
	}else if max < 0 {
		sum += int64(max * 2)
	}
	out := bufio.NewWriter(os.Stdout)
	fmt.Fprint(out, sum)
	out.Flush()
}


package main

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

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

func Printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func Scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }

func Dprint(format string, a ...interface{}) {
	if Debug {
		fmt.Fprintf(os.Stderr, format+"\n", a...)
	}
}

func areEqual(s, t []byte) bool {
	if len(s) != len(t) {
		panic("slice neq")
	}
	for i := 0; i < len(s); i++ {
		if s[i] != t[i] {
			return false
		}
	}
	return true
}

func hasDup(s []byte) bool {
	for i := 1; i < len(s); i++ {
		if s[i-1] == s[i] {
			return true
		}
	}
	return false
}

func calParity(s []byte) bool {
	par := false
	for i := 0; i < len(s); i++ {
		for j := i + 1; j < len(s); j++ {
			if s[i] > s[j] {
				par = !par
			}
		}
	}
	return par
}

func solve(n int, s, t []byte) bool {
	sc := append([]byte{}, s...)
	tc := append([]byte{}, t...)
	sort.Slice(sc, func(i, j int) bool {
		return sc[i] < sc[j]
	})
	sort.Slice(tc, func(i, j int) bool {
		return tc[i] < tc[j]
	})
	if !areEqual(sc, tc) {
		return false
	}
	if hasDup(sc) {
		return true
	}
	return calParity(s) == calParity(t)
}

func main() {
	defer writer.Flush()
	var q int
	Scanf("%d\n", &q)
	for i := 0; i < q; i++ {
		var n int
		var s, t []byte
		Scanf("%d\n%s\n%s\n", &n, &s, &t)
		if solve(n, s, t) {
			Printf("YES\n")
		} else {
			Printf("NO\n")
		}
	}
}

package main

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

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

	var T, n int
	var s, t []byte
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n, &s, &t)
		same := false
		cnt := [26]int{}
		for _, b := range s {
			if cnt[b-'a']++; cnt[b-'a'] > 1 {
				same = true
			}
		}
		for _, b := range t {
			cnt[b-'a']--
		}
		if cnt != [26]int{} {
			Fprintln(out, "NO")
		} else if same {
			Fprintln(out, "YES")
		} else {
			c := 0
			for i, b := range s {
				for _, b2 := range s[:i] {
					if b2 > b {
						c ^= 1
					}
				}
			}
			for i, b := range t {
				for _, b2 := range t[:i] {
					if b2 > b {
						c ^= 1
					}
				}
			}
			if c > 0 {
				Fprintln(out, "NO")
			} else {
				Fprintln(out, "YES")
			}
		}
	}
}

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

package main

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

func check(x, y []byte, n int) bool {
	for ; n > 2; n-- {
		if x[n-1] == y[n-1] {
			continue
		}

		for i := 0; i < n; i++ {
			if x[i] == y[n-1] {
				if (n-1-i)%2 > 0 {
					y[0], y[1] = y[1], y[0]
				}

				for j := i + 1; j < n; j++ {
					x[j-1] = x[j]
				}

				break
			}
		}
	}

	for i := 0; i < n; i++ {
		if x[i] != y[i] {
			return false
		}
	}

	return true
}

func main() {

	reader := bufio.NewReader(os.Stdin)
	var n, p int

	fmt.Fscanf(reader, "%d\n", &p)
	for ; p > 0; p-- {
		var s1, s2 string
		fmt.Fscanf(reader, "%d\n%s\n%s\n", &n, &s1, &s2)

		var a1, a2 [27]int
		for i := 0; i < n; i++ {
			a1[s1[i]-'a']++
			a2[s2[i]-'a']++
		}

		ok := 1 // 0:NO  2:YES  1:possibly
		for i := 0; i < 27; i++ {
			if a1[i] != a2[i] {
				ok = 0
				break
			} else if a1[i] > 1 {
				ok = 2
			}
		}

		if ok == 0 {
			fmt.Println("NO")
			continue
		}

		if ok == 2 {
			fmt.Println("YES")
			continue
		}

		if check([]byte(s1), []byte(s2), n) {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}


package main

import (
	"fmt"

)
var n int
const maxn int = 100005
var nxt [maxn] int
var dp  [maxn] int
const mod int = 1000*1000*1000 + 7
var s string
func solve(ind int) int {

	if ind == n {
		return 1
	}

	if dp[ind] != -1 {
		return dp[ind]
	}

	ret := 0

	if s[ind] == 'a' {
		ret += solve(nxt[ind])
		ret %= mod
	}

	ret += solve(ind + 1)

	ret %= mod
	dp[ind] = ret

	return dp[ind]
}
func main() {

	fmt.Scan(&s)
	n = len(s)

	lst := n
	for i := n - 1 ; i >= 0 ; i-- {
		dp[i] = -1
		nxt[i] = lst;

		if s[i] == 'b' {
			lst = i
		}

	}
	fmt.Println((solve(0) - 1 + mod) % mod);

}

// 1. Only care about a and b.
// 2. Can break the input into a groups.
// 3. Can only care about the very next group.
package main

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

type i64 int64

var (
	ascA   = "a"[0]
	ascB   = "b"[0]
	modulo = i64(1e9) + 7
)

func main() {
	s := ""
	reader := bufio.NewReaderSize(os.Stdin, int(1e5))
	fmt.Fscanf(reader, "%s", &s)
	b, width := make([]bool, len(s)), 0
	for i := 0; i < len(s); i++ {
		if s[i] == ascA || s[i] == ascB {
			b[width], width = s[i] == ascA, width+1
		}
	}

	aGroup := []int{}
	for i := 0; i < width; i++ {
		count := 0
		for (i < width) && b[i] {
			count, i = count+1, i+1
		}
		if count > 0 {
			aGroup = append(aGroup, count)
		}
	}

	if len(aGroup) == 0 {
		fmt.Println(0)
		os.Exit(0)
	}

	sum := i64(aGroup[0])
	for i := 1; i < len(aGroup); i++ {
		sum = (sum + i64(aGroup[i]) + sum*i64(aGroup[i])) % modulo
	}
	fmt.Println(sum)
}

// 1. Only care about a and b
// 2. Can generate the disjoint group, start calc from the last group(which can get the "answer" for itself).
package main

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

type i64 int64

var (
	ascA   = "a"[0]
	ascB   = "b"[0]
	modulo = i64(1e9) + 7
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	s := scanner.Text()
	b, width := make([]bool, len(s)), 0
	for i := 0; i < len(s); i++ {
		if s[i] == ascA || s[i] == ascB {
			b[width], width = s[i] == ascA, width+1
		}
	}

	aGroup := []i64{}
	for i := 0; i < width; i++ {
		count := 0
		for (i < width) && b[i] {
			count, i = count+1, i+1
		}
		if count > 0 {
			aGroup = append(aGroup, i64(count))
		}
	}

	if len(aGroup) == 0 {
		fmt.Println(0)
		os.Exit(0)
	}

	pointer := len(aGroup) - 1
	prev := map[int]i64{1: aGroup[pointer], 0: 1}

	for pointer > 0 {
		maxSeqLen := len(prev) + 1
		pointer--
		oldPrev := prev[0]
		for i := 1; i <= maxSeqLen; i++ {
			prev[i], oldPrev = (aGroup[pointer]*oldPrev+prev[i])%modulo, prev[i]
		}
	}

	sum := i64(0)
	for _, v := range prev {
		sum = (sum + v) % modulo
	}

	fmt.Println(sum - 1)
}


package main

import (
	"fmt"
)

func main() {
	var request, requestA, requestB int
	fmt.Scan(&request)

	servers := make(map[int]int)
	for i:=0; i<request; i++ {
		var requestName, requestSuccess, requestFail int
		fmt.Scan(&requestName, &requestSuccess, &requestFail)

		if requestName == 1 {
			requestA += requestSuccess
		} else {
			requestB += requestSuccess
		}

		servers[requestName] ++
	}

	if servers[1] * 5 <= requestA {
		fmt.Println("LIVE")
	} else {
		fmt.Println("DEAD")
	}

	if servers[2] * 5 <= requestB {
		fmt.Println("LIVE")
	} else {
		fmt.Println("DEAD")
	}

}

// A. System Administrator
/*
Polycarpus is a system administrator. There are two servers under his strict guidance — a and b. To stay informed about the servers' performance, Polycarpus executes commands "ping a" and "ping b". Each ping command sends exactly ten packets to the server specified in the argument of the command. Executing a program results in two integers x and y (x + y = 10; x, y ≥ 0). These numbers mean that x packets successfully reached the corresponding server through the network and y packets were lost.

Today Polycarpus has performed overall n ping commands during his workday. Now for each server Polycarpus wants to know whether the server is "alive" or not. Polycarpus thinks that the server is "alive", if at least half of the packets that we send to this server reached it successfully along the network.

Help Polycarpus, determine for each server, whether it is "alive" or not by the given commands and their results.

Input
The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of commands Polycarpus has fulfilled. Each of the following n lines contains three integers — the description of the commands. The i-th of these lines contains three space-separated integers t i, x i, y i (1 ≤ t i ≤ 2; x i, y i ≥ 0; x i + y i = 10). If t i = 1, then the i-th command is "ping a", otherwise the i-th command is "ping b". Numbers x i, y i represent the result of executing this command, that is, x i packets reached the corresponding server successfully and y i packets were lost.

It is guaranteed that the input has at least one "ping a" command and at least one "ping b" command.

Output
In the first line print string "LIVE" (without the quotes) if server a is "alive", otherwise print "DEAD" (without the quotes).

In the second line print the state of server b in the similar format.

Examples
Input
2
1 5 5
2 6 4

Output
LIVE
LIVE

Input
3
1 0 10
2 0 10
1 10 0

Output
LIVE
DEAD

Note
Consider the first test case. There 10 packets were sent to server a, 5 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall there were 10 packets sent to server b, 6 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network.

Consider the second test case. There were overall 20 packages sent to server a, 10 of them reached it. Therefore, at least half of all packets sent to this server successfully reached it through the network. Overall 10 packets were sent to server b, 0 of them reached it. Therefore, less than half of all packets sent to this server successfully reached it through the network.
*/
package main

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

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

	x1, y1, x2, y2 := 0, 0, 0, 0
	for ; n > 0; n-- {
		input2, _ := reader.ReadString('\n')
		arr := strings.Split(strings.TrimSpace(input2), " ")

		t, _ := strconv.Atoi(arr[0])
		a, _ := strconv.Atoi(arr[1])
		b, _ := strconv.Atoi(arr[2])

		if t == 1 {
			x1 += a
			y1 += b
		} else {
			x2 += a
			y2 += b
		}
	}

	if x1 >= y1 {
		fmt.Println("LIVE")
	} else {
		fmt.Println("DEAD")
	}
	if x2 >= y2 {
		fmt.Println("LIVE")
	} else {
		fmt.Println("DEAD")
	}
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scanf("%d\n", &n)
	aPass := 0
	aOk := 0
	bPass := 0
	bOk := 0
	for i := 0; i < n; i++ {
		var a, b, c int
		fmt.Scanf("%d %d %d\n", &a, &b, &c)
		if a == 1 {
			aPass += 5
			aOk += b
		} else {
			bPass += 5
			bOk += b
		}
	}
	if aOk >= aPass {
		fmt.Println("LIVE")
	} else {
		fmt.Println("DEAD")
	}
	if bOk >= bPass {
		fmt.Println("LIVE")
	} else {
		fmt.Println("DEAD")
	}
}

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

func main() {
	var n,k,i int
	fmt.Scan(&n)
	x:=make([]int,5)
	y:=make([]int,5)
	for i=1;i<=n;i++ {
		fmt.Scan(&k,&x[0],&y[0])
		x[k]+=x[0]
		y[k]+=y[0]
	}
	for i=1;i<=2;i++ {
		if x[i]>=y[i] {
			fmt.Println("LIVE")
		} else {
			fmt.Println("DEAD")
		}
	}

}

package main

import (
	"fmt"
)

func main() {

	var (
		i, n, t, x, y int32
		dat           [2][2]int32
	)

	fmt.Scan(&n)
	for i = 0; i < n; i++ {
		fmt.Scan(&t)
		fmt.Scan(&x)
		fmt.Scan(&y)
		dat[t-1][0] += x
		dat[t-1][1] += (x + y)

	}

	if 2*dat[0][0] >= dat[0][1] {
		fmt.Println("LIVE")
	} else {
		fmt.Println("DEAD")

	}

	if 2*dat[1][0] >= dat[1][1] {
		fmt.Println("LIVE")
	} else {
		fmt.Println("DEAD")

	}

}

package main

import "fmt"

func main() {
    var n,t,x,y int
    var cntx,cnty [2]int
    fmt.Scan(&n)
    for i := 0; i < n; i++ {
        fmt.Scan(&t,&x,&y)
        cntx[t-1] += x
        cnty[t-1] += y
    }
    for i := 0; i < 2; i++ {
        if cntx[i] >= (cntx[i]+cnty[i])/2 {
            fmt.Println("LIVE")
        } else {
            fmt.Println("DEAD")
        }
    }
}

package main
import "fmt"
func main() {
	var n, t, a, b int
	fmt.Scan(&n)
	x,y := 0,0
	for i:=0; i<n; i++ {
		fmt.Scan(&t, &a, &b)
		if t==1 {
			x += a-b
		} else {
			y += a-b
		}
	}
	if x>=0 {
		fmt.Println("LIVE")
	} else {
		fmt.Println("DEAD")
	}
	if y>=0 {
		fmt.Println("LIVE")
	} else {
		fmt.Println("DEAD")
	}
}

package main
import "fmt"
func main() {
	var n, t, a, b int
	fmt.Scan(&n)
	v := []int{0,0,0}
	for i:=0; i<n; i++ {
		fmt.Scan(&t, &a, &b)
		v[t] += a-b
	}
	for i:=1; i < 3; i++ {
		if v[i]>=0 {
			fmt.Println("LIVE")
		} else {
			fmt.Println("DEAD")
		}
	}
}

// 245A-mic
package main

import (
    "fmt"
)

func main() {
    var n, pinga, pingb, t, prece, plost, a, b int
    fmt.Scan(&n)
    for i := 0; i < n; i++ {
        fmt.Scan(&t, &prece, &plost)
        if t == 1 {
            pinga += prece
            a++
        } else {
            pingb += prece
            b++
        }
    }
    if pinga >= (a*10)/2 {
        fmt.Println("LIVE")
    } else {
        fmt.Println("DEAD")
    }
    if pingb >= (b*10)/2 {
        fmt.Println("LIVE")
    } else {
        fmt.Println("DEAD")
    }
}

package main

import (
	"fmt"
)

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

	servers := make(map[int]int)
	for i:=0; i<request; i++ {
		var requestName, requestSuccess, requestFail int
		fmt.Scan(&requestName, &requestSuccess, &requestFail)

		if requestSuccess >= 5 {
			servers[requestName] ++
		}
	}

	for i := 1; i <= 2; i++ {
		if servers[i] > 0 {
			fmt.Println("LIVE")
		} else {
			fmt.Println("DEAD")
		}
	}
}


package main

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

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

func (in *CF15884A) 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 *CF15884A) load() {
	if len(in.split) <= in.index {
		in.split = strings.Split(in.GetLine(), in.separator)
		in.index = 0
	}
}

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

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

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

/**
Run solve the problem CF15884A
Date: 8/11/22
User: pepradere
URL: https://codeforces.com/problemset/problem/1584/A
Problem: CF15884A
**/
func (in *CF15884A) Run() {
	for t := in.NextInt(); t > 0; t-- {
		u, v := in.NextInt64(), in.NextInt64()
		fmt.Println(-(u * u), v*v)
	}
}

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

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

package main

import "fmt"

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

	for i := 1; i <= t; i++ {
		var u, v int64
		fmt.Scanln(&u, &v)
		fmt.Println(u*u, -v*v)
	}
}

package main

import "fmt"

func main() {
  var t int
  fmt.Scanf("%d\n", &t)
  for ; t > 0; t-- {
    var u, v int64
    fmt.Scanf("%d %d\n", &u, &v)
    x := -u*u;
    y := v*v;
    fmt.Printf("%d %d\n", x, y)
  }
}

package main

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

var (
	input = bufio.NewReader(os.Stdin)
	output = bufio.NewWriter(os.Stdout)
)

func assert(test bool) {
    if !test {panic("assert!")}
}

func main() {
    defer output.Flush()
    //solve()
    //return
	var t int64
	fmt.Fscanln(input, &t)
    for t > 0 {
        t--
        solve()
    }
}

func solve() {
    var u,v int64
    fmt.Fscanln(input, &u, &v)

    // xv(u + v) + yu(u + v) = xuv + yuv
    // xvu + xv^2 + yu^2 + yuv = xuv + yuv
    // xv^2 + yu^2 = 0
    // lcm(v^2, u^2) - it's wrong because integer overflow
    // unstead answer is
    fmt.Fprintln(output, u*u, -v*v)
    //assert((u + v) * (x * v  + y * u) == x * u * v + y * u * v)
}

package main

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

/*

 */

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

	bld := strings.Builder{}

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

	for ; t > 0; t-- {
		var u, v int64
		scanf("%d %d\n", &u, &v)

		x := u * u

		y := -v * v

		fmt.Fprintf(&bld, "%d %d\n", x, y)
	}

	printf("%s", bld.String())
}

const maxUint = ^uint(0)

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

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

//goland:noinspection GoUnusedType
type pair struct {
	fst int
	snd int
}

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

//goland:noinspection GoUnusedFunction
func printf(f string, a ...interface{}) {
	if _, err := fmt.Fprintf(writer, f, a...); err != nil {
		panic(err)
	}
}

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

//goland:noinspection GoUnusedFunction
func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

//goland:noinspection GoUnusedFunction
func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

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

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

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

	for i := 5; i*i <= n; i += 6 {
		if n%i == 0 || n%(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)
}

//goland:noinspection GoUnusedFunction
func digitAt(num, pos int64) int64 {
	rem := num % int64(math.Pow(10, float64(pos)))
	return rem / int64(math.Pow(10, float64(pos-1)))
}

package main

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

func main() {
	reader := bReader(os.Stdin)
	writer := bWriter(os.Stdout)

	t := readInt(reader)

	for t > 0 {
		u, v := readTwoInt64(reader)
		fmt.Fprintln(writer, -u*u, v*v)

		t--
	}

	writer.Flush()
}

func bReader(stdin *os.File) *bufio.Reader {
	return bufio.NewReaderSize(stdin, 16*1024*1024)
}

func bWriter(stdout *os.File) *bufio.Writer {
	return bufio.NewWriterSize(stdout, 16*1024*1024)
}

func readLine(reader *bufio.Reader) string {
	str, _, err := reader.ReadLine()
	if err == io.EOF {
		return ""
	}

	return strings.TrimRight(string(str), "\r\n")
}

func checkError(err error) {
	if err != nil {
		panic(err)
	}
}

func readInt(reader *bufio.Reader) int {
	return int(readInt64(reader))
}

func readInt64(reader *bufio.Reader) int64 {
	value, err := strconv.ParseInt(readLine(reader), 10, 64)
	checkError(err)

	return value
}

func readString(reader *bufio.Reader) string {
	return readLine(reader)
}

func readArrayString(reader *bufio.Reader) []string {
	return strings.Split(strings.TrimSpace(readLine(reader)), " ")
}

func readArrayInt(reader *bufio.Reader) []int {
	arTemp := strings.Split(strings.TrimSpace(readLine(reader)), " ")
	n := len(arTemp)

	var ar []int

	for i := 0; i < n; i++ {
		arItemTemp, err := strconv.ParseInt(arTemp[i], 10, 64)
		checkError(err)
		arItem := int(arItemTemp)
		ar = append(ar, arItem)
	}

	return ar
}

func readArrayInt64(reader *bufio.Reader) []int64 {
	arTemp := strings.Split(strings.TrimSpace(readLine(reader)), " ")
	n := len(arTemp)

	var ar []int64

	for i := 0; i < n; i++ {
		arItemTemp, err := strconv.ParseInt(arTemp[i], 10, 64)
		checkError(err)
		arItem := arItemTemp
		ar = append(ar, arItem)
	}

	return ar
}

func readTwoInt(reader *bufio.Reader) (int, int) {
	ar := readArrayInt(reader)
	return ar[0], ar[1]
}

func readTwoInt64(reader *bufio.Reader) (int64, int64) {
	ar := readArrayInt64(reader)
	return ar[0], ar[1]
}

func readThreeInt(reader *bufio.Reader) (int, int, int) {
	ar := readArrayInt(reader)
	return ar[0], ar[1], ar[2]
}

func readThreeInt64(reader *bufio.Reader) (int64, int64, int64) {
	ar := readArrayInt64(reader)
	return ar[0], ar[1], ar[2]
}

package main

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

func solve() {
	f := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	N := 0
	fmt.Fscan(f, &N)
	for i := 0; i < N; i++ {
		u, v := int64(0), int64(0)
		fmt.Fscan(f, &u, &v)
		fmt.Fprintln(w, -(u * u), (v * v))
	}
	w.Flush()
}

func main() {
	solve()
}

package main

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

var (
	reader  = bufio.NewReader(os.Stdin)
	t, u, v int
)

func solve(u, v int) string {
	var (
		x = int64(u) * int64(u)
		y = -int64(v) * int64(v)
	)
	return fmt.Sprint(x, y)
}

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

package main

import "fmt"

func main() {
  var t int
  fmt.Scanf("%d", &t)
  for ; t > 0; t-- {
    var u, v int64
    fmt.Scanf("%d %d\n", &u, &v)
    x := -u*u;
    y := v*v;
    fmt.Printf("%d %d\n", x, y)
  }
}

package main

import "fmt"

func main() {
  var t int
  fmt.Scanf("%d", &t)
  for ; t > 0; t-- {
    var u, v int64
    fmt.Scanf("%d %d", &u, &v)
    x := -u*u;
    y := v*v;
    fmt.Printf("%d %d\n", x, y)
  }
}

package main

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

var (
	input = bufio.NewReader(os.Stdin)
	output = bufio.NewWriter(os.Stdout)
)

func assert(test bool) {
    if !test {panic("assert!")}
}

func main() {
    defer output.Flush()
    //solve()
    //return
	var t int64
	fmt.Fscanln(input, &t)
    for t > 0 {
        t--
        solve()
    }
}

func solve() {
    var u,v int64
    fmt.Fscanln(input, &u, &v)

    // xv(u + v) + yu(u + v) = xuv + yuv
    // xvu + xv^2 + yu^2 + yuv = xuv + yuv
    // xv^2 + yu^2 = 0
    // lcm(v^2, u^2)
    lc := lcm(v*v, u*u)
    x, y := lc / (v * v), -lc / (u * u)
    fmt.Fprintln(output, x, y)
 //   assert((u + v) * (x * v  + y * u) == x * u * v + y * u * v)
}

func lcm(a, b int64) int64 {
    return a*b / gcd(a, b)
}
func gcd(a, b int64) int64 {
    if b == 0 { return a }
    return gcd(b, a % b)
}

package main

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

/*

 */

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

	bld := strings.Builder{}

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

	for ; t > 0; t-- {
		var u, v int64
		scanf("%d %d\n", &u, &v)

		x := u * u

		y := -x * v * v / (u * u)

		fmt.Fprintf(&bld, "%d %d\n", x, y)
	}

	printf("%s", bld.String())
}

const maxUint = ^uint(0)

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

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

//goland:noinspection GoUnusedType
type pair struct {
	fst int
	snd int
}

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

//goland:noinspection GoUnusedFunction
func printf(f string, a ...interface{}) {
	if _, err := fmt.Fprintf(writer, f, a...); err != nil {
		panic(err)
	}
}

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

//goland:noinspection GoUnusedFunction
func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

//goland:noinspection GoUnusedFunction
func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

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

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

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

	for i := 5; i*i <= n; i += 6 {
		if n%i == 0 || n%(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)
}

//goland:noinspection GoUnusedFunction
func digitAt(num, pos int64) int64 {
	rem := num % int64(math.Pow(10, float64(pos)))
	return rem / int64(math.Pow(10, float64(pos-1)))
}


package main

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

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

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, c int
		fmt.Fscan(in, &n, &c)

		aa := make([]int, 101)
		for i := 0; i < n; i++ {
			var v int
			fmt.Fscan(in, &v)

			aa[v]++
		}

		var tot int64
		for _, v := range aa {
			if v > 0 {
				tot += min(int64(v), int64(c))
			}
		}

		fmt.Fprintln(out, tot)
	}
}

package main

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

func main() {
	var t, n, c, buffer, counter, sum int
	var mass []int
	fmt.Fscan(os.Stdin, &t)
	for i := 0; i < t; i++ {
		sum = 0
		fmt.Fscan(os.Stdin, &n)
		fmt.Fscan(os.Stdin, &c)
		for j := 0; j < n; j++ {
			fmt.Fscan(os.Stdin, &buffer)
			mass = append(mass, buffer)
		}
		sort.Ints(mass)
		counter = 1
		for j := 0; j < n-1; j++ {
			if mass[j] != mass[j+1] {
				if counter > c {
					sum = sum + c
				} else {
					sum = sum + counter
				}
				counter = 1
			} else {
				counter++
			}
		}
		if counter > c {
			sum = sum + c
		} else {
			sum = sum + counter
		}
		//fmt.Println(mass)
		fmt.Println(sum)
		sum = 0
		mass = nil
	}
}

package main
// github.com/jamesgrimard/codeforces
import(
    "fmt"
    "bufio"
    "os"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var n,c int
		fmt.Fscan(in,&n,&c)
		list:= make([]int,n)
		for j:=0;j<n;j++{
			fmt.Fscan(in,&list[j])
		}
		mapper:= make(map[int]int)
		for j:=0;j<n;j++{
			mapper[list[j]]++
		}
		var sum int
		for _,value := range mapper {
			if value < c {
				sum+=value
			} else {
				sum+=c
			}
		}
		fmt.Fprintln(out,sum)
	}
}

package main

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

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

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func solve(n, c int, a []int) int {
	o := make([]int, 101)
	for _, x := range a {
		o[x]++
	}
	r := 0
	for _, k := range o {
		r += min(c, k)
	}
	return r
}

func main() {
	fmt.Fscan(reader, &t)
	for ; t > 0; t-- {
		fmt.Fscan(reader, &n, &c)
		a := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(reader, &a[i])
		}
		fmt.Println(solve(n, c, a))
	}
}

package main

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

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

func (in *CF1730A) 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 *CF1730A) load() {
	if len(in.split) <= in.index {
		in.split = strings.Split(in.GetLine(), in.separator)
		in.index = 0
	}
}

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

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

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

/**
Run solve the problem CF1730A
Date: 1/10/22
User: pepradere
URL: https://codeforces.com/problemset/problem/1730/A
Problem: CF1730A
**/
func (in *CF1730A) Run() {
	for t := in.NextInt(); t > 0; t-- {
		n, c := in.NextInt(), in.NextInt()
		arr := make([]int, 101)
		for i := 0; i < n; i++ {
			arr[in.NextInt()]++
		}
		cost := 0
		for i := 0; i < len(arr); i++ {
			if arr[i] > 0 {
				if arr[i] > c {
					cost += c
				} else {
					cost += arr[i]
				}
			}
		}
		fmt.Println(cost)

	}
}

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

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

package main

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

func main() {
	var T, n, c, temp, cost int

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

	for fmt.Fscan(r, &T); T > 0; T-- {
		fmt.Fscan(r, &n, &c)
		a := make([]int, 101)
		for i := 0; i < n; i++ {
			fmt.Fscan(r, &temp)
			a[temp]++
		}

		cost = 0
		for i := 0; i < 101; i++ {
			if a[i] < c {
				cost += a[i]
			} else {
				cost += c
			}
		}

		fmt.Fprintln(w, cost)
	}
}

package main

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

func main() {
	defer writer.Flush()
	var t int
	scanws(&t)
	for t > 0 {
		solve()
		t--
	}
}

func solve() {
	var n, c, v, tot int
	fMap := make(map[int]int)
	scanws(&n, &c)
	for n > 0 {
		scanws(&v)
		fMap[v]++
		n--
	}
	for _, freq := range fMap {
		tot += MinInt(freq, c)
	}
	printf("%d\n", tot)
}

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

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 scanws(a ...interface{}) { fmt.Fscan(reader, a...) }

package main

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

func main() {

	var t int

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

	fmt.Fscan(in, &t)

	for tt := 0; tt < t; tt++ {
		var n, c int
		fmt.Fscan(in, &n)
		fmt.Fscan(in, &c)

		fff := make(map[int]int)

		for j := 0; j < n; j++ {
			var temp int
			fmt.Fscan(in, &temp)

			fff[temp]++
		}

		o := solve(&fff, c)
		fmt.Fprintln(out, o)
	}
}

func solve(ff *map[int]int, c int) int {

	tc := 0

	for _, t1 := range *ff {
		if t1 > c {
			tc += c
		} else {
			tc += t1
		}
	}
	return tc
}

package main

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

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

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

	var T int
	var n int
	var c int
	var x int

	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n)
		Fscan(in, &c)
		r := make([]int, 101)
		for i := 0; i < n; i++ {
			Fscan(in, &x)
			r[x]++
		}
		ans :=0
		for _, v := range r {
			if v < c {
				ans += v
			} else {
				ans += c
			}
		}

		Fprintln(out, ans)
	}
}

package main

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

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

func main() {
	defer out.Flush()
	var t int
	fmt.Fscan(in, &t)
	for ; t > 0; t-- {
		var n, c, num int
		fmt.Fscan(in, &n, &c)
		mmid := make(map[int]int)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &num)
			if val, ok := mmid[num]; ok {
				mmid[num] = val + 1
			} else {
				mmid[num] = 1
			}
		}
		res := 0
		for _, val := range mmid {
			if val >= c {
				res += c
			} else {
				res += val
			}
		}
		fmt.Fprintln(out, res)
	}
}

package main

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

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

func scan(a ...interface{}) {
	fmt.Fscan(in, a...)
}
func printf(f string, a ...interface{}) {
	fmt.Fprintf(out, f, a...)
}

func solve() {
	var n, c int
	scan(&n, &c)
	a := make([]int, n)
	f := make([]int, 101)
	for i := 0; i < n; i++ {
		scan(&a[i])
		f[a[i]]++
	}
	result := 0
	for i := 0; i <= 100; i++ {
		if f[i] > 0 {
			cost := f[i]
			if cost > c {
				cost = c
			}
			result += cost
		}
	}
	printf("%d\n", result)
}
func main() {
	defer out.Flush()
	n := 0
	scan(&n)
	for i := 0; i < n; i++ {
		solve()
	}
}

package main

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

const cf = true

func solve() {
	var n, c, num int
	fmt.Fscan(in, &n, &c)
	cnt := make([]int, 101)
	for i := 0; i < n; i++ {
		fmt.Fscan(in, &num)
		cnt[num]++
	}
	ans := 0
	for _, item := range cnt {
		ans += min(item, c)
	}
	fmt.Fprintln(out, ans)
}

func main() {
	defer out.Flush()
	t := 1
	fmt.Fscan(in, &t)
	for ; t > 0; t-- {
		solve()
	}
}

func ConvertInt(val string, base, toBase int) (string, error) {
	i, err := strconv.ParseInt(val, base, 64)
	if err != nil {
		return "", err
	}
	return strconv.FormatInt(i, toBase), nil
}

type set[T Ordered] struct {
	itms map[T]struct{}
}

func (s *set[T]) init() {
	if s.itms == nil {
		s.itms = make(map[T]struct{})
	}
}

func (s *set[T]) add(item T) *set[T] {
	s.init()
	s.itms[item] = exists
	return s
}

func (s *set[T]) remove(item T) *set[T] {
	s.init()
	delete(s.itms, item)
	return s
}

func (s *set[T]) has(item T) bool {
	s.init()
	_, c := s.itms[item]
	return c
}

func (s *set[T]) sortedItems() []T {
	s.init()
	items := make([]T, 0, s.size())
	for item := range s.itms {
		items = append(items, item)
	}
	sort.Slice(items, func(i, j int) bool {
		return items[i] < items[j]
	})
	return items
}

func (s *set[T]) items() []T {
	s.init()
	items := make([]T, 0, s.size())
	for item := range s.itms {
		items = append(items, item)
	}
	return items
}

func (s *set[T]) size() int {
	s.init()
	return len(s.itms)
}

var exists = struct{}{}

const MaxUint = ^uint(0)
const MinUint = 0
const MaxInt = int(MaxUint >> 1)
const MinInt = -MaxInt - 1

func reverseStr(s string) string {
	r := []rune(s)
	for i, j := 0, len(r)-1; i < len(r)/2; i, j = i+1, j-1 {
		r[i], r[j] = r[j], r[i]
	}
	return string(r)
}

type Float interface {
	~float32 | ~float64
}

type Integer interface {
	Signed | Unsigned
}

type Signed interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64
}

type Unsigned interface {
	~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr
}

type Ordered interface {
	Integer | Float | ~string
}

func abs[T Signed](x T) T {
	if x < 0 {
		return -x
	}
	return x
}

func min[T Ordered](x, y T) T {
	if x < y {
		return x
	}
	return y
}

func max[T Ordered](x, y T) T {
	if x > y {
		return x
	}
	return y
}

var (
	in  = getReader()
	out = getWriter()
)

func getReader() *bufio.Reader {
	if cf {
		return bufio.NewReader(os.Stdin)
	} else {
		in, _ := os.Open("input.txt")
		return bufio.NewReader(in)
	}
}

func getWriter() *bufio.Writer {
	if cf {
		return bufio.NewWriter(os.Stdout)
	} else {
		out, _ := os.Create("output.txt")
		return bufio.NewWriter(out)
	}
}

package main

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

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

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, c int
		fmt.Fscan(in, &n, &c)

		aa := make([]int, 101)
		for i := 0; i < n; i++ {
			var v int
			fmt.Fscan(in, &v)

			aa[v]++
		}

		var tot int64
		for _, v := range aa {
			if v == 1 {
				tot++
			} else if v > 1 {
				tot += int64(c)
			}
		}

		fmt.Fprintln(out, min(int64(n), tot))
	}
}

package main

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

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

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, c int
		fmt.Fscan(in, &n, &c)

		aa := make([]int, 101)
		for i := 0; i < n; i++ {
			var v int
			fmt.Fscan(in, &v)

			aa[v]++
		}

		var tot int
		for _, v := range aa {
			if v == 1 {
				tot++
			} else if v > 1 {
				tot += c
			}
		}

		fmt.Fprintln(out, min(n, tot))
	}
}

package main

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

func main() {
	var t, n, c, buffer, counter, sum int
	var mass []int
	fmt.Fscan(os.Stdin, &t)
	for i := 0; i < t; i++ {
		sum = 0
		fmt.Fscan(os.Stdin, &n)
		fmt.Fscan(os.Stdin, &c)
		for j := 0; j < n; j++ {
			fmt.Fscan(os.Stdin, &buffer)
			mass = append(mass, buffer)
		}
		sort.Ints(mass)
		counter = 1
		for j := 0; j < n-1; j++ {
			if mass[j] != mass[j+1] {
				if counter > c {
					sum = sum + c
				} else {
					sum = sum + counter
				}
				counter = 1
			} else {
				counter++
			}
		}
		if counter > c {
			sum = sum + c
		} else {
			sum = sum + counter
		}
		fmt.Println(mass)
		fmt.Println(sum)
		sum = 0
		mass = nil
	}
}


package main

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

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

func debug(a ...interface{}) {
	for _, e := range a {
		printf("%v ", e)
	}
	printf("\n")
	writer.Flush()
}

func solve() {
	var n int
	scanf("%d\n", &n)
	excluded := make([]bool, 10)
	for i:=0; i<n; i++ {
		var num int
		scanf("%d ", &num)
		excluded[num] = true
	}
	scanf("\n")

	var res int = 0
	for num:=0; num<10000; num++ {
		isIncluded := true
		curNum := num

		count := make([]int, 10)
		for i:=0; i<4; i++ {
			count[curNum%10]++
			curNum /= 10
		}

		for number:=0; number<10; number++ {
			if count[number] == 0 {
				continue
			}
			if count[number] != 2 || excluded[number] {
				isIncluded = false
				break
			}
		}
		if isIncluded {
			res++
		}
	}

	printf("%d\n", res)
}

func main() {
	defer writer.Flush()

	var T int
	scanf("%d\n", &T)
	for tt:=1; tt<=T; tt++ {
		solve()
	}
}

package main

import "fmt"

func main() {
	var t int
	fmt.Scan(&t)
	for o := 0; o < t; o++ {
		var n int
		fmt.Scan(&n)

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

		res := 0
		for i := 0; i <= 9; i++ {
			for j := i + 1; j <= 9; j++ {
				flag := true
				for k := 0; k < n; k++ {
					if i == arr[k] || j == arr[k] {
						flag = false
						break
					}
				}
				if flag {
					res += 2 * 3
				}
			}
		}

		fmt.Println(res)
	}
}

package main

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

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

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

	var T int
	var n int
	var x int

	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n)

		a := make([]int, n)
		for i := 0; i < n; i++ {
			Fscan(in, &x)
			a[i] = x
		}

		ans := (10 - n) * (10 - n - 1) / 2 * 6

		Fprintln(out, ans)
	}
}

package main

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

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

	res := make([]int, 11)
	for i := range res {
		res[i] = 3*i*(i-1)
	}

	var T int
	for fmt.Fscan(r, &T); T > 0; T-- {

		var n, temp int
		fmt.Fscan(r, &n)

		for i := 0; i < n; i++ { fmt.Fscan(r, &temp) }
		fmt.Fprintln(w, res[10-n])
	}

}

package main
import(
    "fmt"
    "bufio"
    "os"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var n int
		fmt.Fscan(in,&n)
		for j:=0;j<n;j++{
			var x int
			fmt.Fscan(in,&x)
		}
		fmt.Fprintln(out,Cumsum(10-n-1)*6)
	}
}
func Cumsum(x int) int {
	sum:=0
	for j:=1;j<=x;j++{
		sum+=j
	}
	return sum
}

package main

import (
	"fmt"
)

func processSet() {
	nValues := 0
	dummy := 0
	fmt.Scan(&nValues)
	n := 10 - nValues - 1
	for nValues > 0 {
		fmt.Scan(&dummy)
		nValues--
	}

	fmt.Println((n + n*n) / 2 * 6)
}

func main() {

	var nSets = 0
	fmt.Scan(&nSets)
	for nSets > 0 {
		processSet()

		nSets--
	}

}

package main

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

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

func (in *CF1743A) 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 *CF1743A) load() {
	if len(in.split) <= in.index {
		in.split = strings.Split(in.GetLine(), in.separator)
		in.index = 0
	}
}

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

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

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

/**
Run solve the problem CF1743A
Date: 10/18/2022
User: wotan
URL: https://codeforces.com/problemset/problem/1743/A
Problem: CF1743A
**/
func (in *CF1743A) Run() {

	for t := in.NextInt(); t > 0; t-- {
		n := in.NextInt()
		for i := 0; i < n; i++ {
			in.NextInt()
		}

		sol := fib(10-n-1) * 6
		fmt.Println(sol)

	}

}

func fib(n int) int {
	if n <= 1 {
		return 1
	}
	return n + fib(n-1)
}

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

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

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 n int
		fmt.Fscan(in, &n)
		aa := make([]int, n)
		for i := range aa {
			fmt.Fscan(in, &aa[i])
		}

		d := 10 - n - 1
		fmt.Fprintln(out, 6*d*(d+1)/2)
	}
}

package main

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

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

func solve() {
    var n, x int
    Fscan(in, &n)
    for i := 0; i < n; i++ {
        Fscan(in, &x)
    }

    n = 10 - n;
    Fprintln(out, n * (n - 1) *3);
}

func main() {
    var T int
    Fscan(in, &T)
    for ; T > 0; T-- {
        solve()
    }
    out.Flush()
}

package main

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

var reader = bufio.NewReader(os.Stdin)

const N = 52

var n, m int
var (
	a, g, q [N]int
)

func main() {
	var t int

	fmt.Fscan(reader, &t)

	for t > 0 {
		t--
		fmt.Fscan(reader, &n)
		a := make([]int, n)
		invalid := make(map[int]int, 0)
		for i := 0; i < n; i++ {
			fmt.Fscan(reader, &a[i])
			invalid[a[i]] = 2
		}
		ans := 0
		var dfs func(u int)
		used := map[int]int{}
		dfs = func(u int) {
			if u == 3 {
				if len(used) == 2 {
					ans++
				}
				return
			}
			for i := 0; i <= 9; i++ {
				if invalid[i] == 0 {
					used[i]++
					dfs(u + 1)
					used[i]--
					if used[i] == 0 {
						delete(used, i)
					}
				}
			}
		}
		dfs(0)
		fmt.Println(ans)
	}
}

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

/*
	A template for Go on codeforces.com
	Author: Yakov, frvr.ru
*/

package main

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

func main() {
	t := readInt()
	for j := 0; j < t; j++ {
		n := readInt()
		var arr []int
		arr1 := make([]int, 10)
		arr = readInts()
		for i := 0; i < n; i++ {
			arr1[arr[i]] = 1
		}
		//fmt.Printf("arr1====>%v\n", arr1)
		cnt := 0
		for i := 0; i < 10; i++ {
			for j := i + 1; j < 10; j++ {
				if arr1[i] == 1 || arr1[j] == 1 {
					continue
				}
				cnt += 6
			}
		}
		writeLine(cnt)
	}
}

/* ~~~~~~~~~~ */
/* ~~~~~~~~~~ */
/* ~~~~~~~~~~ */

var in = bufio.NewReader(os.Stdin)

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

func typeOf(arg interface{}) string {
	switch reflect.TypeOf(arg).Kind() {
	case reflect.Int:
		return "int"
	case reflect.Int8:
		return "int8"
	case reflect.Int16:
		return "int16"
	case reflect.Int32:
		return "int32"
	case reflect.Int64:
		return "int64"
	case reflect.Uint:
		return "uint"
	case reflect.Uint8:
		return "uint8"
	case reflect.Uint16:
		return "uint16"
	case reflect.Uint32:
		return "uint32"
	case reflect.Uint64:
		return "uint64"
	case reflect.Float32:
		return "float32"
	case reflect.Float64:
		return "float64"
	case reflect.Complex64:
		return "complex64"
	case reflect.Complex128:
		return "complex128"
	case reflect.Bool:
		return "bool"
	case reflect.String:
		return "string"
	case reflect.Chan:
		return "chan"
	case reflect.Ptr:
		return "ptr"
	case reflect.Uintptr:
		return "uintptr"
	case reflect.UnsafePointer:
		return "unsafeptr"
	case reflect.Interface:
		return "interface"
	case reflect.Array:
		return "array"
	case reflect.Slice:
		return "slice"
	case reflect.Map:
		return "map"
	case reflect.Struct:
		return "struct"
	case reflect.Func:
		return "func"
	case reflect.Invalid:
		return "invalid"
	default:
		return "nil"
	}
}

/* ~~~~~~~~~~ */

func _scln() string {
	ln, _ := in.ReadString('\n')
	return strings.Trim(ln, " \r\n")
}
func _sc(s []string) string {
	if len(s) == 0 {
		return _scln()
	}
	return s[0]
}

func readLine() string              { return _scln() }
func readString() string            { return _scln() }
func readStrings() []string         { return strings.Split(_scln(), " ") }
func readBool(s ...string) bool     { t, _ := strconv.ParseBool(_sc(s)); return t }
func readByte(s ...string) byte     { t, _ := strconv.ParseUint(_sc(s), 10, 8); return byte(t) }
func readDouble(s ...string) double { t, _ := strconv.ParseFloat(_sc(s), 64); return t }
func readFloat(s ...string) float   { t, _ := strconv.ParseFloat(_sc(s), 32); return float32(t) }
func readInt(s ...string) int       { t, _ := strconv.Atoi(_sc(s)); return t }
func readLong(s ...string) long     { t, _ := strconv.ParseInt(_sc(s), 10, 64); return t }
func readULong(s ...string) ulong   { t, _ := strconv.ParseUint(_sc(s), 10, 64); return t }

/* ~~~~~~~~~~ */

// Too much overhead with universal method using interface{}, wait for the generics,
// but for now — just don't look at the redundancy of the code after that commentary :)

func readBools() []bool {
	strs := readStrings()
	arr := make([]bool, len(strs))
	for i, s := range strs {
		arr[i] = readBool(s)
	}
	return arr
}
func readBytes() []byte {
	strs := readStrings()
	arr := make([]byte, len(strs))
	for i, s := range strs {
		arr[i] = readByte(s)
	}
	return arr
}
func readDoubles() []double {
	strs := readStrings()
	arr := make([]double, len(strs))
	for i, s := range strs {
		arr[i] = readDouble(s)
	}
	return arr
}
func readFloats() []float {
	strs := readStrings()
	arr := make([]float, len(strs))
	for i, s := range strs {
		arr[i] = readFloat(s)
	}
	return arr
}
func readInts() []int {
	strs := readStrings()
	arr := make([]int, len(strs))
	for i, s := range strs {
		arr[i] = readInt(s)
	}
	return arr
}
func readLongs() []long {
	strs := readStrings()
	arr := make([]long, len(strs))
	for i, s := range strs {
		arr[i] = readLong(s)
	}
	return arr
}
func readULongs() []ulong {
	strs := readStrings()
	arr := make([]ulong, len(strs))
	for i, s := range strs {
		arr[i] = readULong(s)
	}
	return arr
}

/* ~~~~~~~~~~ */

func write(arg ...interface{})                 { fmt.Print(arg...) }
func writeLine(arg ...interface{})             { fmt.Println(arg...) }
func writeFormat(f string, arg ...interface{}) { fmt.Printf(f, arg...) }

package main

import (
	"fmt"
)

func main() {
	var num int
	fmt.Scan(&num)
	for t := 0; t < num; t++ {
		var n int
		fmt.Scan(&n)
		var numArr []int
		for i := 0; i < n; i++ {
			var num3 int
			fmt.Scan(&num3)
			numArr = append(numArr, num3)
		}
		var res int
		res = A(numArr)
		fmt.Println(res)
	}

}
func A(arr []int) int {
	var num int
	count := 1
	num = 10 - len(arr)
	count = num * (num - 1)
	count = (count / 2) * 6

	return count

}


package main

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

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

func solve() string {
	var n, m int
	fmt.Fscan(in, &n, &m)
	var words = make([]string, n)
	for i := range words {
		fmt.Fscan(in, &words[i])
	}
	var res = math.MaxInt
	var temp int
	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			temp = 0
			for k := 0; k < m; k++ {
				if words[i][k] > words[j][k] {
					temp += int(words[i][k] - words[j][k])
				} else {
					temp += int(words[j][k] - words[i][k])
				}
			}
			if temp < res {
				res = temp
			}
		}
	}

	return strconv.FormatInt(int64(res), 10)
}

func main() {
	defer out.Flush()
	var t int
	for fmt.Fscanln(in, &t); t > 0; t-- {
		fmt.Fprintln(out, solve())
	}
}

package main

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

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

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

	var T int
	var n int
	var sn int
	var x string

	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n)
		Fscan(in, &sn)

		row := make([]string, n)
		for i := 0; i < n; i++ {
			Fscan(in, &x)
			row[i] = x
		}

		ans := 1<<30
		for i, v := range row {
			for j := i + 1; j < n; j++ {
				t := 0
				vv := row[j]
				for k := 0; k < sn; k++ {
					if vv[k] >v[k] {
						t += int(vv[k]-v[k])
					} else {
						t += int(v[k]-vv[k])
					}
				}
				if t < ans {
					ans = t
				}
			}
		}

		Fprintln(out, ans)
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	var N,T,Q,sum int
	var S string

	//fmt.Fscan(in, &N)

	//num := make(map[int]int)
	//全体の個数
	fmt.Fscan(in, &N)

	for i := 0;i < N;i++{
		min := 100000000
		fmt.Fscan(in, &T,&Q)
		list := make([][]int,T)
		//文字の個数
		for j := 0;j < T;j++{
			fmt.Fscan(in, &S)
			val := make([]int,Q)
			for number,k := range S{
				val[number] = int(k)
			}
			list[j] = val
		}

		//文字列の長さ
		for k := 0;k < T-1;k++{
			for l := k+1;l < T;l++{
				for m := 0;m < Q;m++{
					a := list[k][m]-list[l][m]
					sum += int(math.Abs(float64(a)))
				}
				if min > sum {
					min = sum
				}
				sum = 0
			}
		}
		fmt.Println(min)
	}
}

package main
import(
    "fmt"
    "bufio"
    "os"
)
var letters = map[string]int{
	"a": 1,
	"b": 2,
	"c": 3,
	"d": 4,
	"e": 5,
	"f": 6,
	"g": 7,
	"h": 8,
	"i": 9,
	"j": 10,
	"k": 11,
	"l": 12,
	"m": 13,
	"n": 14,
	"o": 15,
	"p": 16,
	"q": 17,
	"r": 18,
	"s": 19,
	"t": 20,
	"u": 21,
	"v": 22,
	"w": 23,
	"x": 24,
	"y": 25,
	"z": 26,
}
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var n,m int
		fmt.Fscan(in,&n,&m)
		list:= make([]string,n)
		for j:=0;j<n;j++{
			fmt.Fscan(in,&list[j])
		}
		smallest:=999
		for j:=0;j<n-1;j++{
			for l:=j+1;l<n;l++{
				tally:=0
				for k:=0;k<m;k++{
					tally+=abs(letters[string(list[j][k])]-letters[string(list[l][k])])
				}
				if tally <= smallest {
					smallest= tally
				}
			}
		}
		fmt.Fprintln(out,smallest)
	}
}
func abs(x int) int {
	var result int
	if x > 0 {
		result = x
	} else {
		if x < 0 {
			result = x*-1
		}
	}
	return result
}

package main

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

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

func handle(a string, b string) int {
	cnt := 0
	for i := 0; i < len(a); i++ {
		cnt += int(math.Abs(float64(a[i]) - float64(b[i])))
	}
	return cnt
}

func main() {
	defer out.Flush()
	var t, n, m int
	for fmt.Fscan(in, &t); t > 0; t-- {
		fmt.Fscan(in, &n, &m)
		s := make([]string, n)
		for i := range s {
			fmt.Fscan(in, &s[i])
		}
		res := 100000
		for i := 0; i < n; i++ {
			for j := 0; j < i; j++ {
				tmp := handle(s[i], s[j])
				if tmp < res {
					res = tmp
				}
			}
		}
		fmt.Fprintln(out, res)
	}
}

package main

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

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

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

func main() {
	defer out.Flush()

	var tc int
	fmt.Fscan(in, &tc)
	for ; tc > 0; tc-- {
		var n, m int
		fmt.Fscan(in, &n, &m)
		a := make([]string, n)
		for j := 0; j < n; j++ {
			fmt.Fscan(in, &a[j])
		}
		ans := math.MaxInt32
		for i := 0; i < n; i++ {
			for j := i + 1; j < n; j++ {
				w1 := a[i]
				w2 := a[j]
				now := 0
				for k := 0; k < m; k++ {
					now += int(math.Abs(float64(int(w1[k]) - int(w2[k]))))
				}
				ans = min(ans, now)
			}
		}
		fmt.Println(ans)
	} //fim do loop de test cases
} // fim main

package main

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

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

func (in *CF1676C) 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 *CF1676C) load() {
	if len(in.split) <= in.index {
		in.split = strings.Split(in.GetLine(), in.separator)
		in.index = 0
	}
}

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

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

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

/**
Run solve the problem CF1676C
Date: 13/05/22
User: pepradere
URL: https://codeforces.com/problemset/problem/1676/C
Problem: CF1676C
**/
func (in *CF1676C) Run() {
	for t := in.NextInt(); t > 0; t-- {
		n, m := in.NextInt(), in.NextInt()
		arr := make([]string, n)
		for i := 0; i < n; i++ {
			arr[i] = in.NextString()
		}
		min := -1
		for i := 0; i < n; i++ {
			for j := 0; j < n; j++ {
				if i != j {
					diff := 0
					for p := 0; p < m; p++ {
						d := int(math.Abs(float64(arr[i][p]) - float64(arr[j][p])))
						diff += d
					}
					if min == -1 {
						min = diff
					} else if min > diff {
						min = diff
					}

				}
			}
		}
		fmt.Println(min)
	}
}

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

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

package main

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

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

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

func solve(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	var t int
	for fmt.Fscan(in, &t); t > 0; t-- {
		var n, m int
		fmt.Fscan(in, &n)
		fmt.Fscan(in, &m)
		a := make([]string, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &a[i])
		}
		ans := math.MaxInt
		for i := 0; i < n; i++ {
			for j := i + 1; j < n; j++ {
				diff := 0
				for k := 0; k < m; k++ {
					diff += Abs(int(a[i][k]) - int(a[j][k]))
				}
				if diff < ans {
					ans = diff
				}
			}
		}
		fmt.Fprintln(out, ans)
	}
}

package main

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

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

	var T int
	for fmt.Fscan(in, &T); T > 0; T-- {
		var n, m int
		fmt.Fscan(in, &n, &m)
		s := make([]string, n)
		for i := 0;i < n; i++ {
			fmt.Fscan(in, &s[i])
		}
		min := func(a, b int) int {
			if a < b {
				return a
			}
			return b
		}
		abs := func(a, b int) int {
			if a > b {
				return a - b
			}
			return b - a
		}
		var ans int = 1e9

		for i := 0;i < n; i++ {
			for j := i + 1;j < n; j++ {
				temp := 0
				for k := 0;k < m; k++ {
					temp += abs(int(s[i][k]), int(s[j][k]))
				}
				ans = min(ans, temp)
			}
		}
		fmt.Fprintln(out, ans)
	}
}

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

package main

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

func toInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	testCases, _ := strconv.Atoi(scanner.Text())

	for idx := 0; idx < testCases; idx++ {
		scanner.Scan()
		splitted := strings.Split(scanner.Text(), " ")
		words, length := toInt(splitted[0]), toInt(splitted[1])

		wds := make([]string, words)
		for idx := 0; idx < words; idx++ {
			scanner.Scan()
			wds[idx] = scanner.Text()
		}

		minimum := math.MaxInt
		for i := 0; i < words; i++ {
			for j := i + 1; j < words; j++ {
				diff := 0
				for l := 0; l < length; l++ {
					diff += abs(int(wds[i][l]) - int(wds[j][l]))
				}
				if diff < minimum {
					minimum = diff
				}
			}
		}
		fmt.Println(minimum)
	}
}

package main

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

func getValue(s string, t string, m int) int {
	cnt := 0
	for i := 0; i < m; i++ {
		cnt += int( math.Abs( float64( int(rune(s[i])-96) - int(rune(t[i])-96) ) ) )
	}
	return cnt
}

func main() {
	var (
		t int
	)

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

	for t > 0 {
		t--

		text, _ := reader.ReadString('\n')
		ninps := strings.Fields(text)
		n, _ := strconv.Atoi(ninps[0])
		m, _ := strconv.Atoi(ninps[1])

		x := make([]string, n)

		for i := 0; i < n; i++ {
			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]
			}
			x[i] = s
		}

		min := math.MaxInt32
		for i := 0; i < n-1; i++ {
			for j := i+1; j < n; j++ {
				a := getValue(x[i], x[j], m)
				if a < min {
					min = a
					//fmt.Println("M: ", (i+1), (j+1))
				}
			}
		}
		fmt.Println(min)
	}
}

package main

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

//goland:noinspection GoUnusedFunction
func min(a int, nums ...int) int {
	min := a

	for _, num := range nums {
		if num < min {
			min = num
		}
	}
	return min
}

//goland:noinspection GoUnusedFunction
func max(a int, nums ...int) int {
	max := a

	for _, num := range nums {
		if num > max {
			max = num
		}
	}
	return max
}

//goland:noinspection GoUnusedFunction
func maxFloat(a float64, nums ...float64) float64 {
	max := a

	for _, num := range nums {
		if num > max {
			max = num
		}
	}
	return max
}

//goland:noinspection GoUnusedFunction
func fprintlnArr(w io.Writer, arr []int) {
	for _, val := range arr {
		fmt.Fprint(w, val, " ")
	}
	fmt.Fprintln(w)
}

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

	var t int
	for fmt.Fscan(in, &t); t > 0; t-- {
		var n, m int
		fmt.Fscan(in, &n, &m)

		arr := make([]string, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &arr[i])
		}

		minDist := math.MaxInt

		for i := 0; i < n; i++ {
			s1 := arr[i]
			for j := i + 1; j < n; j++ {
				s2 := arr[j]
				curDist := 0
				for z := 0; z < m; z++ {
					curDist += int(math.Abs(float64(s1[z]) - float64(s2[z])))
				}
				minDist = min(minDist, curDist)
			}
		}

		fmt.Fprintln(out, minDist)
	}
}

package main

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

var r = bufio.NewReader(os.Stdin)
var w = bufio.NewWriter(os.Stdout)
func slove() {
	var n, m int
	fmt.Fscan(r, &n, &m)
	ss := make([]string, n)
	for i:=0;i<n;i++ {
		fmt.Fscan(r, &ss[i])
	}
	ans := 26*8
	for i := range ss {
		for j:=i+1;j<n;j++ {
			ans = min(ans, diff(ss[i], ss[j]))
		}
	}
	fmt.Fprintln(w, ans)
}

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

func diff(a, b string) (ans int) {
	for i := range a {
		ans += int(abs(int(a[i])-int(b[i])))
	}
	return
}

func main() {
	defer w.Flush()
	var n int
	fmt.Fscan(r, &n)
	for i:=1;i<=n;i++ {
		slove()
	}
}

package main

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

func abs(n int) int {
	if n < 0 {
		return n * -1
	}
	return n
}

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, m int
		fmt.Fscan(in, &n, &m)

		words := make([]string, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &words[i])
		}

		fn := func(s1, s2 string) int {
			var d int
			for i := range s1 {
				a := int(s1[i] - 'a')
				b := int(s2[i] - 'a')
				d += abs(a - b)
			}
			return d
		}
		min := math.MaxInt32
		for i := 0; i < n-1; i++ {
			for j := i + 1; j < n; j++ {
				if fn(words[i], words[j]) < min {
					min = fn(words[i], words[j])
				}
			}
		}
		fmt.Fprintln(out, min)
	}
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"io/ioutil"
	"os"
	"strings"
)

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

	solve := func(curCase int) {
		var n ,m int
		Fscan(in, &n,&m)
		a := make([]string, n)
		for i := range a {
			Fscan(in, &a[i])
		}
		mi := int(1e9)
		for i, v := range a {
			for _, w := range a[:i] {
				s := 0
				for k := range v {
					s+=abs(int(v[k]-'a')-int(w[k]-'a'))
				}
				mi = min(mi, s)
			}
		}
		Fprintln(out, mi)
	}

	cases := 1
	Fscan(in, &cases)
	for curCase := 1; curCase <= cases; curCase++ {
		solve(curCase)
	}

	leftData, _ := ioutil.ReadAll(in)
	if s := strings.TrimSpace(string(leftData)); s != "" {
		panic("有未读入的数据：\n" + s)
	}

}

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

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

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

package main

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

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

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

	t := 0
	fmt.Fscan(in, &t)
	for k := 0; k < t; k++ {
		n, m := 0, 0
		fmt.Fscan(in, &n, &m)
		a := make([]string, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &a[i])
		}
		ans := int(1e9)
		for i := 0; i < n; i++ {
			for j := i + 1; j < n; j++ {
				str1 := a[i]
				str2 := a[j]
				tmp := 0
				for x := 0; x < m; x++ {
					tmp += abs(int(str1[x]) - int(str2[x]))
				}
				ans = min(ans, tmp)
			}
		}
		fmt.Fprintln(out, ans)
	}
}

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

func min(i, j int) int {
	if i < j {
		return i
	}
	return j
}

package main

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

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

	n := readInt(in)
	for i := 0; i < n; i++ {
		solution(in, out)
	}
}

func solution(in *bufio.Reader, out *bufio.Writer) {
	arr := readArrInt(in)
	n := arr[0]
	words := make([]string, n)
	for i := 0; i < n; i++ {
		words[i] = readLine(in)
	}

	min := math.MaxInt
	for i := 0; i < n; i++ {
		for j := i; j < n; j++ {
			if i == j {
				continue
			}

			sum := 0
			for k := 0; k < len(words[i]); k++ {
				sum += Abs(int(words[i][k]) - int(words[j][k]))
			}

			if sum < min {
				min = sum
			}
		}
	}

	out.WriteString(strconv.Itoa(min) + "\n")

}

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

func readInt(in *bufio.Reader) int {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.Atoi(nStr)
	return n
}

func readLine(in *bufio.Reader) string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")
	return line
}

func readLineNumbs(in *bufio.Reader) []string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")
	numbs := strings.Split(line, " ")
	return numbs
}

func readArrInt(in *bufio.Reader) []int {
	numbs := readLineNumbs(in)
	arr := make([]int, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.Atoi(n)
		arr[i] = val
	}
	return arr
}

func readArrInt64(in *bufio.Reader) []int64 {
	numbs := readLineNumbs(in)
	arr := make([]int64, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.ParseInt(n, 10, 64)
		arr[i] = val
	}
	return arr
}

package main
import (
    "fmt"
    "os"
    "bufio"
)
const INF = int(1e9)
func abs(x int) int {
    if x<0 {
        x = -x
    }
    return x
}
func main() {
    r := bufio.NewReader(os.Stdin)
    w := bufio.NewWriter(os.Stdout)
    defer w.Flush()

    var t int
    fmt.Fscan(r, &t)
    for _i:=0;_i<t;_i++ {
        var n,m int
        fmt.Fscan(r, &n, &m)
        s := make([]string, n)
        for i:=0;i<n;i++ {
            fmt.Fscan(r, &s[i])
        }
        ans := INF
        for i:=0;i<n;i++ {
            for j:=0;j<i;j++ {
                res := 0
                for k:=0;k<m;k++ {
                    res += abs(int(s[i][k])-int(s[j][k]))
                }
                if ans>res {
                    ans=res
                }
            }
        }
        fmt.Fprintln(w, ans)
    }
}

package main

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

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

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

	t := 0
	fmt.Fscan(in, &t)
	for k := 0; k < t; k++ {
		n, m := 0, 0
		fmt.Fscan(in, &n, &m)
		a := make([]string, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &a[i])
		}
		ans := int(1e9)
		for i := 0; i < n; i++ {
			for j := i + 1; j < n; j++ {
				str1 := a[i]
				str2 := a[j]
				tmp := 0
				for x := 0; x < m; x++ {
					tmp += abs(int(str1[x]) - int(str2[x]))
				}
				ans = min(ans, tmp)
			}
		}
		fmt.Fprintln(out, ans)
	}
}

func abs(x int) int {
	fmt.Println("xxx", x)
	if x < 0 {
		return -x
	}
	return x
}

func min(i, j int) int {
	if i < j {
		return i
	}
	return j
}

package main

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

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

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

	t := 0
	fmt.Fscan(in, &t)
	for k := 0; k < t; k++ {
		n, m := 0, 0
		fmt.Fscan(in, &n, &m)
		a := make([]string, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &a[i])
		}
		ans := int(1e8)
		sort.Slice(a, func(i, j int) bool {
			return a[i] < a[j]
		})
		for i := 1; i < n; i++ {
			str1 := a[i-1]
			str2 := a[i]
			tmp := 0
			for j := 0; j < m; j++ {
				tmp += abs(int(str2[j] - str1[j]))
			}
			ans = min(ans, tmp)
		}
		fmt.Fprintln(out, ans)
	}
}

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

func min(i, j int) int {
	if i < j {
		return i
	}
	return j
}

package main

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

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

	n := readInt(in)
	for i := 0; i < n; i++ {
		solution(in, out)
	}
}

func solution(in *bufio.Reader, out *bufio.Writer) {
	n := readInt(in)
	readInt(in)

	words := make([]string, n)
	for i := 0; i < n; i++ {
		words[i] = readLine(in)
	}

	min := math.MaxInt
	for i := 0; i < n; i++ {
		for j := i; j < n; j++ {
			if i == j {
				continue
			}

			sum := 0
			for k := 0; k < len(words[i]); k++ {
				sum += Abs(int(words[i][k] - words[j][k]))
			}

			if sum < min {
				min = sum
			}
		}
	}

	out.WriteString(strconv.Itoa(min) + "\n")

}

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

func readInt(in *bufio.Reader) int {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.Atoi(nStr)
	return n
}

func readLine(in *bufio.Reader) string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")
	return line
}

func readLineNumbs(in *bufio.Reader) []string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")
	numbs := strings.Split(line, " ")
	return numbs
}

func readArrInt(in *bufio.Reader) []int {
	numbs := readLineNumbs(in)
	arr := make([]int, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.Atoi(n)
		arr[i] = val
	}
	return arr
}

func readArrInt64(in *bufio.Reader) []int64 {
	numbs := readLineNumbs(in)
	arr := make([]int64, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.ParseInt(n, 10, 64)
		arr[i] = val
	}
	return arr
}

package main
import (
    "fmt"
    "os"
    "bufio"
)
const INF = int(1e9)
func abs(x int) int {
    if x<0 {
        x = -x
    }
    return x
}
func main() {
    r := bufio.NewReader(os.Stdin)
    w := bufio.NewWriter(os.Stdout)
    defer w.Flush()

    var t int
    fmt.Fscan(r, &t)
    for _i:=0;_i<t;_i++ {
        var n,m int
        fmt.Fscan(r, &n, &m)
        s := make([]string, n)
        for i:=0;i<n;i++ {
            fmt.Fscan(r, &s[i])
        }
        ans := INF
        for i:=0;i<n;i++ {
            for j:=0;j<i;j++ {
                res := 0
                for k:=0;k<m;k++ {
                    res += abs(int(s[i][k]-s[j][k]))
                }
                if ans>res {
                    ans=res
                }
            }
        }
        fmt.Fprintln(w, ans)
    }
}

package main

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

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

func solve() string {
	var n, m int
	fmt.Fscan(in, &n, &m)
	var words = make([]string, n)
	for i := range words {
		fmt.Fscan(in, &words[i])
	}
	var res = math.MaxInt
	var temp int
	sort.Strings(words)
	for i := 0; i < len(words)-1; i++ {
		temp = 0
		for j := 0; j < m; j++ {
			if words[i][j] > words[i+1][j] {
				temp += int(words[i][j] - words[i+1][j])
			} else {
				temp += int(words[i+1][j] - words[i][j])
			}
		}
		if temp < res {
			res = temp
		}
	}

	return strconv.FormatInt(int64(res), 10)
}

func main() {
	defer out.Flush()
	var t int
	for fmt.Fscanln(in, &t); t > 0; t-- {
		fmt.Fprintln(out, solve())
	}
}

package main

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

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

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

	var T int
	var n int
	var sn int
	var x string

	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n)
		Fscan(in, &sn)

		row := make([]string, n)
		for i := 0; i < n; i++ {
			Fscan(in, &x)
			row[i] = x
		}

		ans := 1<<30
		for i, v := range row {
			for j := i + 1; j < n; j++ {
				t := 0
				vv := row[j]
				for k := 0; k < sn; k++ {
					tt := int(vv[k]-v[k])
					if tt < 0 {
						tt = -tt
					}
					t += tt
				}
				if t < ans {
					ans = t
				}
			}
		}

		Fprintln(out, ans)
	}
}


package main

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

// github.com/EndlessCheng/codeforces-go
func CF1368E(_r io.Reader, _w io.Writer) {
	out := bufio.NewWriter(_w)
	defer out.Flush()
	buf := make([]byte, 4096)
	_i := len(buf)
	rc := func() byte {
		if _i == len(buf) {
			_r.Read(buf)
			_i = 0
		}
		b := buf[_i]
		_i++
		return b
	}
	r := func() (x int) {
		b := rc()
		for ; '0' > b; b = rc() {
		}
		for ; '0' <= b; b = rc() {
			x = x*10 + int(b&15)
		}
		return
	}

	for t := r(); t > 0; t-- {
		n := r()
		g := make([][]int, n+1)
		for m := r(); m > 0; m-- {
			v, w := r(), r()
			g[w] = append(g[w], v)
		}
		ans := []interface{}{}
		dp := make([]int, n+1)
		for w, vs := range g {
			for _, v := range vs {
				if dp[v]+1 > dp[w] {
					dp[w] = dp[v] + 1
				}
			}
			if dp[w] > 1 {
				dp[w] = -1
				ans = append(ans, w)
			}
		}
		Fprintln(out, len(ans))
		Fprintln(out, ans...)
	}
}

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

package main

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

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 main() {
	reader := bufio.NewReader(os.Stdin)

	tc := readNum(reader)

	for tc > 0 {
		tc--
		n, m := readTwoNums(reader)
		E := make([][]int, m)
		for i := 0; i < m; i++ {
			E[i] = readNNums(reader, 2)
		}
		res := solve(n, E)
		var buf bytes.Buffer
		buf.WriteString(fmt.Sprintf("%d\n", len(res)))
		for i := 0; i < len(res); i++ {
			buf.WriteString(fmt.Sprintf("%d ", res[i]))
		}
		fmt.Println(buf.String())
	}
}

func solve(n int, E [][]int) []int {
	out := make([][]int, n)
	for i := 0; i < n; i++ {
		out[i] = make([]int, 0, 2)
	}
	for _, e := range E {
		u, v := e[0], e[1]
		u--
		v--
		out[u] = append(out[u], v)
	}
	cnt := make([]int, n)
	res := make([]int, 0, 4*n/7)
	for i := 0; i < n; i++ {
		if cnt[i] > 1 {
			// need to remove it
			res = append(res, i+1)
		} else {
			// keep it
			for _, j := range out[i] {
				cnt[j] = max(cnt[j], cnt[i]+1)
			}
		}
	}

	return res
}

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

package main

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

const (
	mod = int64(998244353)
)

var cur []int
var inDegree []int
var cannotComeBlocker []int
var n, m int
var found bool
var edges [][]int
var ans []int

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	tt := 1
	fmt.Fscanf(in, "%d\n", &tt)
	for t := 0; t < tt; t++ {
		n, m = 0, 0
		fmt.Fscanf(in, "%d %d\n", &n, &m)
		edges = make([][]int, n)
		o, p := 0, 0
		for i := 0; i < m; i++ {
			fmt.Fscanf(in, "%d %d\n", &o, &p)
			o--
			p--
			edges[o] = append(edges[o], p)
		}
		cur = []int{}
		found = false
		inDegree = make([]int, n)
		cannotComeBlocker = make([]int, n)
		dfs(0)
		curMap := make(map[int]bool)
		for _, tmp := range ans {
			curMap[tmp] = true
		}
		fmt.Fprintf(out, "%d\n", n-len(ans))
		isFirst := true
		for i := 0; i < n; i++ {
			if !curMap[i] {
				if !isFirst {
					fmt.Fprintf(out, " ")
				} else {
					isFirst = false
				}
				fmt.Fprintf(out, "%d", i+1)
			}
		}
		fmt.Fprintf(out, "\n")
	}
	return
}

func dfs(i int) {
	//fmt.Println(i, cur, inDegree, cannotComeBlocker, n*4/7)
	if found {
		return
	}
	if (n - len(cur)) <= n*4/7 {
		//fmt.Println("wtf?")
		ans = make([]int, 0)
		for i := 0; i < len(cur); i++ {
			ans = append(ans, cur[i])
		}
		found = true
		return
	}
	if i == n {
		return
	}
	if cannotComeBlocker[i] > 0 {
		dfs(i + 1)
		return
	}
	if inDegree[i] == 0 {
		for _, next := range edges[i] {
			inDegree[next]++
		}
		cur = append(cur, i)
		dfs(i + 1)
		cur = cur[:len(cur)-1]
		for _, next := range edges[i] {
			inDegree[next]--
		}
	} else {
		//fmt.Println("debug", edges[i])
		for _, next := range edges[i] {
			cannotComeBlocker[next]++
		}
		cur = append(cur, i)
		dfs(i + 1)
		cur = cur[:len(cur)-1]
		for _, next := range edges[i] {
			cannotComeBlocker[next]--
		}
	}
	dfs(i + 1)
}

package main

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

// github.com/EndlessCheng/codeforces-go
func main() {
	I := bufio.NewReader(os.Stdin)
	O := bufio.NewWriter(os.Stdout)
	defer O.Flush()
	var t, n, m, v, w int
	for Fscan(I, &t); t > 0; t-- {
		Fscan(I, &n, &m)
		g := make([][]int, n+1)
		for ; m > 0; m-- {
			Fscan(I, &v, &w)
			g[w] = append(g[w], v)
		}
		a := []interface{}{}
		l := make([]int, n+1)
		for w, u := range g {
			for _, v := range u {
				if l[v]+1 > l[w] {
					l[w] = l[v] + 1
				}
			}
			if l[w] > 1 {
				l[w] = -1
				a = append(a, w)
			}
		}
		Fprintln(O, len(a))
		Fprintln(O, a...)
	}
}

package main

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

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

	var t, n, m, v, w int
	for Fscan(in, &t); t > 0; t-- {
		Fscan(in, &n, &m)
		g := make([][]int, n+1)
		for ; m > 0; m-- {
			Fscan(in, &v, &w)
			g[w] = append(g[w], v)
		}
		ans := []interface{}{}
		dp := make([]int, n+1)
		for w, vs := range g {
			for _, v := range vs {
				if dp[v]+1 > dp[w] {
					dp[w] = dp[v] + 1
				}
			}
			if dp[w] > 1 {
				dp[w] = -1
				ans = append(ans, w)
			}
		}
		Fprintln(out, len(ans))
		Fprintln(out, ans...)
	}
}

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

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1368E(_r io.Reader, _w io.Writer) {
	out := bufio.NewWriter(_w)
	defer out.Flush()
	buf := make([]byte, 4096)
	_i := len(buf)
	rc := func() byte {
		if _i == len(buf) {
			_r.Read(buf)
			_i = 0
		}
		b := buf[_i]
		_i++
		return b
	}
	r := func() (x int) {
		b := rc()
		for ; '0' > b; b = rc() {
		}
		for ; '0' <= b; b = rc() {
			x = x*10 + int(b&15)
		}
		return
	}

	for t := r(); t > 0; t-- {
		n := r()
		g := make([][]int, n+1)
		for m := r(); m > 0; m-- {
			v, w := r(), r()
			g[w] = append(g[w], v)
		}
		c := 0
		s := []byte{}
		dp := make([]int, n+1)
		for w, vs := range g {
			for _, v := range vs {
				if dp[v]+1 > dp[w] {
					dp[w] = dp[v] + 1
				}
			}
			if dp[w] > 1 {
				dp[w] = -1
				c++
				s = append(s, strconv.Itoa(w)...)
				s = append(s, ' ')
			}
		}
		Fprintf(out, "%d\n%s\n", c, s)
	}
}

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

package main

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

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 main() {
	reader := bufio.NewReader(os.Stdin)

	tc := readNum(reader)

	for tc > 0 {
		tc--
		n, m := readTwoNums(reader)
		E := make([][]int, m)
		for i := 0; i < m; i++ {
			E[i] = readNNums(reader, 2)
		}
		res := solve(n, E)
		var buf bytes.Buffer
		buf.WriteString(fmt.Sprintf("%d\n", len(res)))
		for i := 0; i < len(res); i++ {
			buf.WriteString(fmt.Sprintf("%d ", res[i]))
		}
		fmt.Println(buf.String())
	}
}

func solve(n int, E [][]int) []int {
	degree := make([]int, n)
	out := make([][]int, n)
	for i := 0; i < n; i++ {
		out[i] = make([]int, 0, 2)
	}
	for _, e := range E {
		u, v := e[0], e[1]
		u--
		v--
		out[u] = append(out[u], v)
		degree[v]++
	}
	res := make([]int, 0, 4*n/7)
	for i := 0; i < n; i++ {
		if degree[i] > 1 {
			res = append(res, i+1)
			for _, j := range out[i] {
				degree[j]--
			}
		}
	}

	return res
}

package main

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

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 main() {
	reader := bufio.NewReader(os.Stdin)

	tc := readNum(reader)

	for tc > 0 {
		tc--
		n, m := readTwoNums(reader)
		E := make([][]int, m)
		for i := 0; i < m; i++ {
			E[i] = readNNums(reader, 2)
		}
		res := solve(n, E)
		var buf bytes.Buffer

		for i := 0; i < len(res); i++ {
			buf.WriteString(fmt.Sprintf("%d ", res[i]))
		}
		fmt.Println(buf.String())
	}
}

func solve(n int, E [][]int) []int {
	degree := make([]int, n)
	out := make([][]int, n)
	for i := 0; i < n; i++ {
		out[i] = make([]int, 0, 2)
	}
	for _, e := range E {
		u, v := e[0], e[1]
		u--
		v--
		out[u] = append(out[u], v)
		degree[v]++
	}
	res := make([]int, 0, 4*n/7)
	for i := 0; i < n; i++ {
		if degree[i] > 1 {
			res = append(res, i+1)
			for _, j := range out[i] {
				degree[j]--
			}
		}
	}

	return res
}

package main

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

const (
	mod = int64(998244353)
)

var cur []int
var inDegree []int
var cannotComeBlocker []int
var n, m int
var found bool
var edges [][]int
var ans []int

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	tt := 1
	fmt.Fscanf(in, "%d\n", &tt)
	for t := 0; t < tt; t++ {
		n, m = 0, 0
		fmt.Fscanf(in, "%d %d\n", &n, &m)
		edges = make([][]int, n)
		o, p := 0, 0
		for i := 0; i < m; i++ {
			fmt.Fscanf(in, "%d %d\n", &o, &p)
			edges[o] = append(edges[o], p)
		}
		cur = []int{}
		found = false
		inDegree = make([]int, n)
		cannotComeBlocker = make([]int, n)
		dfs(0)
		curMap := make(map[int]bool)
		for _, tmp := range ans {
			curMap[tmp] = true
		}
		fmt.Fprintf(out, "%d\n", n-len(ans))
		isFirst := true
		for i := 0; i < n; i++ {
			if !curMap[i] {
				if !isFirst {
					fmt.Fprintf(out, " ")
				} else {
					isFirst = false
				}
				fmt.Fprintf(out, "%d", i+1)
			}
		}
		fmt.Fprintf(out, "\n")
	}
	return
}

func dfs(i int) {
	//fmt.Println(cur)
	if i == n {
		return
	}
	if found {
		return
	}
	if (n - len(cur)) <= n*4/7 {
		ans = cur
		found = true
		return
	}
	if cannotComeBlocker[i] > 0 {
		dfs(i + 1)
		return
	}
	if inDegree[i] == 0 {
		for _, next := range edges[i] {
			inDegree[next]++
		}
		cur = append(cur, i)
		dfs(i + 1)
		cur = cur[:len(cur)-1]
		for _, next := range edges[i] {
			inDegree[next]--
		}
	} else {
		for _, next := range edges[i] {
			cannotComeBlocker[next]++
		}
		cur = append(cur, i)
		dfs(i + 1)
		cur = cur[:len(cur)-1]
		for _, next := range edges[i] {
			cannotComeBlocker[next]--
		}
	}
	dfs(i + 1)
}

package main

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

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

	var t, n, m, v, w int
	for Fscan(in, &t); t > 0; t-- {
		Fscan(in, &n, &m)
		g := make([][]int, n+1)
		has := make([]bool, n+1)
		for ; m > 0; m-- {
			Fscan(in, &v, &w)
			g[v] = append(g[v], w)
			has[w] = true
		}

		ans := []interface{}{}
		ans2 := []interface{}{}
		q := []int{}
		for i := 1; i <= n; i++ {
			if !has[i] {
				ans = append(ans, i)
				q = append(q, i)
			}
		}
		dep := make([]int, n+1)
		for len(q) > 0 {
			v, q = q[0], q[1:]
			for _, w := range g[v] {
				if dep[w] == 0 {
					dep[w] = dep[v] + 1
					if dep[w]&1 == 0 {
						ans = append(ans, w)
					} else {
						ans2 = append(ans2, w)
					}
					q = append(q, w)
				}
			}
		}
		if len(ans) > len(ans2) {
			ans, ans2 = ans2, ans
		}
		Fprintln(out, len(ans))
		Fprintln(out, ans...)
	}
}

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

package main

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

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

	var t, n, m, v, w int
	for Fscan(in, &t); t > 0; t-- {
		Fscan(in, &n, &m)
		g := make([][]int, n+1)
		has := make([]bool, n+1)
		for ; m > 0; m-- {
			Fscan(in, &v, &w)
			g[v] = append(g[v], w)
			has[w] = true
		}

		st := 1
		for ; st <= n && has[st]; st++ {
		}
		dep := make([]int, n+1)
		vs := []interface{}{st}
		vs2 := []interface{}{}
		q := []int{st}
		for len(q) > 0 {
			v := q[0]
			q = q[1:]
			for _, w := range g[v] {
				if dep[w] == 0 {
					dep[w] = dep[v] + 1
					if dep[w]&1 == 0 {
						vs = append(vs, w)
					} else {
						vs2 = append(vs2, w)
					}
					q = append(q, w)
				}
			}
		}
		if len(vs) > len(vs2) {
			vs, vs2 = vs2, vs
		}
		Fprintln(out, len(vs))
		Fprintln(out, vs...)
	}
}

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