package main

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

type MyScanner struct {
	in *bufio.Scanner
}

var in = MyScanner{bufio.NewScanner(os.Stdin)}

func ScanInts(data []byte, atEOF bool) (advance int, token []byte, err error) {
	advance, token, err = bufio.ScanWords(data, atEOF)
	if err == nil && token != nil {
		_, err = strconv.Atoi(string(token))
	}
	return
}

func (m *MyScanner) innerNext(f bufio.SplitFunc) bool {
	m.in.Split(f)
	return m.in.Scan()
}

func (m *MyScanner) NextInt() (int, error) {
	if !m.innerNext(ScanInts) {
		return 0, m.in.Err()
	}
	r, _ := strconv.Atoi(m.in.Text())
	return r, nil
}

func main() {
	n, _ := in.NextInt()
	b := make([]byte, n)
	for i := 1; i < n; i += 2 {
		m := (n - i) / 2
		p := 0
		for j := 0; j < m; j++ {
			b[p] = '*'
			b[n-p-1] = '*'
			p++
		}
		for j := 0; j < i; j++ {
			b[p] = 'D'
			p++
		}
		fmt.Println(string(b))
	}
	for i := 0; i < n; i++ {
		b[i] = 'D'
	}
	fmt.Println(string(b))
	for i := n - 2; i > 0; i -= 2 {
		m := (n - i) / 2
		p := 0
		for j := 0; j < m; j++ {
			b[p] = '*'
			b[n-p-1] = '*'
			p++
		}
		for j := 0; j < i; j++ {
			b[p] = 'D'
			p++
		}
		fmt.Println(string(b))
	}
}

package main

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

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

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

	n := nextInt()
	m := n / 2

	k, l := m, 0

	for i := 0; i < m; i++ {
		for j := 0; j < k; j++ {
			print("*")
		}

		for j := 0; j <= l; j++ {
			print("D")
		}

		for j := 0; j < k; j++ {
			print("*")
		}

		k--
		l += 2
		println()
	}

	for i := 0; i < n; i++ {
		print("D")
	}

	println()

	k, l = 0, n - 2

	for i := 0; i < m; i++ {
		for j := 0; j <= k; j++ {
			print("*")
		}

		for j := 0; j < l; j++ {
			print("D")
		}

		for j := 0; j <= k; j++ {
			print("*")
		}

		k++
		l -= 2
		println()
	}
}

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

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

func nextFloat() float64 {
	n, err := strconv.ParseFloat(next(), 64)
	if err != nil {
		panic(err)
	}
	return n
}

func println(a ...interface{}) {
	fmt.Fprintln(writer, a...)
}

func print(a ...interface{}) {
	fmt.Fprint(writer, a...)
}

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

package main

import "fmt"

func main() {
	var n int
	var r []rune

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

	r = make([]rune, n)

	for i := 0; i < n; i++ {
		r[i] = '*'
	}

	r[n/2] = 'D'

	fmt.Println(string(r))

	for i := 1; i <= (n / 2); i++ {
		r[(n/2)+i] = 'D'
		r[(n/2)-i] = 'D'
		fmt.Println(string(r))
	}
	for i := 0; i < (n / 2); i++ {
		r[i] = '*'
		r[n-1-i] = '*'
		fmt.Println(string(r))
	}
}

package main

import "fmt"

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

func main() {
	var n int
	fmt.Scan(&n)
	a := n / 2
	for i := 0; i < n; i++ {
		b := abs(i - a)
		for j := 0; j < b; j++ {
			fmt.Print("*")
		}
		for j := 0; j < n-2*b; j++ {
			fmt.Print("D")
		}
		for j := 0; j < b; j++ {
			fmt.Print("*")
		}
		fmt.Println()
	}
}

package main

import (
	"fmt"
)

func out(a int, b int) {
	for j := 0; j < a; j++ {
		fmt.Print("*")
	}
	for j := 0; j < b; j++ {
		fmt.Print("D")
	}
	for j := 0; j < a; j++ {
		fmt.Print("*")
	}
	fmt.Println()
}

func main() {
	var n int
	fmt.Scanf("%d", &n)

	for i := 0; i < n / 2 + 1; i++ {
		out(n / 2 - i, i * 2 + 1)
	}
	for i := 0; i < n / 2; i++ {
		j := n / 2 - 1 - i
		out(n / 2 - j, j * 2 + 1)
	}
}

package main

import "fmt"

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

	for i := 1; i <= n; i++ {
		l := 0
		if i <= (n+1)/2 {
			l = 2*i - 1
		} else {
			l = 2*(n-i) + 1
		}

		k := (n-l)/2 + 1
		for j := 1; j <= n; j++ {
			if j < k {
				fmt.Print("*")
			} else if j >= (k + l) {
				fmt.Print("*")
			} else {
				fmt.Print("D")
			}
		}
		fmt.Println("")
	}
}

package main

import (
    "fmt"
)

func Prt(n int, j int){
    for i := 1 ; i <= n ; i++ {
        if ( i <= n/2 - j + 1 ) || ( i >= n/2 + j + 1) {
            fmt.Print("*")
        } else {
            fmt.Print("D")
        }
    }
    fmt.Println()
}

func main() {
    var n int
    fmt.Scanf("%d",&n)
    for i := 1 ; i <= n/2 ; i++ {
        Prt(n,i)
    }
    for i:= n/2 + 1; i<= n ;i++{
        Prt(n,n-i+1)
    }
}

package main

import (
    "fmt"
    )

func get_line(index, n int) string {
    line := make([]byte, n, n)
    if index > n / 2 {
        index = n - index - 1
    }

    nd := index * 2 + 1
    nstar := (n - nd) / 2
    i := 0
    for ; i < nstar; i++ {
        line[i] = '*'
        line[n-i-1] = '*'
    }
    for ; i < nstar + nd; i++ {
        line[i] = 'D'
    }

    return string(line)
}

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

    for i := 0; i < n; i++ {
        line := get_line(i, n)
        fmt.Println(line)
    }
}


package main
import ."fmt"

func main() {
	var T, n int
	for Scan(&T); T > 0; T-- {
		Scan(&n)
		a := make([]int, n)
		for i := range a {
			Scan(&a[i])
		}
		set := map[int]bool{}
		for i := 0; i < 1<<n; i++ {
			sum := 0
			for j, v := range a {
				sum += i >> j & 1 * v
			}
			set[sum] = true
		}
		if len(set) < 1<<n {
			Println("YES")
		} else {
			Println("NO")
		}
	}
}

package main
import."fmt"

// github.com/EndlessCheng/codeforces-go
func main(){
	T,n:=0,0
	for Scan(&T);T>0;T--{
		Scan(&n)
		a:=make([]int,n)
		for i:=range a{Scan(&a[i])}
		m:=map[int]int{}
		for i:=0;i<1<<n;i++{
			s:=0
			for j,v:=range a{s+=i>>j&1*v}
			m[s]=1
		}
		s:="NO";if len(m)<1<<n{s="YES"}
		Println(s)
	}
}

package main

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

var (
	read  = bufio.NewReader(os.Stdin)
	write = bufio.NewWriter(os.Stdout)
)

func main() {
	defer write.Flush()
	var t int
	fmt.Fscan(read, &t)
	for i := 0; i < t; i++ {
		solve()
	}
}

func solve() {
	var n int
	fmt.Fscan(read, &n)
	a := make([]int, n)
	for i := range a {
		fmt.Fscan(read, &a[i])
	}
	m := map[int]int{}
	for i := 0; i < 1<<n; i++ {
		s := 0
		for j, l := range a {
			s += i >> j & 1 * l
			//fmt.Fprintln(write,i,j,l, i>>j&1*l)
		}
		m[s] = 1
	}
	//fmt.Fprintln(write, len(m), 1<<n)
	s := "NO"
	if len(m) < 1<<n {
		s = "YES"
	}
	fmt.Fprintln(write, s)
}

package main
import ."fmt"

func main() {
	var T, n int
	for Scan(&T); T > 0; T-- {
		Scan(&n)
		a := make([]int, n)
		for i := range a {
			Scan(&a[i])
		}
		set := map[int]bool{}
		for i := 0; i < 1<<n; i++ {
			sum := 0
			for j, v := range a {
				sum += i >> j & 1 * v
			}
			set[sum] = true
		}
		if len(set) < 1<<n { // 至少有两个子集和相同
			Println("YES")
		} else {
			Println("NO")
		}
	}
}

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1552D(in io.Reader, out io.Writer) {
	var T, n int
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n)
		a := make([]int, n)
		for i := range a {
			Fscan(in, &a[i])
		}
		has := map[int]bool{}
		for i := 0; i < 1<<n; i++ {
			sum := 0
			for j, v := range a {
				sum += i >> j & 1 * v
			}
			has[sum] = true
		}
		if len(has) < 1<<n { // 存在两个不同的
			Fprintln(out, "YES")
		} else {
			Fprintln(out, "NO")
		}
	}
}

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

package main

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

var (
	read  = bufio.NewReader(os.Stdin)
	write = bufio.NewWriter(os.Stdout)
)

func main() {
	defer write.Flush()
	var t int
	fmt.Fscan(read, &t)
	for i := 0; i < t; i++ {
		solve()
	}
}

func solve() {
	var n int
	fmt.Fscan(read, &n)
	a := make([]int, n)
	for i := range a {
		fmt.Fscan(read, &a[i])
	}
	m := map[int]int{}
	for i := 0; i < 1<<n; i++ {
		s := 0
		for j, l := range a {
			s += i >> j & 1 * l
			fmt.Fprintln(write,i,j,l, i>>j&1*l)
		}
		m[s] = 1
	}
	fmt.Fprintln(write, len(m), 1<<n)
	s := "NO"
	if len(m) < 1<<n {
		s = "YES"
	}
	fmt.Fprintln(write, s)
}


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)
		list1:= make([]int,n)
		list2:= make([]int,n)
		for j:=0;j<n;j++{
			fmt.Fscan(in,&list1[j])
		}
		for j:=0;j<n;j++{
			fmt.Fscan(in,&list2[j])
		}
		fmt.Fprintf(out,"%v ",list2[0]-list1[0])
		for j:=0;j<n-1;j++{
			if list2[j] > list1[j+1] {
				fmt.Fprintf(out,"%v ",list2[j+1]-list2[j])
			} else {
				fmt.Fprintf(out,"%v ",list2[j+1]-list1[j+1])
			}
		}
		fmt.Fprintln(out,)
	}
}

package main

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

var (
    a, b [2e5+5]int64
)

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

func run(_r io.Reader, _w io.Writer){
    in := bufio.NewScanner(_r)
    out := bufio.NewWriter(_w)
    defer out.Flush()
    in.Split(bufio.ScanWords)
    read := func() (x int64) {
        in.Scan()
        for _, v := range in.Bytes() {
            x = x*10 + int64(v & 15)
        }
        return
    }
    for t := read(); t > 0; t-- {
        n := read()
        for i := int64(1); i <= n; i++ {
            a[i] = read()
        }
        for i := int64(1); i <= n; i++ {
            b[i] = read()
        }
        for i := int64(1); i <= n; i++ {
            Fprint(out, b[i] - a[i], " ")
            if b[i] > a[i+1] {
                a[i+1] = b[i]
            }
        }
        Fprintln(out)
    }
}

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

package main

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

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

func main() {
	defer out.Flush()
	var t, n int
	for fmt.Fscan(in, &t); t > 0; t-- {
		fmt.Fscan(in, &n)
		s := make([]int, n+1)
		f := make([]int, n+1)
		for i := 1; i <= n; i++ {
			fmt.Fscan(in, &s[i])
		}
		for i := 1; i <= n; i++ {
			fmt.Fscan(in, &f[i])
		}
		for i := 1; i <= n; i++ {
			fmt.Fprintf(out, "%d ", f[i]-int(math.Max(float64(s[i]), float64(f[i-1]))))
		}
		fmt.Fprintln(out, "")
	}
}

package main

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

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

func main() {

	var n int
	fmt.Fscan(in, &n)
	for 0 < n {
		n--
		solve()
	}
	defer out.Flush()
}

func solve() {

	var n int
	fmt.Fscan(in, &n)
	a := make([]int, n)
	b := make([]int, n)

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

	var last int

	for i := 0; i < n; i++ {
		if last > a[i] {
			fmt.Fprint(out, b[i]-last, " ")
		} else {
			fmt.Fprint(out, b[i]-a[i], " ")
		}
		last = Max(last, b[i])
	}
	fmt.Fprintln(out)
}

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

package main

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

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

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

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

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

func main() {
	defer writer.Flush()
	var test int
	scanf("%v\n", &test)
	for ; test > 0; test-- {
		var n int
		scanf("%v\n", &n)
		s := make([]int, n)
		f := make([]int, n)
		for i := 0; i < n; i++ {
			scanf("%v", &s[i])
		}
		scanf("\n")
		for i := 0; i < n; i++ {
			scanf("%v", &f[i])
		}
		scanf("\n")
		printf("%v ", f[0] - s[0])
		for i := 1; i < n; i++ {
			printf("%v ", f[i] - Max(s[i], f[i - 1]))
		}
		printf("\n")
	}
}

package main

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

const (
	MaxInt32 = 1 << 31 - 1
)

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

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

func main(){
	cin := bufio.NewReader(os.Stdin)
	var t int
	fmt.Fscan(cin, &t)
	for tc := 0; tc < t; tc++ {
		var n int
		fmt.Fscan(cin, &n)
		s := make([]int, n)
		f := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(cin, &s[i])
		}
		for i := 0; i < n; i++ {
			fmt.Fscan(cin, &f[i])
		}
		for i := 0; i < n; i++ {
			ans := 0
			if i > 0 {
				ans = f[i] - Max(s[i], f[i-1])
			}else {
				ans = f[i] - s[i]
			}
			if i == n - 1{
				fmt.Printf("%d\n", ans)
			}else {
				fmt.Printf("%d ", ans)
			}
		}
	}
}

package main

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

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

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

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

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

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

/**
Run solve the problem CF1690C
Date: 11/06/22
User: pepradere
URL: https://codeforces.com/problemset/problem/1690/C
Problem: CF1690C
**/
func (in *CF1690C) Run() {
	for t := in.NextInt(); t > 0; t-- {
		n := in.NextInt()
		a := make([]int, n)
		for i := 0; i < n; i++ {
			a[i] = in.NextInt()
		}
		b := make([]int, n)
		for i := 0; i < n; i++ {
			b[i] = in.NextInt()
		}
		for i:=0;i<n;i++{
			if i == 0 {
				fmt.Print(b[i]-a[i])
			}else {
				fmt.Print(" ",b[i]-int(math.Max(float64(b[i-1]), float64(a[i]))))
			}
		}
		fmt.Println()
	}
}

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

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

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

		fmt.Fprintf(out, "%d ", b[0]-a[0])
		for i := 1; i < n; i++ {
			if b[i-1] > a[i] {
				a[i] = b[i-1]
			}
			fmt.Fprintf(out, "%d ", b[i]-a[i])
		}
		fmt.Fprintln(out)
	}
}

package main

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

/*
4
3
3 6 9
4 7 11
5
0 3 4 7 9
2 4 5 8 10
5
0 1 3 4 7
2 3 7 8 10
4
0 1 2 3
5 6 7 8
---
1 1 2
2 1 1 1 1
2 1 4 1 2
5 1 1 1
*/

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

	a := make([]int, n)

	for i := range a {
		scanf("%d", &a[i])
	}
	scanf("\n")

	f := make([]int, n)

	for i := range f {
		scanf("%d", &f[i])
	}
	scanf("\n")

	prevFinish := 0

	for i := range f {
		start := max(prevFinish, a[i])
		d := f[i] - start
		prevFinish = f[i]

		fmt.Fprintf(writer, "%d ", d)
	}
	fmt.Fprintln(writer)
}

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

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

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

const maxUint = ^uint(0)

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

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

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

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

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

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

//goland:noinspection GoUnusedFunction
func min(nums ...int) int {
	return nums[minIdx(nums...)]
}

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

	return minNumIdx
}

//goland:noinspection GoUnusedFunction
func max(nums ...int) int {
	return nums[maxIdx(nums...)]
}

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

	return maxNumIdx
}

//goland:noinspection GoUnusedFunction
func sum(nums ...int) (sum int) {
	for _, num := range nums {
		sum += num
	}
	return
}

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

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

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

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

	return true
}

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

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

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

	num = abs(num)

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

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

//goland:noinspection GoUnusedFunction
func factorize(num int64) []int64 {
	factors := make([]int64, 0)

	for ftr := int64(2); ftr*ftr <= num; ftr++ {
		for num%ftr == 0 {
			num /= ftr
			factors = append(factors, ftr)
		}
	}

	if num > 1 {
		factors = append(factors, num)
	}

	return factors
}

package main

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

func A3() {
	_in, _out := os.Stdin, os.Stdout
	in, out := bufio.NewReader(_in), bufio.NewWriter(_out)
	defer out.Flush()
	var cas int = 1
	Fscan(in, &cas)
	var sol func()
	// Coding...beg!
	sol = func() {
		var n int

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

		}
		for i := 0; i < n; i++ {
			Fscan(in, &f[i])

		}
		ans := []int{f[0] - s[0]}
		ed := f[0]
		for i := 1; i < n; i++ {
			if s[i] <= ed {
				if f[i] <= ed {
					ans = append(ans, 0)

				} else {
					ans = append(ans, f[i]-ed)
					ed = f[i]
				}
			} else {
				ans = append(ans, f[i]-s[i])
				ed = f[i]
			}
		}
		for i := 0; i < n; i++ {
			Fprint(out, ans[i], " ")
		}
		Fprintln(out)
	}
	// Coding...ove!
	for i := 0; i < cas; i++ {
		sol()
	}
}

func main() { A3() }

package main

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

var r = bufio.NewReader(os.Stdin)
var w = bufio.NewWriter(os.Stdout)

func slove() {
	var n int
	fmt.Fscan(r, &n)
	a := make([]int, n)
	for i:=0;i<n;i++ {
		fmt.Fscan(r, &a[i])
	}
	b := make([]int, n)
	for i:=0;i<n;i++ {
		fmt.Fscan(r, &b[i])
	}
	ans := make([]int, n)
	ans[0] = b[0] - a[0]
	for i:=1;i<n;i++ {
		ans[i] = b[i] - max(a[i], b[i-1])
	}
	for i := range ans {
		fmt.Fprint(w, ans[i], " ")
	}
	fmt.Fprint(w, "\n")
}

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

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


package main

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

var (
	r *bufio.Scanner
	w *bufio.Writer
)

const ISDEBUG = false

func readLine() string {
	r.Scan()
	return r.Text()
}

func readInt() int {
	r.Scan()
	x, _ := strconv.Atoi(r.Text())
	return x
}

func readInts(n int) []int {
	var res []int
	for i := 0; i < n; i++ {
		if !r.Scan() {
			fmt.Println(r.Err())
		}
		x, _ := strconv.Atoi(r.Text())
		res = append(res, x)
	}
	return res
}

func isLower(c rune) bool {
	return c >= 'a' && c <= 'z'
}

func isUpper(c rune) bool {
	return c >= 'A' && c <= 'Z'
}

func isDigit(c rune) bool {
	return c >= '0' && c <= '9'
}

func A() {
	t := readInt()
	for i := 0; i < t; i++ {
		s := readLine()
		hasLower, hasUpper, hasDigit := false, false, false
		errs := 3
		result := s
		for _, c := range s {
			if isUpper(c) {
				if !hasUpper {
					errs -= 1
				}
				hasUpper = true
			}

			if isLower(c) {
				if !hasLower {
					errs -= 1
				}
				hasLower = true
			}

			if isDigit(c) {
				if !hasDigit {
					errs -= 1
				}
				hasDigit = true
			}
		}

		if errs == 2 {
			if hasLower {
				result = "A1" + s[2:]
			}
			if hasUpper {
				result = "a1" + s[2:]
			}
			if hasDigit {
				result = "Aa" + s[2:]
			}
		} else if errs == 1 {
			cupper, clower, cdigit := 0, 0, 0
			pos := 0
			for j, c := range s {
				if isUpper(c) {
					cupper += 1
					if cupper > 1 {
						pos = j
						break
					}
				}

				if isLower(c) {
					clower += 1
					if clower > 1 {
						pos = j
						break
					}
				}

				if isDigit(c) {
					cdigit += 1
					if cdigit > 1 {
						pos = j
						break
					}
				}
			}
			if !hasDigit {
				result = s[0:pos] + "0" + s[pos+1:]
			} else if !hasLower {
				result = s[0:pos] + "a" + s[pos+1:]
			} else {
				result = s[0:pos] + "A" + s[pos+1:]
			}

		}

		w.WriteString(fmt.Sprintf("%s\n", result))
	}
}

func main() {
	if ISDEBUG {
		fi, err := os.Open("input.txt")
		if err != nil {
			panic(err)
		}
		fo, _ := os.OpenFile("output.txt", os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0755)
		r = bufio.NewScanner(fi)
		w = bufio.NewWriter(fo)

		defer fi.Close()
		defer fo.Close()
	} else {
		r = bufio.NewScanner(os.Stdin)
		w = bufio.NewWriter(os.Stdout)
	}
	r.Split(bufio.ScanWords)
	defer w.Flush()

	A()
}

package main

import (
	"fmt"
)

type char struct {
	cond   func(b byte) bool
	symbol string
	points []int
}

func sortChars(src []*char) {
	for i := 1; i < len(src); i++ {
		for j := i; j > 0; j-- {
			if len(src[j].points) > len(src[j-1].points) {
				src[j], src[j-1] = src[j-1], src[j]
			}
		}
	}
}

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

	for T > 0 {
		T--
		upper := char{
			symbol: "A",
			cond:   func(b byte) bool { return (b >= "A"[0]) && (b <= "Z"[0]) },
		}
		num := char{
			symbol: "0",
			cond:   func(b byte) bool { return (b >= "0"[0]) && (b <= "9"[0]) },
		}
		lower := char{
			symbol: "a",
			cond:   func(b byte) bool { return (b >= "a"[0]) && (b <= "z"[0]) },
		}
		chars := []*char{&upper, &lower, &num}

		var pass string
		fmt.Scan(&pass)
		for i := 0; i < len(pass); i++ {
			for _, c := range chars {
				if c.cond(pass[i]) {
					c.points = append(c.points, i)
				}
			}
		}
		sortChars(chars)

		// Good shape
		if len(chars[2].points) > 0 {
			fmt.Println(pass)
			continue
		}
		// Shape like "AAAAAAA"
		if len(chars[1].points) == 0 {
			newPass := pass[0:chars[0].points[0]] + chars[1].symbol +
				pass[chars[0].points[0]+1:chars[0].points[1]] + chars[2].symbol +
				pass[chars[0].points[1]+1:]
			fmt.Println(newPass)
			continue
		}
		// Shpae like "AAAAaaaa"
		fmt.Println(pass[0:chars[0].points[0]] + chars[2].symbol + pass[chars[0].points[0]+1:])
	}
}


package main

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

// github.com/EndlessCheng/codeforces-go
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	type query struct{ lb, rb, l, r, k, t, qid int }
	type modify struct{ p, v int }

	var n, q, op int
	Fscan(in, &n, &q)
	a := make([]int, n+1)
	for i := 1; i <= n; i++ {
		Fscan(in, &a[i])
	}
	B := int(math.Round(math.Pow(float64(n), 2.0/3)))
	qs := []query{}
	ms := []modify{}
	for ; q > 0; q-- {
		if Fscan(in, &op); op == 1 {
			var l, r, k int
			Fscan(in, &l, &r, &k)
			qs = append(qs, query{l / B, (r + 1) / B, l, r + 1, k, len(ms), len(qs)})
		} else {
			var p, v int
			Fscan(in, &p, &v)
			ms = append(ms, modify{p, v})
		}
	}
	sort.Slice(qs, func(i, j int) bool {
		a, b := qs[i], qs[j]
		if a.lb != b.lb {
			return a.lb < b.lb
		}
		if a.rb != b.rb {
			return a.rb < b.rb
		}
		if a.rb&1 == 0 {
			return a.t < b.t
		}
		return a.t > b.t
	})

	const mx int = 1e5
	var cnt, scnt, st [mx + 1]int
	for i := 0; i <= mx; i++ {
		scnt[i] = i
		st[i] = mx
	}
	st[0] = 0
	l, r, now := 1, 1, 0
	move := func(v, d int) {
		if d > 0 {
			cnt[v]++
			st[cnt[v]]--
			scnt[st[cnt[v]]] = cnt[v]
		} else {
			c := cnt[v]
			cnt[v]--
			i := st[c]
			st[c]++
			scnt[i] = cnt[v]
		}
	}
	timeSlip := func(l, r int) {
		m := ms[now]
		p, v := m.p, m.v
		if l <= p && p < r {
			move(a[p], -1)
			move(v, 1)
		}
		a[p], ms[now].v = v, a[p]
	}
	ans := make([]int, len(qs))
	for _, q := range qs {
		for ; r < q.r; r++ {
			move(a[r], 1)
		}
		for ; l < q.l; l++ {
			move(a[l], -1)
		}
		for l > q.l {
			l--
			move(a[l], 1)
		}
		for r > q.r {
			r--
			move(a[r], -1)
		}
		for ; now < q.t; now++ {
			timeSlip(q.l, q.r)
		}
		for now > q.t {
			now--
			timeSlip(q.l, q.r)
		}
		d := int(1e9)
		for i := st[1]; i+q.k <= mx; {
			c := scnt[i]
			if dd := scnt[i+q.k-1] - c; dd < d {
				d = dd
			}
			i = st[c+1]
		}
		if d == 1e9 {
			d = -1
		}
		ans[q.qid] = d
	}
	for _, v := range ans {
		Fprintln(out, v)
	}
}

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1476G(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	type query struct{ lb, rb, l, r, k, t, qid int }
	type modify struct{ pos, val int }

	var n, q, op int
	Fscan(in, &n, &q)
	a := make([]int, n+1)
	for i := 1; i <= n; i++ {
		Fscan(in, &a[i])
	}
	blockSize := int(math.Round(math.Pow(float64(n), 2.0/3)))
	qs, ms := []query{}, []modify{}
	for ; q > 0; q-- {
		if Fscan(in, &op); op == 1 {
			var l, r, k int
			Fscan(in, &l, &r, &k)
			qs = append(qs, query{l / blockSize, (r + 1) / blockSize, l, r + 1, k, len(ms), len(qs)})
		} else {
			var pos, val int
			Fscan(in, &pos, &val)
			ms = append(ms, modify{pos, val})
		}
	}
	sort.Slice(qs, func(i, j int) bool {
		a, b := qs[i], qs[j]
		if a.lb != b.lb {
			return a.lb < b.lb
		}
		if a.rb != b.rb {
			return a.rb < b.rb
		}
		if a.rb&1 == 0 {
			return a.t < b.t
		}
		return a.t > b.t
	})

	const mx int = 1e5
	var cnt, scnt, st [mx + 1]int
	for i := 1; i <= mx; i++ {
		st[i] = mx
	}
	l, r, now := 1, 1, 0
	add := func(val int) {
		cnt[val]++
		st[cnt[val]]--
		scnt[st[cnt[val]]] = cnt[val]
	}
	del := func(val int) {
		c := cnt[val]
		cnt[val]--
		i := st[c]
		st[c]++
		scnt[i] = cnt[val]
	}
	timeSlip := func(l, r int) {
		m := ms[now]
		p, v := m.pos, m.val
		if l <= p && p < r {
			del(a[p])
			add(v)
		}
		a[p], ms[now].val = v, a[p]
	}
	ans := make([]int, len(qs))
	for _, q := range qs {
		for ; r < q.r; r++ {
			add(a[r])
		}
		for ; l < q.l; l++ {
			del(a[l])
		}
		for l > q.l {
			l--
			add(a[l])
		}
		for r > q.r {
			r--
			del(a[r])
		}
		for ; now < q.t; now++ {
			timeSlip(q.l, q.r)
		}
		for now > q.t {
			now--
			timeSlip(q.l, q.r)
		}
		minDif := int(1e9)
		for i := st[1]; i+q.k <= mx; {
			c := scnt[i]
			if dif := scnt[i+q.k-1] - c; dif < minDif {
				minDif = dif
			}
			i = st[c+1]
		}
		if minDif == 1e9 {
			minDif = -1
		}
		ans[q.qid] = minDif
	}
	for _, v := range ans {
		Fprintln(out, v)
	}
}

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

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1476G(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	type query struct{ lb, rb, l, r, k, t, qid int }
	type modify struct{ pos, val int }

	var n, q, op int
	Fscan(in, &n, &q)
	a := make([]int, n+1)
	for i := 1; i <= n; i++ {
		Fscan(in, &a[i])
	}
	blockSize := int(math.Round(math.Pow(float64(n), 2.0/3)))
	qs, ms := []query{}, []modify{}
	for ; q > 0; q-- {
		if Fscan(in, &op); op == 1 {
			var l, r, k int
			Fscan(in, &l, &r, &k)
			qs = append(qs, query{l / blockSize, (r + 1) / blockSize, l, r + 1, k, len(ms), len(qs)})
		} else {
			var pos, val int
			Fscan(in, &pos, &val)
			ms = append(ms, modify{pos, val})
		}
	}
	sort.Slice(qs, func(i, j int) bool {
		a, b := qs[i], qs[j]
		if a.lb != b.lb {
			return a.lb < b.lb
		}
		if a.rb != b.rb {
			return a.rb < b.rb
		}
		if a.rb&1 == 0 {
			return a.t < b.t
		}
		return a.t > b.t
	})

	const mx int = 1e5
	var cnt, scnt, st [mx + 1]int
	for i := 1; i <= mx; i++ {
		st[i] = mx
	}
	l, r, now := 1, 1, 0
	add := func(val int) {
		cnt[val]++
		st[cnt[val]]--
		scnt[st[cnt[val]]] = cnt[val]
	}
	del := func(val int) {
		c := cnt[val]
		cnt[val]--
		i := st[c]
		st[c]++
		scnt[i] = cnt[val]
	}
	ans := make([]int, len(qs))
	for _, q := range qs {
		for ; r < q.r; r++ {
			add(a[r])
		}
		for ; l < q.l; l++ {
			del(a[l])
		}
		for l > q.l {
			l--
			add(a[l])
		}
		for r > q.r {
			r--
			del(a[r])
		}
		for ; now < q.t; now++ {
			m := ms[now]
			p, v := m.pos, m.val
			if q.l <= p && p < q.r {
				del(a[p])
				add(v)
			}
			a[p], ms[now].val = v, a[p]
		}
		for now > q.t {
			now--
			m := ms[now]
			p, v := m.pos, m.val
			if q.l <= p && p < q.r {
				del(a[p])
				add(v)
			}
			a[p], ms[now].val = v, a[p]
		}
		minDif := int(1e9)
		for i := st[1]; i+q.k <= mx; {
			c := scnt[i]
			if dif := scnt[i+q.k-1] - c; dif < minDif {
				minDif = dif
			}
			i = st[c+1]
		}
		if minDif == 1e9 {
			minDif = -1
		}
		ans[q.qid] = minDif
	}
	for _, v := range ans {
		Fprintln(out, v)
	}
}

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

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1476G(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	type query struct{ lb, rb, l, r, k, t, qid int }
	type modify struct{ pos, val int }

	var n, q, op int
	Fscan(in, &n, &q)
	a := make([]int, n+1)
	for i := 1; i <= n; i++ {
		Fscan(in, &a[i])
	}
	blockSize := int(math.Round(math.Pow(float64(n), 2.0/3)))
	qs, ms := []query{}, []modify{}
	for ; q > 0; q-- {
		if Fscan(in, &op); op == 1 {
			var l, r, k int
			Fscan(in, &l, &r, &k)
			qs = append(qs, query{l / blockSize, (r + 1) / blockSize, l, r + 1, k, len(ms), len(qs)})
		} else {
			var pos, val int
			Fscan(in, &pos, &val)
			ms = append(ms, modify{pos, val})
		}
	}
	sort.Slice(qs, func(i, j int) bool {
		a, b := qs[i], qs[j]
		if a.lb != b.lb {
			return a.lb < b.lb
		}
		if a.rb != b.rb {
			return a.rb < b.rb
		}
		if a.rb&1 == 0 {
			return a.t < b.t
		}
		return a.t > b.t
	})

	const mx int = 1e5
	var cnt, scnt, st [mx + 1]int
	for i := 1; i <= mx; i++ {
		st[i] = mx
	}
	l, r, now := 1, 1, 0
	add := func(val int) {
		cnt[val]++
		st[cnt[val]]--
		scnt[st[cnt[val]]] = cnt[val]
	}
	del := func(val int) {
		c := cnt[val]
		cnt[val]--
		i := st[c]
		st[c]++
		scnt[i] = cnt[val]
	}
	timeSlip := func(l, r int) {
		m := ms[now]
		p, v := m.pos, m.val
		if l <= p && p < r {
			del(a[p])
			add(v)
		}
		a[p], ms[now].val = v, a[p]
	}
	ans := make([]int, len(qs))
	for _, q := range qs {
		for ; r < q.r; r++ {
			add(a[r])
		}
		for ; l < q.l; l++ {
			del(a[l])
		}
		for l > q.l {
			l--
			add(a[l])
		}
		for r > q.r {
			r--
			del(a[r])
		}
		for ; now < q.t; now++ {
			timeSlip(q.l, q.r)
		}
		for now > q.t {
			now--
			timeSlip(q.l, q.r)
		}
		minDif := int(1e9)
		for i := st[1]; i+q.k <= mx; {
			c := scnt[i]
			if dif := scnt[i+q.k-1] - c; dif < minDif {
				minDif = dif
			}
			i = st[c+1]
		}
		if minDif == 1e9 {
			minDif = -1
		}
		ans[q.qid] = minDif
	}
	for _, v := range ans {
		Fprintln(out, v)
	}
}

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

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1476G(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	type query struct{ lb, rb, l, r, k, t, qid int }
	type modify struct{ pos, val int }

	var n, q, op int
	Fscan(in, &n, &q)
	a := make([]int, n+1)
	for i := 1; i <= n; i++ {
		Fscan(in, &a[i])
	}
	blockSize := int(math.Round(math.Pow(float64(n), 2.0/3)))
	qs := []query{}
	ms := []modify{}
	for ; q > 0; q-- {
		if Fscan(in, &op); op == 1 {
			var l, r, k int
			Fscan(in, &l, &r, &k)
			qs = append(qs, query{l / blockSize, (r + 1) / blockSize, l, r + 1, k, len(ms), len(qs)})
		} else {
			var pos, val int
			Fscan(in, &pos, &val)
			ms = append(ms, modify{pos, val})
		}
	}
	sort.Slice(qs, func(i, j int) bool {
		a, b := qs[i], qs[j]
		if a.lb != b.lb {
			return a.lb < b.lb
		}
		if a.rb != b.rb {
			return a.rb < b.rb
		}
		if a.rb&1 == 0 {
			return a.t < b.t
		}
		return a.t > b.t
	})

	const mx int = 1e5
	var cnt, scnt, st [mx + 1]int
	for i := 0; i <= mx; i++ {
		scnt[i] = i
		st[i] = mx
	}
	st[0] = 0
	l, r, now := 1, 1, 0
	move := func(val, delta int) {
		if delta > 0 {
			cnt[val]++
			st[cnt[val]]--
			scnt[st[cnt[val]]] = cnt[val]
		} else {
			c := cnt[val]
			cnt[val]--
			i := st[c]
			st[c]++
			scnt[i] = cnt[val]
		}
	}
	timeSlip := func(l, r int) {
		m := ms[now]
		p, v := m.pos, m.val
		if l <= p && p < r {
			move(a[p], -1)
			move(v, 1)
		}
		a[p], ms[now].val = v, a[p]
	}
	ans := make([]int, len(qs))
	for _, q := range qs {
		for ; r < q.r; r++ {
			move(a[r], 1)
		}
		for ; l < q.l; l++ {
			move(a[l], -1)
		}
		for l > q.l {
			l--
			move(a[l], 1)
		}
		for r > q.r {
			r--
			move(a[r], -1)
		}
		for ; now < q.t; now++ {
			timeSlip(q.l, q.r)
		}
		for now > q.t {
			now--
			timeSlip(q.l, q.r)
		}
		res := int(1e9)
		for i := st[1]; i+q.k <= mx; {
			c := scnt[i]
			res = min(res, scnt[i+q.k-1]-c)
			i = st[c+1]
		}
		if res == 1e9 {
			res = -1
		}
		ans[q.qid] = res
	}
	for _, v := range ans {
		Fprintln(out, v)
	}
}

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

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

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	n, m := readTwoNums(reader)
	A := readNNums(reader, n)

	Q := make([][]int, m)
	for i := 0; i < m; i++ {
		s, _ := reader.ReadBytes('\n')
		if s[0] == '1' {
			Q[i] = readNNums2(s, 4)
		} else {
			Q[i] = readNNums2(s, 3)
		}
	}

	res := solve(A, Q)

	var buf bytes.Buffer

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

	fmt.Print(buf.String())
}

func readNNums2(buf []byte, n int) []int {
	res := make([]int, n)
	var pos int
	for i := 0; i < n; i++ {
		pos = readInt(buf, pos, &res[i]) + 1
	}
	return res
}

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
}

const BLK_SIZE = 2000
const N = 100013

func solve(A []int, Q [][]int) []int {
	q := make([]Query, 0, len(Q))
	upd := make([]Update, 0, len(Q))

	for i := 0; i < len(Q); i++ {
		if Q[i][0] == 1 {
			l, r, k := Q[i][1], Q[i][2], Q[i][3]
			q = append(q, Query{len(upd), l - 1, r - 1, k, len(q)})
		} else {
			p, x := Q[i][1], Q[i][2]
			p--
			upd = append(upd, Update{p, A[p], x})
			A[p] = x
		}
	}

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

	for i := len(upd) - 1; i >= 0; i-- {
		A[upd[i][0]] = upd[i][1]
	}

	cnt := make([]int, N)
	ord := make([]int, N)
	bounds := make([]*Pair, N)
	for i := 0; i < N; i++ {
		bounds[i] = &Pair{N, 0}
	}
	bounds[0] = &Pair{0, N - 1}

	add := func(x int) {
		c := cnt[x]
		ord[bounds[c].first]++
		bounds[c+1].second = bounds[c].first
		if bounds[c+1].first == N {
			bounds[c+1].first = bounds[c].first
		}
		if bounds[c].first == bounds[c].second {
			bounds[c].first = N - 1
		}
		bounds[c].first++
		cnt[x]++
	}

	rem := func(x int) {
		c := cnt[x]
		ord[bounds[c].second]--

		if bounds[c-1].first == N {
			bounds[c-1].second = bounds[c].second
		}
		bounds[c-1].first = bounds[c].second
		if bounds[c].first == bounds[c].second {
			bounds[c].first = N
		}
		bounds[c].second--
		cnt[x]--
	}

	var L, T int
	R := -1

	apply := func(i, fl int) {
		p := upd[i][0]
		x := upd[i][fl+1]
		if L <= p && p <= R {
			rem(A[p])
			add(x)
		}
		A[p] = x
	}

	res := make([]int, len(q))

	for _, cur := range q {
		t, l, r, k := cur.t, cur.l, cur.r, cur.k
		for T < t {
			apply(T, 1)
			T++
		}
		for T > t {
			T--
			apply(T, 0)
		}
		for R < r {
			R++
			add(A[R])
		}
		for L > l {
			L--
			add(A[L])
		}
		for R > r {
			rem(A[R])
			R--
		}
		for L < l {
			rem(A[L])
			L++
		}

		ans := N
		for i, j, sum := 0, 0, 0; i < N && ord[i] > 0; i = bounds[ord[i]].second + 1 {
			for j < N && ord[j] > 0 && sum < k {
				sum += bounds[ord[j]].second - bounds[ord[j]].first + 1
				j = bounds[ord[j]].second + 1
			}
			if sum >= k {
				ans = min(ans, ord[i]-ord[j-1])
			}
			sum -= bounds[ord[i]].second - bounds[ord[i]].first + 1
		}
		if ans == N {
			res[cur.i] = -1
		} else {
			res[cur.i] = ans
		}
	}

	return res
}

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

type Query struct {
	t, l, r, k, i int
}

func (a Query) Less(b Query) bool {
	if a.t/BLK_SIZE != b.t/BLK_SIZE {
		return a.t < b.t
	}

	if a.l/BLK_SIZE != b.l/BLK_SIZE {
		return a.l < b.l
	}

	if (a.l/BLK_SIZE)&1 == 1 {
		return a.r < b.r
	}
	return a.r > b.r
}

type Pair struct {
	first, second int
}

type Update [3]int

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	n, m := readTwoNums(reader)
	A := readNNums(reader, n)

	Q := make([][]int, m)
	for i := 0; i < m; i++ {
		s, _ := reader.ReadBytes('\n')
		if s[0] == '1' {
			Q[i] = readNNums2(s, 4)
		} else {
			Q[i] = readNNums2(s, 3)
		}
	}

	res := solve(A, Q)

	var buf bytes.Buffer

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

	fmt.Print(buf.String())
}

func readNNums2(buf []byte, n int) []int {
	res := make([]int, n)
	var pos int
	for i := 0; i < n; i++ {
		pos = readInt(buf, pos, &res[i]) + 1
	}
	return res
}

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
}

const BLK_SIZE = 500
const N = 100013

func solve(A []int, Q [][]int) []int {
	q := make([]Query, 0, len(Q))
	upd := make([]Update, 0, len(Q))

	for i := 0; i < len(Q); i++ {
		tp := Q[i][0]
		if tp == 1 {
			l, r, k := Q[i][1], Q[i][2], Q[i][3]
			q = append(q, Query{len(upd), l - 1, r - 1, k, len(q)})
		} else {
			p, x := Q[i][1], Q[i][2]
			p--
			upd = append(upd, Update{p, A[p], x})
			A[p] = x
		}
	}

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

	cnt := make([]int, N)
	ord := make([]int, N)
	bounds := make([]*Pair, N)
	for i := 0; i < N; i++ {
		bounds[i] = &Pair{N, 0}
	}
	bounds[0] = &Pair{0, N - 1}

	add := func(x int) {
		c := cnt[x]
		ord[bounds[c].first]++
		bounds[c+1].second = bounds[c].first
		if bounds[c+1].first == N {
			bounds[c+1].first = bounds[c].first
		}
		if bounds[c].first == bounds[c].second {
			bounds[c].first = N - 1
		}
		bounds[c].first++
		cnt[x]++
	}

	rem := func(x int) {
		c := cnt[x]
		ord[bounds[c].second]--

		if bounds[c-1].first == N {
			bounds[c-1].second = bounds[c].second
		}
		bounds[c-1].first = bounds[c].second
		if bounds[c].first == bounds[c].second {
			bounds[c].first = N
		}
		bounds[c].second--
		cnt[x]--
	}

	var L, T int
	R := -1

	apply := func(i, fl int) {
		p := upd[i][0]
		x := upd[i][fl+1]
		if L <= p && p <= R {
			rem(A[p])
			add(x)
		}
		A[p] = x
	}

	res := make([]int, len(q))

	for _, cur := range q {
		t, l, r, k := cur.t, cur.l, cur.r, cur.k
		for T < t {
			apply(T, 1)
			T++
		}
		for T > t {
			T--
			apply(T, 0)
		}
		for R < r {
			R++
			add(A[R])
		}
		for L > l {
			L--
			add(A[L])
		}
		for R > r {
			rem(A[R])
			R--
		}
		for L < l {
			rem(A[L])
			L++
		}

		ans := N
		for i, j, sum := 0, 0, 0; i < N && ord[i] > 0; i = bounds[ord[i]].second + 1 {
			for j < N && ord[j] > 0 && sum < k {
				sum += bounds[ord[j]].second - bounds[ord[j]].first + 1
				j = bounds[ord[j]].second + 1
			}
			if sum >= k {
				ans = min(ans, ord[i]-ord[j-1])
			}
			sum -= bounds[ord[i]].second - bounds[ord[i]].first + 1
		}
		if ans == N {
			res[cur.i] = -1
		} else {
			res[cur.i] = ans
		}
	}

	return res
}

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

type Query struct {
	t, l, r, k, i int
}

func (a Query) Less(b Query) bool {
	if a.t/BLK_SIZE != b.t/BLK_SIZE {
		return a.t < b.t
	}

	if a.l/BLK_SIZE != b.l/BLK_SIZE {
		return a.l < b.l
	}

	if (a.l/BLK_SIZE)&1 == 1 {
		return a.r < b.r
	}
	return a.r > b.r
}

type Pair struct {
	first, second int
}

type Update [3]int


/*
URL:
https://codeforces.com/contest/1364/problem/B
*/

package main

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

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

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

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

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

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

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

const (
	// General purpose
	MOD          = 1000000000 + 7
	ALPHABET_NUM = 26
	INF_INT64    = math.MaxInt64
	INF_BIT60    = 1 << 60
	INF_INT32    = math.MaxInt32
	INF_BIT30    = 1 << 30
	NIL          = -1

	// for dijkstra, prim, and so on
	WHITE = 0
	GRAY  = 1
	BLACK = 2
)

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

var (
	t int

	n int
	P []int
)

func main() {
	t = ReadInt()

	for i := 0; i < t; i++ {
		n = ReadInt()
		P = ReadIntSlice(n)

		solve()
	}
}

func solve() {
	F := make([]bool, n)
	D := make([]int, 0)
	for i := 1; i < n; i++ {
		d := P[i] - P[i-1]
		D = append(D, d)
	}

	F[0], F[n-1] = true, true
	for i := 1; i < n-1; i++ {
		if (D[i-1] > 0 && D[i] > 0) || (D[i-1] < 0 && D[i] < 0) {
			F[i] = false
		} else {
			F[i] = true
		}
	}

	answers := []int{}
	for i := 0; i < n; i++ {
		if F[i] {
			answers = append(answers, P[i])
		}
	}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	return res
}

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

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

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

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

	return string(res)
}

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

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

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

	return string(res)
}

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

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

package main

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

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 := readNum(reader)
		P := readNNums(reader, n)
		res := solve(n, P)
		fmt.Println(len(res))
		var buf bytes.Buffer
		for i := 0; i < len(res); i++ {
			buf.WriteString(strconv.Itoa(res[i]))
			buf.WriteByte(' ')
		}
		fmt.Println(buf.String())
	}
}

func solve(n int, P []int) []int {
	// find moutain peek
	var res = make([]int, 0, n)
	res = append(res, P[0])
	for i := 0; i < n-1; {
		j := i + 1
		if P[j] > P[i] {
			for j < n && P[j] > P[j-1] {
				j++
			}

		} else {
			for j < n && P[j] < P[j-1] {
				j++
			}
		}
		// j - 1 is the peek
		j--

		if i == j {
			break
		}

		res = append(res, P[j])
		i = j
	}
	return res
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	t := int64(1)
	fmt.Fscanf(in, "%d\n", &t)
	for tt := int64(0); tt < t; tt++ {
		n := 0
		fmt.Fscanf(in, "%d\n", &n)
		a := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscanf(in, "%d", &a[i])
		}
		fmt.Fscanf(in, "\n")
		ans := []int{a[0]}
		for i := 1; i < n-1; i++ {
			if !same(a[i]-a[i-1], a[i+1]-a[i]) {
				ans = append(ans, a[i])
			}
		}
		ans = append(ans, a[n-1])
		fmt.Fprintf(out, "%d\n", len(ans))
		for i := 0; i < len(ans)-1; i++ {
			fmt.Fprintf(out, "%d ", ans[i])
		}
		fmt.Fprintf(out, "%d\n", ans[len(ans)-1])
	}
	return
}

func same(a, b int) bool {
	if a > 0 && b > 0 {
		return true
	}
	if a < 0 && b < 0 {
		return true
	}
	return false
}

package main

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

func main() {
	var cases int
	fmt.Scanf("%d\n", &cases)
	reader := bufio.NewReader(os.Stdin)
	for i := 0; i < cases; i++ {
		line := readLine(reader)
		n, _ := strconv.Atoi(string(line))
		line = readLine(reader)
		pns := strings.Split(string(line), " ")
		pn := make([]int, n)
		flag := make([]bool, n)
		for i := 0; i < n; i++ {
			pn[i], _ = strconv.Atoi(pns[i])
		}
		del := 0
		for i := 1; i < n-1; i++ {
			if (pn[i] >= pn[i-1] && pn[i+1] >= pn[i]) ||
				(pn[i] <= pn[i-1] && pn[i+1] <= pn[i]) {
				flag[i] = true
				del++
			}
		}
		fmt.Println(n - del)
		for i := 0; i<n;i++ {
			if !flag[i] {
				fmt.Printf("%d ", pn[i])
			}
		}
		fmt.Println()
	}
}

func readLine(reader *bufio.Reader) []byte {
	result := make([]byte, 0)
	for {
		s, isPrefix, err := reader.ReadLine()
		if err != nil {
			fmt.Printf("error=%+v\n", err)
			break
		}
		result = append(result, s...)
		if !isPrefix {
			break
		}
	}
	return result
}

package main

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

var nTest, n int
var a [100000]int

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	fmt.Fscan(in, &nTest)

	for t := 0; t < nTest; t++ {
		fmt.Fscan(in, &n)

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

		res := []int{a[0]}
		for i := 1; i < n-1; i++ {
			if !((a[i-1] < a[i] && a[i] < a[i+1]) || (a[i-1] > a[i] && a[i] > a[i+1])) {
				res = append(res, a[i])
			}
		}

		res = append(res, a[n-1])
		fmt.Fprintln(out, len(res))
		for _, v := range res {
			fmt.Fprintf(out, "%d ", v)
		}
		fmt.Fprintln(out)
	}
	out.Flush()
}

package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
}

func Next() string {
	sc.Scan()
	return sc.Text()
}

func NextInt() int {
	i, err := strconv.Atoi(Next())
	if err != nil {
		panic(err)
	}
	return i
}

func main() {
	tt := NextInt()
	for ; tt > 0; tt-- {
		n := NextInt()
		a := make([]int, n)
		var ret []int
		for i := 0; i < n; i++ {
			a[i] = NextInt()
		}
		j := 0
		for i := 1; i < n; i++ {
			if a[i] > a[j] {
				ret = append(ret, a[j])
				for ; i + 1 < n && a[i] < a[i + 1]; i++ {}
				j = i
			} else {
				ret = append(ret, a[j])
				for ; i + 1 < n && a[i] > a[i + 1]; i++ {}
				j = i
			}
		}
		ret = append(ret, a[j])
		fmt.Println(len(ret))
		for i := 0; i < len(ret); i++ {
			fmt.Print(ret[i], " ")
		}
		fmt.Println()
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t, now int
	fmt.Fscanf(in, "%d\n", &t)
	for now < t {
		now++
		var n int
		fmt.Fscanf(in, "%d %d\n", &n)
		var num int
		mas := make([]int, n+1)
		ans := make([]int, 0, n+1)
		for i := 0; i < n; i++ {
			fmt.Fscanf(in, "%d", &mas[i])
		}
		fmt.Fscanf(in, "\n")
		num = mas[0]
		help := make([]int, n)
		for i := 0; i < n - 1; i++ {
			if mas[i] < mas[i + 1]{
				help[i] = 1
			}
		}
		ind := help[0]
		num = mas[0]
		var flag bool
		for i := 0; i < n;i++{
			if help[i] != ind{
				ans = append(ans, num)
				ind = 1 - ind
				num = mas[i]
				if i == n-1{
					flag=true
				}
			}
		}
		if len(ans) == 0{
			ans = append(ans, mas[0])
			ans = append(ans, mas[n-1])
		} else {
			ans = append(ans, num)
			if !flag{
				ans = append(ans, mas[n - 1])
			}

		}
		fmt.Fprintln(out, len(ans))
		for _, i := range ans{
			fmt.Fprintf(out, "%v ", i)
		}
		fmt.Fprintln(out)
	}
	return
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t, now int
	fmt.Fscanf(in, "%d\n", &t)
	for now < t {
		now++
		var n int
		fmt.Fscanf(in, "%d %d\n", &n)
		var num int
		mas := make([]int, n+1)
		ans := make([]int, 0, n+1)
		for i := 0; i < n; i++ {
			fmt.Fscanf(in, "%d", &mas[i])
		}
		fmt.Fscanf(in, "\n")
		num = mas[0]
		help := make([]int, n)
		for i := 0; i < n - 1; i++ {
			if mas[i] < mas[i + 1]{
				help[i] = 1
			}
		}
		ind := help[0]
		num = mas[0]
		for i := 0; i < n;i++{
			if help[i] != ind{
				ans = append(ans, num)
				ind = 1 - ind
				num = mas[i]
			}
		}
		if len(ans) == 0{
			ans = append(ans, mas[0])
			ans = append(ans, mas[n-1])
		} else {
			ans = append(ans, num)
			ans = append(ans, mas[n - 1])
		}
		fmt.Fprintln(out, len(ans))
		for _, i := range ans{
			fmt.Fprintf(out, "%v ", i)
		}
		fmt.Fprintln(out)
	}
	return
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t, now int
	fmt.Fscanf(in, "%d\n", &t)
	for now < t {
		now++
		var n int
		fmt.Fscanf(in, "%d %d\n", &n)
		var num int
		mas := make([]int, n+1)
		ans := make([]int, 0, n+1)
		for i := 0; i < n; i++ {
			fmt.Fscanf(in, "%d", &mas[i])
		}
		fmt.Fscanf(in, "\n")
		num = mas[0]
		help := make([]int, n)
		for i := 0; i < n - 1; i++ {
			if mas[i] < mas[i + 1]{
				help[i] = 1
			}
		}
		ind := help[0]
		num = help[0]
		for i := 0; i < n;i++{
			if help[i] != ind{
				ans = append(ans, num)
				ind = 1 - ind
				num = mas[i]
			}
		}
		if len(ans) == 0{
			ans = append(ans, mas[0])
			ans = append(ans, mas[n-1])
		} else {
			ans = append(ans, num)
			ans = append(ans, mas[n - 1])
		}
		fmt.Fprintln(out, len(ans))
		for _, i := range ans{
			fmt.Fprintf(out, "%v ", i)
		}
		fmt.Fprintln(out)
	}
	return
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t, now int
	fmt.Fscanf(in, "%d\n", &t)
	for now < t {
		now++
		var n int
		fmt.Fscanf(in, "%d %d\n", &n)
		var num int
		mas := make([]int, n+1)
		ans := make([]int, 0, n+1)
		for i := 0; i < n; i++ {
			fmt.Fscanf(in, "%d", &mas[i])
		}
		fmt.Fscanf(in, "\n")
		num = mas[0]
		help := make([]int, n)
		for i := 1; i < n; i++ {
			if mas[i] > mas[i - 1]{
				help[i] = 1
			}
		}
		ind := help[0]
		for i := 0; i < n;i++{
			if help[i] != ind{
				ans = append(ans, num)
				ind = 1 - ind
				num = mas[i]
			} else {
				num = mas[i]
			}
		}
		if len(ans) == 0{
			ans = append(ans, mas[0])
		}
		ans = append(ans, mas[n-1])
		fmt.Fprintln(out, len(ans))
		for _, i := range ans{
			fmt.Fprintf(out,"%v ", i)
		}
		fmt.Fprintln(out)
	}
	return
}


package main

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

func main() {
	defer _w.Flush()
	t := ReadInt()
	for i := 0; i < t; i++ {
		n, m, r, c := ReadInt(), ReadInt(), ReadInt(), ReadInt()
		println(solve(n, m, r, c))
	}
}

func solve(n, m, r, c int) int {
	return Max((n-r), (r-1)) + Max((m-c), (c-1))
}

func Max(xs ...int) int {
	max := xs[0]
	for _, x := range xs[1:] {
		if max < x {
			max = x
		}
	}
	return max
}

var _r, _w = bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)

func print(a ...interface{})            { fmt.Fprint(_w, a...) }
func printf(f string, a ...interface{}) { fmt.Fprintf(_w, f, a...) }
func println(a ...interface{})          { fmt.Fprintln(_w, a...) }
func printInts(a ...int)                { s := fmt.Sprint(a); println(s[1 : len(s)-1]) }
func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(_r, a...); err != nil {
		panic(err)
	}
}
func ReadString() (s string) { Scan(&s); return }
func ReadInt() (i int)       { Scan(&i); return }
func ReadInts(n int) (a []int) {
	for i := 0; i < n; i++ {
		a = append(a, ReadInt())
	}
	return
}
func ReadInt64() (i int64) { Scan(&i); return }
func ReadInt64s(n int) (a []int64) {
	for i := 0; i < n; i++ {
		a = append(a, ReadInt64())
	}
	return
}

package main

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

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

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

	var t, n, m, r, c int
	fmt.Fscan(in, &t)

	for ; t > 0; t-- {
		fmt.Fscan(in, &n, &m, &r, &c)
		fmt.Println(max(n-r, r-1) + max(m-c, c-1))
	}
}

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

package main

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

var (
	t int

	n, m, r, c int64
)

func main() {
	defer stdout.Flush()

	t = readi()
	for tc := 0; tc < t; tc++ {
		n, m, r, c = readll4()
		r--
		c--

		solve()
	}
}

func solve() {
	R := Max(r, n-1-r)
	C := Max(c, m-1-c)

	ans := R + C

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	return s
}

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

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

	if e == 0 {
		return 1
	}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	return string(res)
}

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

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

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

	return string(res)
}

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

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

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

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

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

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

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

	return res
}


package main

import (
    "fmt"
)

func main() {
    var x, y, z, r int64
    fmt.Scan(&x, &y, &z)
    if (x + y) / z > x / z + y / z {
        if x % z >= y % z {
            r = z - x % z
        } else {
            r = z - y % z
        }
    }
    fmt.Println((x + y) / z, r)
}

// Author: sighduck
// URL: https://codeforces.com/contest/1181/problem/A

package main

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

type Solution struct {
	Coconuts int64
	Transfer int64
}

func Solve(x, y, z int64) Solution {
	a, b := x%z, y%z
	if a+b < z {
		return Solution{Coconuts: x/z + y/z, Transfer: 0}
	}
	if a >= b {
		return Solution{Coconuts: (x + y) / z, Transfer: z - a}
	}
	return Solution{Coconuts: (x + y) / z, Transfer: z - b}
}

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

	var x, y, z int64
	fmt.Fscanf(reader, "%d %d %d\n", &x, &y, &z)

	solution := Solve(x, y, z)
	fmt.Fprintf(writer, "%d %d\n", solution.Coconuts, solution.Transfer)
}

package main

import (
	"fmt"
	"os"
)

func main() {
	var a, b, c uint64

	fmt.Fscanln(os.Stdin, &a, &b, &c)

	r := uint64(0)
	s := false
	if b%c >= c-a%c {
		r = c - a%c
		s = true
	}

	if a%c >= c-b%c {
		if !s {
			r = c - b%c
		} else {
			if c-b%c < r {
				r = c - b%c
			}
		}
	}

	fmt.Fprint(os.Stdout, (a+b)/c, r)
}

/*
go run a.go
582426543750017 789023129080207 4395672028302
312 2197836014149
*/
package main

import (
	"bufio"
	"fmt"
	"math"
	"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 main() {
	defer writer.Flush()
	var a, b, c int64
	var r float64
	scanf("%d %d %d\n", &a, &b, &c)
	if (a+b)/c > a/c+b/c {
		x := c*((a/c)+1) - a
		y := c*((b/c)+1) - b
		r = math.Min(float64(x), float64(y))
	}
	printf("%d %d\n", (a+b)/c, int64(r))
}

/*
go run a.go
*/
package main

import (
	"bufio"
	"fmt"
	"math"
	"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 main() {
	defer writer.Flush()
	var a, b, c int64
	var r float64
	scanf("%d %d %d\n", &a, &b, &c)
	//fmt.Println(int((a + b) / c))
	// fmt.Println(int(a / c))
	// fmt.Println(int(b / c))
	//fmt.Println(int((a+b)/c) > (int(a/c) + int(b/c)))
	if (a+b)/c > a/c+b/c {
		x := c*((a/c)+1) - a
		y := c*((b/c)+1) - b
		// fmt.Println(c*float64((int(b/c)+1)) - b)
		r = math.Min(float64(x), float64(y))
	}
	printf("%d %d\n", int((a+b)/c), int(r))
}

/*
go run a.go
*/
package main

import (
	"bufio"
	"fmt"
	"math"
	"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 main() {
	defer writer.Flush()
	var a, b, c, r float64
	scanf("%f %f %f\n", &a, &b, &c)
	//fmt.Println(int((a + b) / c))
	// fmt.Println(int(a / c))
	// fmt.Println(int(b / c))
	//fmt.Println(int((a+b)/c) > (int(a/c) + int(b/c)))
	if int((a+b)/c) > (int(a/c) + int(b/c)) {
		// fmt.Println(c*float64((int(a/c)+1)) - a)
		// fmt.Println(c*float64((int(b/c)+1)) - b)
		r = math.Min(c*float64((int(a/c)+1))-a, c*float64((int(b/c)+1))-b)
	}
	printf("%d %d\n", int((a+b)/c), int(r))
}

/*
go run a.go
582426543750017 789023129080207 4395672028302
312 2197836014149
*/
package main

import (
	"bufio"
	"fmt"
	"math"
	"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 main() {
	defer writer.Flush()
	var a, b, c int64
	var r float64
	scanf("%d %d %d\n", &a, &b, &c)
	if (a+b)/c > a/c+b/c {
		x := c*((a/c)+1) - a
		y := c*((b/c)+1) - b
		r = math.Min(float64(x), float64(y))
	}
	printf("%d %d\n", int((a+b)/c), int(r))
}

/*
go run a.go
*/
package main

import (
	"bufio"
	"fmt"
	"math"
	"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 main() {
	defer writer.Flush()
	var a, b, c float64
	scanf("%f %f %f\n", &a, &b, &c)
	printf("%d %d\n", int((a+b)/c), int(math.Min(math.Mod(a, c), math.Mod(b, c))))
}

package main

import (
    "fmt"
    "math"
)

func main() {
    var x, y, z int64
    fmt.Scan(&x, &y, &z)
    fmt.Println((x + y) % z, int(math.Min(float64(x % z), float64(y % z))))
}

package main

import (
    "fmt"
    "math"
)

func main() {
    var x, y, z, r int64
    fmt.Scan(&x, &y, &z)
    if (x + y) / z > x / z + y / z {
        r = z - int64(math.Max(float64(x % z), float64(y % z)))
    }
    fmt.Println((x + y) / z, r)
}

package main

import (
    "fmt"
    "math"
)

func main() {
    var x, y, z int64
    fmt.Scan(&x, &y, &z)
    fmt.Println((x + y) / z, int(math.Min(float64(x % z), float64(y % z))))
}


package main

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

func I(i ...interface{}) error {
	_, err := fmt.Fscan(r, i...)
	return err
}

func O(o ...interface{}) {
	fmt.Fprint(w, o...)
}

var (
	r *bufio.Reader
	w *bufio.Writer
)

func init() {
	if f, err := os.Open("in.goC"); err == nil {
		r = bufio.NewReader(f)
	} else {
		r = bufio.NewReader(os.Stdin)
	}
	w = bufio.NewWriter(os.Stdout)
}

type Int int64

func main() {
	defer w.Flush()
	var a, b string
	for I(&a, &b) == nil {
		solve(a, b)
	}
}

func solve(a, b string) {
	p, s := make([]int, len(a)+1), make([]int, len(a)+1)
	aa, bb := reverse(a), reverse(b)
	for i := 1; i < len(p); i++ {
		if p[i-1] < len(b) && a[i-1] == b[p[i-1]] {
			p[i] = p[i-1] + 1
		} else {
			p[i] = p[i-1]
		}
		if s[i-1] < len(b) && aa[i-1] == bb[s[i-1]] {
			s[i] = s[i-1] + 1
		} else {
			s[i] = s[i-1]
		}
	}
	var l, r, max int
	for i := 0; i < len(p); i++ {
		o, oo := p[i], s[len(p)-1-i]
		if o+oo > max && o+oo <= len(a) {
			l, r = o, oo
			max = o + oo
		}
	}
	var ans string
	if max == 0 {
		ans = "-"
	} else if max > len(b) {
		ans = b
	} else {
		ans = b[:l] + reverse(bb[:r])
	}
	O(ans, "\n")
}

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

package main

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

func I(i ...interface{}) error {
	_, err := fmt.Fscan(r, i...)
	return err
}

func O(o ...interface{}) {
	fmt.Fprint(w, o...)
}

var (
	r *bufio.Reader
	w *bufio.Writer
)

func init() {
	if f, err := os.Open("in.goC"); err == nil {
		r = bufio.NewReader(f)
	} else {
		r = bufio.NewReader(os.Stdin)
	}
	w = bufio.NewWriter(os.Stdout)
}

func main() {
	defer w.Flush()
	var a, b string
	for I(&a, &b) == nil {
		solve(a, b)
	}
}

func solve(a, b string) {
	i, j := 0, 0
	var p, s []int
	p = append(p, -1e9)
	for i < len(b) && j < len(a) {
		if b[i] == a[j] {
			p = append(p, j)
			i++
		}
		j++
	}
	i, j = len(b)-1, len(a)-1
	s = append(s, 1e9)
	for i >= 0 && j >= 0 {
		if b[i] == a[j] {
			s = append(s, j)
			i--
		}
		j--
	}
	i, j = 0, len(p)-1
	var ans string
	var max int
	for j >= 0 && i < len(s) {
		if len(b) > i+j-1 && p[j] < s[i] {
			if i+j > max {
				max = i + j
				ans = b[:j]
				if i > 0 {
					ans = b[:j] + b[len(b)-i:]
				}
			}
			i++
			continue
		}
		j--
	}
	if len(ans) == 0 {
		ans = "-"
	}
	O(ans, "\n")
}

package main

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

func I(i ...interface{}) error {
	_, err := fmt.Fscan(r, i...)
	return err
}

func O(o ...interface{}) {
	fmt.Fprint(w, o...)
}

var (
	r *bufio.Reader
	w *bufio.Writer
)

func init() {
	if f, err := os.Open("in.goC"); err == nil {
		r = bufio.NewReader(f)
	} else {
		r = bufio.NewReader(os.Stdin)
	}
	w = bufio.NewWriter(os.Stdout)
}

func main() {
	defer w.Flush()
	var a, b string
	for I(&a, &b) == nil {
		solve(a, b)
	}
}

func solve(a, b string) {
	i, j := 0, 0
	var p, s []int
	for i < len(b) && j < len(a) {
		if b[i] == a[j] {
			p = append(p, i)
			i++
		}
		j++
	}
	i, j = len(b)-1, len(a)-1
	for i >= 0 && j >= 0 {
		if b[i] == a[j] {
			s = append(s, i)
			i--
		}
		j--
	}
	var ans string
	if len(p) == 0 && len(s) == 0 {
		ans = "-"
	} else if len(p) == 0 {
		ans = b[s[len(s)-1]:]
	} else if len(s) == 0 {
		o := 1
		if p[len(p)-1] == len(b)-1 {
			o--
		}
		ans = b[:p[len(p)-1]+o]
	} else {
		o := 1
		if p[len(p)-1] == len(b)-1 || p[len(p)-1] == len(b)-1-s[len(s)-1] {
			o--
		}
		r := b[:p[len(p)-1]+o]
		l := b[s[len(s)-1]:]
		if len(r)+len(l) <= len(a) {
			ans = r + l
		} else {
			diff := len(r) + len(l) - len(a)
			if diff == len(r) {
				ans = l
			} else if diff == len(l) {
				ans = r
			} else if diff > len(r) {
				diff -= len(r)
				ans = l[diff:]
			} else if diff > len(l) {
				diff -= len(l)
				ans = r[:len(r)-diff]
			} else {
				ans = r[:len(r)-diff] + l
			}
		}
	}
	O(ans, "\n")
}


package main

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

type vec struct{ x, y int }

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

// github.com/EndlessCheng/codeforces-go
func CF1359F(_r io.Reader, out io.Writer) {
	min := func(a, b float64) float64 {
		if a < b {
			return a
		}
		return b
	}
	max := func(a, b float64) float64 {
		if a > b {
			return a
		}
		return b
	}
	type car struct {
		p, d    vec
		s, norm float64
	}

	in := bufio.NewReader(_r)
	var n int
	Fscan(in, &n)
	cs := make([]car, n)
	for i := range cs {
		Fscan(in, &cs[i].p.x, &cs[i].p.y, &cs[i].d.x, &cs[i].d.y, &cs[i].s)
		cs[i].norm = cs[i].d.len()
	}

	ans := 1e99
	for i, p := range cs {
		for j := i + 1; j < n; j++ {
			q := cs[j]
			u := p.p.sub(q.p)
			if det := p.d.det(q.d); det != 0 {
				t1 := q.d.det(u)
				t2 := p.d.det(u)
				if det > 0 && t1 >= 0 && t2 >= 0 || det < 0 && t1 <= 0 && t2 <= 0 {
					ans = min(ans, max(p.norm*float64(t1)/(p.s*float64(det)), q.norm*float64(t2)/(q.s*float64(det))))
				}
			} else {
				if u.det(p.d) != 0 {
					continue
				}
				l := math.Hypot(float64(u.x), float64(u.y))
				if p.d.dot(q.d) > 0 {
					if u.dot(q.d) >= 0 {
						ans = min(ans, l/q.s)
					} else {
						ans = min(ans, l/p.s)
					}
				} else {
					if u.dot(q.d) > 0 {
						ans = min(ans, l/(p.s+q.s))
					}
				}
			}
		}
	}
	if ans == 1e99 {
		Fprint(out, "No show :(")
	} else {
		Fprintf(out, "%.8f", ans)
	}
}

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

package main

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

type vec struct{ x, y int }

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

type car struct {
	p, d vec
	s, l float64
}

// github.com/EndlessCheng/codeforces-go
func main() {
	in := bufio.NewReader(os.Stdin)
	var n int
	Fscan(in, &n)
	c := make([]car, n)
	for i := range c {
		Fscan(in, &c[i].p.x, &c[i].p.y, &c[i].d.x, &c[i].d.y, &c[i].s)
		c[i].l = c[i].d.len()
	}

	ans := 1e99
	for i, p := range c {
		for j := i + 1; j < n; j++ {
			q := c[j]
			u := p.p.sub(q.p)
			if d := p.d.det(q.d); d != 0 {
				if t1, t2 := q.d.det(u), p.d.det(u); d > 0 && t1 >= 0 && t2 >= 0 || d < 0 && t1 <= 0 && t2 <= 0 {
					ans = Min(ans, Max(p.l*float64(t1)/(p.s*float64(d)), q.l*float64(t2)/(q.s*float64(d))))
				}
				continue
			}
			if u.det(p.d) != 0 {
				continue
			}
			l := u.len()
			if p.d.dot(q.d) > 0 {
				if u.dot(q.d) >= 0 {
					ans = Min(ans, l/q.s)
				} else {
					ans = Min(ans, l/p.s)
				}
			} else if u.dot(q.d) > 0 {
				ans = Min(ans, l/(p.s+q.s))
			}
		}
	}
	if ans == 1e99 {
		Print("No show :(")
	} else {
		Printf("%.8f", ans)
	}
}

package main

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

type vec struct{ x, y int }

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

type car struct {
	p, d vec
	s, l float64
}

// github.com/EndlessCheng/codeforces-go
func main() {
	Min := func(a, b float64) float64 {
		if a < b {
			return a
		}
		return b
	}
	Max := func(a, b float64) float64 {
		if a > b {
			return a
		}
		return b
	}
	Abs := func(x float64) float64 {
		if x < 0 {
			return -x
		}
		return x
	}

	in := bufio.NewReader(os.Stdin)
	var n int
	Fscan(in, &n)
	c := make([]car, n)
	for i := range c {
		Fscan(in, &c[i].p.x, &c[i].p.y, &c[i].d.x, &c[i].d.y, &c[i].s)
		c[i].l = c[i].d.len()
	}

	ans := 1e99
	s := 0.
	for i, p := range c {
		for j := i + 1; j < n; j++ {
			q := c[j]
			u := p.p.sub(q.p)
			if d := p.d.det(q.d); d != 0 {
				if d1, d2 := q.d.det(u), p.d.det(u); d > 0 && d1 >= 0 && d2 >= 0 || d < 0 && d1 <= 0 && d2 <= 0 {
					ans = Min(ans, Max(p.l*float64(d1)/(p.s*float64(d)), q.l*float64(d2)/(q.s*float64(d))))
				}
				continue
			}
			if u.det(p.d) != 0 {
				continue
			}
			if p.d.dot(q.d) > 0 {
				if u.dot(q.d) > 0 {
					s = q.s
				} else {
					s = p.s
				}
			} else if u.dot(q.d) > 0 {
				s = p.s + q.s
			} else {
				continue
			}
			if p.d.x != 0 {
				ans = Min(ans, Abs(p.l*float64(u.x)/(s*float64(p.d.x))))
			} else {
				ans = Min(ans, Abs(p.l*float64(u.y)/(s*float64(p.d.y))))
			}
		}
	}
	if ans == 1e99 {
		Print("No show :(")
	} else {
		Printf("%.8f", ans)
	}
}

package main

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

type vec struct{ x, y int }

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

type car struct {
	p, d vec
	s, l float64
}

// github.com/EndlessCheng/codeforces-go
func main() {
	min := func(a, b float64) float64 {
		if a < b {
			return a
		}
		return b
	}
	max := func(a, b float64) float64 {
		if a > b {
			return a
		}
		return b
	}

	in := bufio.NewReader(os.Stdin)
	var n int
	Fscan(in, &n)
	c := make([]car, n)
	for i := range c {
		Fscan(in, &c[i].p.x, &c[i].p.y, &c[i].d.x, &c[i].d.y, &c[i].s)
		c[i].l = c[i].d.len()
	}

	ans := 1e99
	for i, p := range c {
		for j := i + 1; j < n; j++ {
			q := c[j]
			u := p.p.sub(q.p)
			if d := p.d.det(q.d); d != 0 {
				if t1, t2 := q.d.det(u), p.d.det(u); d > 0 && t1 >= 0 && t2 >= 0 || d < 0 && t1 <= 0 && t2 <= 0 {
					ans = min(ans, max(p.l*float64(t1)/(p.s*float64(d)), q.l*float64(t2)/(q.s*float64(d))))
				}
				continue
			}
			if u.det(p.d) != 0 {
				continue
			}
			l := math.Sqrt(float64(u.x*u.x + u.y*u.y))
			if p.d.dot(q.d) > 0 {
				if u.dot(q.d) >= 0 {
					ans = min(ans, l/q.s)
				} else {
					ans = min(ans, l/p.s)
				}
			} else if u.dot(q.d) > 0 {
				ans = min(ans, l/(p.s+q.s))
			}
		}
	}
	if ans == 1e99 {
		Print("No show :(")
	} else {
		Printf("%.8f", ans)
	}
}

package main

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

type vec struct{ x, y int }
type vecF struct{ x, y float64 }

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

// github.com/EndlessCheng/codeforces-go
func CF1359F(_r io.Reader, out io.Writer) {
	min := func(a, b float64) float64 {
		if a < b {
			return a
		}
		return b
	}
	max := func(a, b float64) float64 {
		if a > b {
			return a
		}
		return b
	}
	type car struct {
		p, d vec
		s    float64
	}

	in := bufio.NewReader(_r)
	var n int
	Fscan(in, &n)
	cs := make([]car, n)
	for i := range cs {
		Fscan(in, &cs[i].p.x, &cs[i].p.y, &cs[i].d.x, &cs[i].d.y, &cs[i].s)
	}

	ans := 1e99
	for i, p := range cs {
		for j := i + 1; j < n; j++ {
			q := cs[j]
			u := p.p.sub(q.p)
			if det := p.d.det(q.d); det != 0 {
				t1 := q.d.det(u)
				t2 := p.d.det(u)
				if det > 0 && t1 >= 0 && t2 >= 0 || det < 0 && t1 <= 0 && t2 <= 0 {
					l1, l2 := p.d.mul(float64(t1)/float64(det)).len(), q.d.mul(float64(t2)/float64(det)).len()
					ans = min(ans, max(l1/p.s, l2/q.s))
				}
			} else {
				l := math.Hypot(float64(u.x), float64(u.y))
				if p.d.dot(q.d) > 0 {
					if u.dot(q.d) >= 0 {
						ans = min(ans, l/q.s)
					} else {
						ans = min(ans, l/p.s)
					}
				} else {
					if u.dot(q.d) > 0 {
						ans = min(ans, l/(p.s+q.s))
					}
				}
			}
		}
	}
	if ans == 1e99 {
		Fprint(out, "No show :(")
	} else {
		Fprintf(out, "%.8f", ans)
	}
}

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