package main

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

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

func main() {
	defer writer.Flush()
	var n int
	scanf("%d\n", &n)
	var first,second []int
	if n%2 == 0{
		printf("NO")
	} else{
		//first = append(first,1)
		flag := false
		count := 0
		for i:=2;i<=n*2;i++{
			if flag{
				first = append(first,i)
			}else{
				second = append(second,i)
			}
			count++
			if count ==2{
				count = 0
				flag = !flag
			}
		}
		printf("YES\n")
		printf("1")
		for _,v:= range first{
			printf(" %d",v)
		}
		for _,v:= range second{
			printf(" %d",v)
		}
	}
}

package main

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

func main() {
	defer Flush()

	n := readll()
	a := make([]int64, 2*n)
	for i := int64(0); i < n; i++ {
		v1 := 2*i + 1
		v2 := 2*i + 2
		a[i] = v1
		a[i+n] = v2
	}

	for i := int64(1); i < n; i += 2 {
		a[i], a[i+n] = a[i+n], a[i]
	}

	b := append(a[:2*n:2*n], a...)
	var i, sum int64
	for i = int64(0); i < n; i++ {
		sum += b[i]
	}

	minv := sum
	maxv := sum
	for i = n; i < int64(len(b)); i++ {
		sum += b[i] - b[i-n]
		minv = minll(minv, sum)
		maxv = maxll(minv, sum)
		if 1 < maxv-minv {
			println("NO")
			return
		}
	}
	println("YES")
	sp := ""
	for _, v := range a {
		printf("%s%d", sp, v)
		sp = " "
	}
	println()
}

// -----------------------------------------------------------------------------

// IO helper functions

// Returns next token from input.  It must be initialized by SetInput()
// before the first call.
var nextToken func() ([]byte, error)
var nextLine func() ([]byte, error)

// Holds a buffer for output.  It must be initialized by SetOutput().
// All IO fucntions (read*() and [e]print*()) should write to OutputWriter
// instead of this.
var OutputBuffer *bufio.Writer

// Holds an io.Writer.  It must be initialized by SetOutput()
var OutputWriter io.Writer

// Set IO functions for interactive input/output.
func SetInteractive(w io.Writer, r io.Reader) {
	SetUnbefferedInput(r)
	OutputBuffer = nil
	OutputWriter = w
}

// Setup OutputBuffer and OutputWriter.
func SetOutput(w io.Writer) {
	OutputBuffer = bufio.NewWriter(w)
	OutputWriter = OutputBuffer
}

// Flushes OutputBuffer
func Flush() {
	if OutputBuffer != nil {
		OutputBuffer.Flush()
	}
}

// Returns true if c is a white space
func IsSpace(c byte) bool {
	switch c {
	case '\t', '\n', '\v', '\f', '\r', ' ':
		return true
	}
	return false
}

func IsNewLine(c byte) bool {
	switch c {
	case '\n', '\r':
		return true
	}
	return false
}

// Setup nextToken with input buffer.
func SetInput(r io.Reader) {
	buf := new(bytes.Buffer)
	var b []byte

	var i int
	rest := func() ([]byte, error) {
		for i < len(b) && IsSpace(b[i]) {
			i++
		}
		if i == len(b) {
			return nil, io.ErrUnexpectedEOF
		}
		j := i
		for i < len(b) && !IsSpace(b[i]) {
			i++
		}
		return b[j:i], nil
	}
	initial := func() ([]byte, error) {
		io.Copy(buf, r)
		b = buf.Bytes()
		nextToken = rest
		return rest()
	}
	nextToken = initial

	restLn := func() ([]byte, error) {
		for i < len(b) && IsNewLine(b[i]) {
			i++
		}
		if i == len(b) {
			return nil, io.ErrUnexpectedEOF
		}
		j := i
		for i < len(b) && !IsNewLine(b[i]) {
			i++
		}
		return b[j:i], nil
	}

	initialLn := func() ([]byte, error) {
		io.Copy(buf, r)
		b = buf.Bytes()
		nextLine = restLn
		return restLn()
	}
	nextLine = initialLn
}

// Setup nextToken without input buffer.
func SetUnbefferedInput(r io.Reader) {
	buf := bufio.NewReader(r)
	var b []byte

	var i int
	nextToken = func() ([]byte, error) {
		var err error
		if i == len(b) {
			b, err = buf.ReadBytes('\n')
			if err != nil {
				return nil, err
			}
			i = 0
			j := len(b) - 1
			for 0 <= j && IsSpace(b[j]) {
				j--
			}
			b = b[0 : j+1]
		}
		for i < len(b) && IsSpace(b[i]) {
			i++
		}
		j := i
		for i < len(b) && !IsSpace(b[i]) {
			i++
		}
		if i == j {
			return nil, io.ErrUnexpectedEOF
		}
		return b[j:i], nil
	}
}

// -----------------------------------------------------------------------------

// IO functions

// Reads next token and return it as []byte
func readb() []byte {
	b, err := nextToken()
	if err != nil {
		panic(err)
	}
	return b[:len(b):len(b)]
}

// Reads next token and return it as string
func reads() string {
	return string(readb())
}

// Read next line as []byte.  Trailing '\n' will not be included.
// See also comments on readb()
func readbln() []byte {
	b, err := nextLine()
	if err != nil {
		panic(err)
	}
	return b[:len(b):len(b)]
}

// Read next line as string
func readsln() string {
	return string(readbln())
}

// Reads next token and return it as int64
func readll() int64 {
	i, err := strconv.ParseInt(reads(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// Reads next token and return it as int
func readi() int {
	return int(readll())
}

// Reads next token and return it as float64
func readf() float64 {
	f, err := strconv.ParseFloat(reads(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// Write args to OutputWriter with the format f
func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(OutputWriter, f, args...)
}

// Write args to OutputWriter without format
func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(OutputWriter, args...)
}

// Write args to stderr with the format f
func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

// Write args to stderr without format
func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

// -----------------------------------------------------------------------------

// Utilities

func sumSlice(a []int) int {
	var res int
	for _, v := range a {
		res += v
	}
	return res
}

func sumSlicell(a []int64) int64 {
	var res int64
	for _, v := range a {
		res += v
	}
	return res
}

func readInts(N int) (int, []int) {
	if N == 0 {
		N = readi()
	}
	a := make([]int, N)
	for i := range a {
		a[i] = readi()
	}
	return N, a
}

func readIntsll(N int) (int, []int64) {
	if N == 0 {
		N = readi()
	}
	a := make([]int64, N)
	for i := range a {
		a[i] = readll()
	}
	return N, a
}

// reverse slice in place
func reverse(a []int) {
	for i, j := 0, len(a)-1; i < j; i, j = i+1, j-1 {
		a[i], a[j] = a[j], a[i]
	}
}

// areverse: allocating reverse
func areverse(a []int) []int {
	b := make([]int, len(a))
	for i := range a {
		b[i] = a[len(a)-i-1]
	}
	return b
}

// -----------------------------------------------------------------------------

// Simple math functions

const (
	// big prime
	INF  = 1000000007
	INF2 = 1000000009
	INF3 = 998244353
)

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

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

func minf(a, b float64) float64 {
	if a < b {
		return a
	}
	return b
}

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

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

func maxf(a, b float64) float64 {
	if a < b {
		return b
	}
	return a
}

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

func absll(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func absf(a float64) float64 {
	if a < 0 {
		return -a
	}
	return a
}

// egcd(a, b) returns d, x, y:
//   d is gcd(a,b)
//   x, y are  integers that satisfy ax + by = d
func egcd(a, b int) (int, int, int) {
	if b == 0 {
		return a, 1, 0
	}
	d, x, y := egcd(b, a%b)
	return d, y, x - a/b*y
}

func egcdll(a, b int64) (int64, int64, int64) {
	if b == 0 {
		return a, 1, 0
	}
	d, x, y := egcdll(b, a%b)
	return d, y, x - a/b*y
}

func gcd(a, b int) int {
	d, _, _ := egcd(a, b)
	return d
}

func gcdll(a, b int64) int64 {
	d, _, _ := egcdll(a, b)
	return d
}

// set up IO functions
func init() {
	// for non-interactive
	SetInput(os.Stdin)
	SetOutput(os.Stdout)

	// Enable below when interactive.  Its ok to leave above intact.
	// SetInteractive(os.Stdout, os.Stdin)
}

package main

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

func main() {
	var q int64

	scr := bufio.NewReader(os.Stdin)
	// ocr := bufio.NewWriter(os.Stdout)

	fmt.Fscanln(scr, &q)

	a := make([]int64, 2*q)

	if q%2 == 0 {
		fmt.Println("NO")
	} else {
		for i := int64(0); i < 2*q; i = i + 2 {
			a[i] = i + 1
		}
		n := int64(1)
		for i := q; i < 2*q; i = i + 2 {
			a[i] = 2 * n
			n++
		}
		for i := int64(1); i < q; i = i + 2 {
			a[i] = 2 * n
			n++
		}

		fmt.Println("YES")

		for _, y := range a {
			fmt.Printf("%d ", y)
		}
	}

}

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	var n int
	fmt.Fscan(reader, &n)
	if n%2 == 0 {
		fmt.Fprintf(writer, "NO\n")
		return
	}
	fmt.Fprint(writer, "YES\n")
	var ans = make([]int, 2*n)
	var now = 1
	for i := 0; i < n; i++ {
		if i%2 == 0 {
			ans[i] = now
			ans[i+n] = now + 1
		} else {
			ans[i] = now + 1
			ans[i+n] = now
		}
		now += 2
	}
	for i := 0; i < 2*n; i++ {
		fmt.Fprintf(writer, "%v ", ans[i])
	}
	fmt.Fprintf(writer, "\n")
}

// Author: sighduck
// URL: https://codeforces.com/contest/1206/problem/C

package main

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

type Solution struct {
	exists      bool
	arrangement []int
}

func Solve(n int) Solution {
	if n%2 == 0 {
		return Solution{exists: false, arrangement: []int{}}
	}
	arrangement := make([]int, 2*n)
	for i := 0; i < n; i++ {
		if i%2 == 0 {
			arrangement[i] = 2*n - i
			arrangement[i+n] = 2*n - i - 1
		} else {
			arrangement[i] = i
			arrangement[i+n] = i + 1
		}
	}
	return Solution{exists: true, arrangement: arrangement}
}

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

	var n int
	fmt.Fscanf(reader, "%d\n", &n)
	solution := Solve(n)
	if solution.exists {
		fmt.Fprintf(writer, "YES\n")
		for _, elem := range solution.arrangement {
			fmt.Fprintf(writer, "%d ", elem)
		}
		fmt.Fprintf(writer, "\n")
	} else {
		fmt.Fprintf(writer, "NO\n")
	}
}


package main

import (
	"fmt"
)

func main() {
	var t int
	var n, B, x, y int64
	fmt.Scanf("%d\n", &t)
	for ; t >= 1; t-- {
		fmt.Scanf("%d %d %d %d\n", &n, &B, &x, &y)
		var ans int64
		var a int64
		var i int64
		for i = 1; i <= n; i++ {
			if x > -y && a+x <= B {
				a += x
			} else if -y > x && a-y <= B {
				a -= y
			} else if -y < 0 {
				a -= y
			} else if x < 0 {
				a += x
			}
			ans += a
			// fmt.Println(i, a)
		}
		fmt.Println(ans)
	}
}

package main

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

func main() {

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

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

	for t > 0 {
		n, B, x, y := 0, 0, 0, 0
		fmt.Fscan(reader, &n, &B, &x, &y)

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

		fmt.Fprintln(writter, solve(n, B, x, y))

		t--
	}

	//fmt.Println(commonServices.Solve(4, 1, 7, 3))
}

func solve(n, B, x, y int) int64 {

	result := int64(0)

	array := make([]int64, n+1)
	array[0] = 0

	for i := 1; i <= n; i++ {

		next := array[i-1] + int64(x)
		if next > int64(B) {
			next -= int64(x + y)
		}

		array[i] = next
		result += int64(next)

	}

	//fmt.Println(array)

	return result

}

package main
import "fmt"
import "os"
import "bufio"
//import "math"
//import "sort"
var (
	input = bufio.NewReader(os.Stdin)
	output = bufio.NewWriter(os.Stdout)
)
func main() {
	defer output.Flush()
	count := 0
	fmt.Fscan(input,&count)
	for count>0 {
		count --
		n := 0
		B := 0
		x := 0
		y := 0
		fmt.Fscan(input,&n)
		fmt.Fscan(input,&B)
		fmt.Fscan(input,&x)
		fmt.Fscan(input,&y)
		s := int64(0)
		val := 0
		for i:=1;i<=n;i++ {
			if val+x<=B {
				val += x
				s += int64(val)
			} else {
				val -= y
				s += int64(val)
			}
		}
		fmt.Fprintln(output,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,B,x,y int
		fmt.Fscan(in,&n,&B,&x,&y)
		var list []int= []int{0}
		for j:=1;j<=n;j++{
			if list[j-1]+x <= B {
				list= append(list,list[j-1]+x)
			} else {
				list= append(list,list[j-1]-y)
			}
		}
		count:=0
		for j:=0;j<len(list);j++{
			count+=list[j]
		}
		fmt.Fprintln(out,count)
	}
}

package main

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

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

	var buf bytes.Buffer

	tc := readNum(reader)

	for tc > 0 {
		tc--
		line := readNNums(reader, 4)

		res := solve(line[0], line[1], line[2], line[3])

		buf.WriteString(fmt.Sprintf("%d\n", res))
	}

	fmt.Print(buf.String())
}

func readString(reader *bufio.Reader) string {
	s, _ := reader.ReadString('\n')
	for i := 0; i < len(s); i++ {
		if s[i] == '\n' {
			return s[:i]
		}
	}
	return s
}

func normalize(s string) string {

	for i := len(s); i > 0; i-- {
		if s[i-1] >= 'a' && s[i-1] <= 'z' {
			return s[:i]
		}
	}
	return ""
}

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

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

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

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

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

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

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

	return i
}

func solve(n int, B int, x int, y int) int64 {

	var sum int64

	cur := 0

	for i := 1; i <= n; i++ {
		if cur+x <= B {
			cur += x
		} else {
			cur -= y
		}
		sum += int64(cur)
	}

	return sum
}

package main

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

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

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

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

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

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

/**
Run solve the problem CF1657B
Date: 5/04/22
User: pepradere
URL: https://codeforces.com/problemset/problem/1657/B
Problem: CF1657B
**/
func (in *CF1657B) Run() {
	for t := in.NextInt(); t > 0; t-- {
		n, B, x, y := in.NextInt(), in.NextInt(), in.NextInt(), in.NextInt()
		last := 0
		sum := int64(0)
		for i := 0; i < n; i++ {
			if last+x <= B {
				last += x
				sum += int64(last)
			} else {
				last -= y
				sum += int64(last)
			}
		}
		fmt.Println(sum)
	}
}

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

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

package main

import (
	"fmt"
)

func main(){
	var t, n, B, x, y int64
	fmt.Scanf("%d ", &t)
	for ;t>0;t-=1{
		fmt.Scanf("%d %d %d %d ", &n, &B, &x, &y)
		sum, tmp := int64(0), int64(0)
		for i:=int64(0);i<n;i+=1{
			if tmp + x <= B{
				tmp += x
			}else{
				tmp -= y
			}
			sum += tmp
		}
		fmt.Printf("%d\n", sum)
	}
}

package main

import "fmt"

func solve() {
    var n uint32
    var b, x, y int64
    fmt.Scan(&n)
    fmt.Scan(&b)
    fmt.Scan(&x)
    fmt.Scan(&y)
    cur := int64(0)
    sum := int64(0)
    for i := uint32(0); i < n; i++ {
        if cur + x <= b {
            cur += x
        } else {
            cur -= y
        }
        sum += cur
    }
    fmt.Println(sum)
}

func main() {
    var t uint32
    fmt.Scan(&t)
    for i := uint32(0); i < t; i++ {
        solve()
    }
}

package main

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

var T, n int
var B, x, y int64

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

	Fscan(in, &T)
	for t := 0; t < T; t++ {
		Fscan(in, &n, &B, &x, &y)
		var last, ans int64
		last, ans = 0, 0
		for i := 1; i <= n; i++ {
			if last + x <= B {
				last = last + x
			} else {
				last = last - y
			}
			ans += last
		}
		Fprintln(out, ans)
	}
}

package main

import "fmt"

func main() {
	var T, n, B, x, y, a, sum int64
	fmt.Scan(&T)
	for ; T > 0; T -- {
		fmt.Scan(&n, &B, &x, &y);
		a, sum = 0, 0
		for ; n > 0; n -- {
			if a + x <= B {
				a += x
			} else {
				a -= y
			}
			sum += a
		}
		fmt.Println(sum)
	}
}

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-- {
		var n, b, x, y int64
		fmt.Fscan(in, &n, &b, &x, &y)

		var sum, val int64
		for i := int64(0); i < n; i++ {
			if t := val + x; t <= b {
				val = t
			} else {
				val -= y
			}
			sum += val
		}

		fmt.Fprintln(out, sum)
	}
}

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
		var b, x, y int64
		fmt.Fscan(in, &n, &b, &x, &y)

		var z, sum int64
		for i := 0; i < n; i++ {
			if z+x <= b {
				z += x
			} else {
				z -= y
			}

			sum += z
		}
		fmt.Fprintln(out, sum)
	}
}

package main

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

/*
1
4 3 8 3
---
5 = -3 -3 2 -1
*/

//goland:noinspection GoUnhandledErrorResult
func solve() {
	var n, b, x, y int64
	scanf("%d %d %d %d\n", &n, &b, &x, &y)

	sum := int64(0)

	a := int64(0)

	for i := int64(0); i < n; i++ {
		if a+x <= b {
			a += x
		} else {
			a -= y
		}

		sum += a
	}

	fmt.Fprintln(writer, sum)
}

//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 {
	minNumIdx := 0
	for i, num := range nums {
		if num < nums[minNumIdx] {
			minNumIdx = i
		}
	}

	return nums[minNumIdx]
}

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

	return nums[maxNumIdx]
}

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

	return maxNumIdx
}

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

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

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

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

	return true
}

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

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

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

	num = abs(num)

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

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

package main

import "fmt"

func main() {
	k := 0
	fmt.Scanf("%d\n", &k)
	for k > 0 {
		k--
		var n = 0
		var B, x, y int64
		n, B, x, y = 0, 0, 0, 0
		fmt.Scanf("%d %d %d %d\n", &n, &B, &x, &y)
		var s, c int64
		for i := 1; i < n+1; i++ {
			if c+x <= B {
				c += x
			} else {
				c -= y
			}
			s += c
		}
		fmt.Println(s)
	}
}

package main

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

const (
	INF = 3e5 + 10
)

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

	var t, n int
	var b, x, y int64
	Fscan(in, &t)

	for k := 0; k < t; k++ {
		Fscan(in, &n, &b, &x, &y)
		ans := int64(0)
		cur := int64(0)
		for i := 1; i <= n; i++ {
			if cur+x <= b {
				cur += x
			} else {
				cur -= y
			}
			ans += cur
		}

		Fprintln(out, ans)
	}
}

package main

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

func gcd(a, b int) int {
	if a%b == 0 {
		return b
	}
	return gcd(b, a%b)
}

const mod = 998244353

// 1 2 3 4
func main() {
	in, out := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)
	defer out.Flush()
	t := 1
	fmt.Fscan(in, &t)

	for ii := 0; ii < t; ii++ {
		var n, b, x, y int64
		fmt.Fscan(in, &n, &b, &x, &y)
		last := int64(0)
		sum := int64(0)
		for i := int64(1); i <= n; i++ {
			if last+x > b {
				last -= y
			} else {
				last += x
			}
			sum += last
		}
		fmt.Fprintln(out, sum)
	}
}

package main

import "fmt"

func main() {
	k := 0
	fmt.Scanf("%d\n", &k)
	for k > 0 {
		k--
		var n = 0
		var B, x, y uint64
		n, B, x, y = 0, 0, 0, 0
		fmt.Scanf("%d %d %d %d\n", &n, &B, &x, &y)
		var s, c uint64
		for i := 1; i < n+1; i++ {
			if c+x <= B {
				c += x
			} else {
				c -= y
			}
			s += c
		}
		fmt.Println(s)
	}
}

package main

import "fmt"

func main() {
	k := 0
	fmt.Scanf("%d\n", &k)
	for k > 0 {
		k--
		n, B, x, y := 0, 0, 0, 0
		fmt.Scanf("%d %d %d %d\n", &n, &B, &x, &y)
		s := 0
		c := 0
		for i := 1; i < n+1; i++ {
			if c+x <= B {
				c += x
			} else {
				c -= y
			}
			s += c
		}
		fmt.Println(s)
	}
}

package main

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

const (
	INF = 3e5 + 10
)

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

	var t, n int
	var b, x, y int64
	Fscan(in, &t)

	for k := 0; k < t; k++ {
		Fscan(in, &n, &b, &x, &y)
		y += x
		dp := make([][]int64, 2)
		dp[0] = make([]int64, n+1)
		dp[1] = make([]int64, n+1)

		dp[0][0] = 0
		if x <= b {
			dp[1][0] = x
		} else {
			dp[1][0] = -y * int64(n)
		}
		dp[1][1] = x - y
		ans := -y * int64(n)
		for i := 2; i <= n; i++ {

			for j := 0; j <= i; j++ {
				dp[i%2][j] = -y * int64(n)
			}

			for j := 0; j < i; j++ {
				val := int64(i)*x - int64(j)*y

				if val <= b {
					dp[i%2][j] = max(dp[i%2][j], dp[(i-1)%2][j]+val)
				}
				if val-y <= b {
					dp[i%2][j+1] = max(dp[i%2][j+1], dp[(i-1)%2][j]+val-y)
				}
			}
		}
		for j := 0; j < n; j++ {
			ans = max(ans, dp[n%2][j])
		}
		Fprintln(out, ans)
	}
}

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

}

package main

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

const (
	INF = 3e5 + 10
)

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

	var t, n int
	var b, x, y int64
	Fscan(in, &t)

	for k := 0; k < t; k++ {
		Fscan(in, &n, &b, &x, &y)
		y += x
		dp := make([][]int64, 2)
		dp[0] = make([]int64, n+1)
		dp[1] = make([]int64, n+1)

		dp[0][0] = 0
		if x <= b {
			dp[1][0] = x
		} else {
			dp[1][0] = -y * int64(n)
		}
		dp[1][1] = x - y
		ans := -y * int64(n)
		for i := 2; i <= n; i++ {

			for j := 0; j <= i; j++ {
				dp[i%2][j] = -y * int64(n)
			}

			for j := 0; j < i; j++ {
				val := int64(i)*x - int64(j)*y

				if val <= b {
					dp[i%2][j] = max(dp[i%2][j], dp[(i-1)%2][j]+val)
				}
				if val-y <= b {
					dp[i%2][j+1] = max(dp[i%2][j+1], dp[(i-1)%2][j]+val-y)
				}
				if i == n {
					ans = max(ans, dp[i%2][j])
				}
			}
		}
		Fprintln(out, ans)
	}
}

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

}

package main

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

func gcd(a, b int) int {
	if a%b == 0 {
		return b
	}
	return gcd(b, a%b)
}

const mod = 998244353

// 1 2 3 4
func main() {
	in, out := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)
	defer out.Flush()
	t := 1
	fmt.Fscan(in, &t)

	for ii := 0; ii < t; ii++ {
		var n, b, x, y int
		fmt.Fscan(in, &n, &b, &x, &y)
		last := 0
		sum := 0
		for i := 1; i <= n; i++ {
			if last+x > b {
				last -= y
			} else {
				last += x
			}
			sum += last
		}
		fmt.Fprintln(out, sum)
	}
}

package main

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

func main() {

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

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

	for t > 0 {
		n, B, x, y := 0, 0, 0, 0
		fmt.Fscan(reader, &n, &B, &x, &y)

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

		fmt.Fprintln(writter, solve(n, B, x, y))

		t--
	}

	//fmt.Println(commonServices.Solve(4, 1, 7, 3))
}

func solve(n, B, x, y int) int {

	result := 0

	array := make([]int, n+1)
	array[0] = 0

	for i := 1; i <= n; i++ {

		next := array[i-1] + x
		if next > B {
			next -= (x + y)
		}

		array[i] = next
		result += next

	}

	//fmt.Println(array)

	return result

}

package main
import "fmt"
import "os"
import "bufio"
//import "math"
//import "sort"
var (
	input = bufio.NewReader(os.Stdin)
	output = bufio.NewWriter(os.Stdout)
)
func main() {
	defer output.Flush()
	count := 0
	fmt.Fscan(input,&count)
	for count>0 {
		count --
		n := 0
		B := 0
		x := 0
		y := 0
		fmt.Fscan(input,&n)
		fmt.Fscan(input,&B)
		fmt.Fscan(input,&x)
		fmt.Fscan(input,&y)
		s := 0
		val := 0
		for i:=1;i<=n;i++ {
			if val+x<=B {
				val += x
				s += val
			} else {
				val -= y
				s += val
			}
		}
		fmt.Fprintln(output,s)
	}
}

package main

import (
	"fmt"
)

func main() {
	var t int
	fmt.Scanf("%d\n", &t)
	for ; t >= 1; t-- {
		var n, B, x, y int
		fmt.Scanf("%d %d %d %d\n", &n, &B, &x, &y)
		var ans int
		var a int
		for i := 1; i <= n; i++ {
			if x > -y && a+x <= B {
				a += x
			} else if -y > x && a-y <= B {
				a -= y
			} else if a-y <= B {
				a -= y
			} else if a+x <= B {
				a += x
			}
			ans += a
			// fmt.Println(i, a, ans)
		}
		fmt.Println(ans)
	}
}


/*
URL:
https://codeforces.com/contest/1430/problem/D
*/

package main

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

var (
	t int

	n int
	S []rune
)

func main() {
	defer stdout.Flush()

	t = readi()
	for tc := 0; tc < t; tc++ {
		n = readi()
		S = readrs()

		ans := solve()
		// printf("%d\n", ans)
		fmt.Println(ans)
	}
}

func solve() int {
	res := 0

	_, C := RunLengthEncoding(S)
	B := len(C)
	fp := 0 // 1文字消すポインタ
	sp := 0 // prefixを消すポインタ
	for sp < B {
		// まず最初に、fpは必ずspと同じかそれより後方に位置させる
		for fp < sp {
			fp++
		}

		// fpは2文字以上あるブロックまで移動させる
		for fp < B && C[fp] <= 1 {
			fp++
		}

		// 「1文字消す」に相当する操作
		if fp < B {
			// 2文字以上あるものがあればそれを消す
			C[fp]--
		} else {
			// しょうがないのでspの最後の1文字を消す
			sp++
		}

		// 1文字消せたら操作完了
		res++

		// prefixを消すに相当するポインタ移動
		sp++
	}

	return res
}

// RunLengthEncoding returns encoded slice of an input.
func RunLengthEncoding(S []rune) ([]rune, []int) {
	runes := []rune{}
	lengths := []int{}

	l := 0
	for i := 0; i < len(S); i++ {
		// 1文字目の場合保持
		if i == 0 {
			l = 1
			continue
		}

		if S[i-1] == S[i] {
			// 直前の文字と一致していればインクリメント
			l++
		} else {
			// 不一致のタイミングで追加し、長さをリセットする
			runes = append(runes, S[i-1])
			lengths = append(lengths, l)
			l = 1
		}
	}
	runes = append(runes, S[len(S)-1])
	lengths = append(lengths, l)

	return runes, lengths
}

// RunLengthDecoding decodes RLE results.
func RunLengthDecoding(S []rune, L []int) []rune {
	if len(S) != len(L) {
		panic("S, L are not RunLengthEncoding results")
	}

	res := []rune{}

	for i := 0; i < len(S); i++ {
		for j := 0; j < L[i]; j++ {
			res = append(res, S[i])
		}
	}

	return res
}

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

/********** 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
}

/********** 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 (
	"bufio"
	"fmt"
	"os"
)

var reader = bufio.NewReader(os.Stdin)

func main() {
	var t int
	fmt.Fscan(reader, &t)

	for i := 0; i < t; i++ {
		var n int
		fmt.Fscan(reader, &n)

		var s string
		fmt.Fscan(reader, &s)

		fmt.Println(steps(s))
	}

}

func steps(s string) int {
	front := len(s) - 1
	bank := 0
	turns := 0

	for front >= 0 {
		back := front
		for front >= 0 && s[front] == s[back] {
			front--
		}

		bank += back - front - 1
		turns++

		if bank == 0 && front < 0 {
			break
		}

		if bank > 0 {
			bank--
		} else {
			front--
		}
	}

	return turns
}

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

	return b
}

package main

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

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

var T, n int
var s string

func main() {
	for _, _ = fmt.Fscan(_r, &T); T > 0; T-- {
		_, _ = fmt.Fscan(_r, &n)
		_, _ = fmt.Fscan(_r, &s)
		var lens []int
		for i := 0; i < n; {
			st := i
			for ; i < n && s[i] == s[st]; i++ {
			}
			lens = append(lens, i-st)
		}

		ans := 0
		for i, p := 0, 0; i < len(lens); i++ {
			if p < i {
				p = i
			}
			for ; p < len(lens) && lens[p] == 1; p++ {
			}
			if p < len(lens) {
				lens[p]--
			} else {
				i++
			}
			ans++
		}
		_, _ = fmt.Fprintln(_w, ans)
		_ = _w.Flush()

	}
}

/*
URL:
https://codeforces.com/contest/1430/problem/D
*/

package main

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

var (
	t int

	n int
	S []rune
)

func main() {
	defer stdout.Flush()

	t = readi()
	for tc := 0; tc < t; tc++ {
		n = readi()
		S = readrs()

		ans := solve()
		printf("%d\n", ans)
	}
}

func solve() int {
	res := 0

	_, C := RunLengthEncoding(S)
	B := len(C)
	fp := 0 // 1文字消すポインタ
	sp := 0 // prefixを消すポインタ
	for sp < B {
		// まず最初に、fpは必ずspと同じかそれより後方に位置させる
		for fp < sp {
			fp++
		}

		// fpは2文字以上あるブロックまで移動させる
		for fp < B && C[fp] <= 1 {
			fp++
		}

		// 「1文字消す」に相当する操作
		if fp < B {
			// 2文字以上あるものがあればそれを消す
			C[fp]--
		} else {
			// しょうがないのでspの最後の1文字を消す
			sp++
		}

		// 1文字消せたら操作完了
		res++

		// prefixを消すに相当するポインタ移動
		sp++
	}

	return res
}

// RunLengthEncoding returns encoded slice of an input.
func RunLengthEncoding(S []rune) ([]rune, []int) {
	runes := []rune{}
	lengths := []int{}

	l := 0
	for i := 0; i < len(S); i++ {
		// 1文字目の場合保持
		if i == 0 {
			l = 1
			continue
		}

		if S[i-1] == S[i] {
			// 直前の文字と一致していればインクリメント
			l++
		} else {
			// 不一致のタイミングで追加し、長さをリセットする
			runes = append(runes, S[i-1])
			lengths = append(lengths, l)
			l = 1
		}
	}
	runes = append(runes, S[len(S)-1])
	lengths = append(lengths, l)

	return runes, lengths
}

// RunLengthDecoding decodes RLE results.
func RunLengthDecoding(S []rune, L []int) []rune {
	if len(S) != len(L) {
		panic("S, L are not RunLengthEncoding results")
	}

	res := []rune{}

	for i := 0; i < len(S); i++ {
		for j := 0; j < L[i]; j++ {
			res = append(res, S[i])
		}
	}

	return res
}

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

/********** 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
}

/********** 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 (
	"bufio"
	. "fmt"
	"io"
	"os"
)

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

	var T, n int
	var s string
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n, &s)
		c := []int{}
		for i := 0; i < n; {
			st := i
			for ; i < n && s[i] == s[st]; i++ {
			}
			c = append(c, i-st)
		}
		n = len(c)
		ans := 0
		for i, p := 0, 0; i < n; i++ {
			if p < i {
				p = i
			}
			for ; p < n && c[p] <= 1; p++ {
			}
			if p < n {
				c[p]--
			} else {
				i++
			}
			ans++
		}
		Fprintln(out, ans)
	}
}

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

package main

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

type node struct {
	lr       [2]*node
	priority uint
	key      int
	ids      []int
}

func (o *node) cmp(b int) int8 {
	switch {
	case b < o.key:
		return 0
	case b > o.key:
		return 1
	default:
		return -1
	}
}

func (o *node) rotate(d int8) *node {
	x := o.lr[d^1]
	o.lr[d^1] = x.lr[d]
	x.lr[d] = o
	return x
}

type treap struct {
	rd   uint
	root *node
}

func (t *treap) fastRand() uint {
	t.rd ^= t.rd << 13
	t.rd ^= t.rd >> 17
	t.rd ^= t.rd << 5
	return t.rd
}

func (t *treap) _put(o *node, key, i int) *node {
	if o == nil {
		return &node{priority: t.fastRand(), key: key, ids: []int{i}}
	}
	if d := o.cmp(key); d >= 0 {
		o.lr[d] = t._put(o.lr[d], key, i)
		if o.lr[d].priority > o.priority {
			o = o.rotate(d ^ 1)
		}
	} else {
		o.ids = append(o.ids, i)
	}
	return o
}

func (t *treap) put(key, i int) { t.root = t._put(t.root, key, i) }

func (t *treap) _delete(o *node, key int) *node {
	if o == nil {
		return nil
	}
	if d := o.cmp(key); d >= 0 {
		o.lr[d] = t._delete(o.lr[d], key)
	} else {
		if len(o.ids) > 1 {
			o.ids = o.ids[1:]
		} else {
			if o.lr[1] == nil {
				return o.lr[0]
			}
			if o.lr[0] == nil {
				return o.lr[1]
			}
			d = 0
			if o.lr[0].priority > o.lr[1].priority {
				d = 1
			}
			o = o.rotate(d)
			o.lr[d] = t._delete(o.lr[d], key)
		}
	}
	return o
}

func (t *treap) delete(key int) { t.root = t._delete(t.root, key) }

func (t *treap) get(key int) *node {
	for o := t.root; o != nil; {
		if d := o.cmp(key); d >= 0 {
			o = o.lr[d]
		} else {
			return o
		}
	}
	return nil
}

func (t *treap) max() (max *node) {
	for o := t.root; o != nil; o = o.lr[1] {
		max = o
	}
	return
}

func newTreap() *treap { return &treap{rd: 1} }

// 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(Case int) {
		var n int
		var s []byte
		Fscan(in, &n, &s)

		//t := newTreap()
		cnt := []int{}
		for i := 0; i < n; {
			st := i
			v := s[st]
			for i++; i < n && s[i] == v; i++ {
			}
			//t.put(i-st, len(cnt))
			cnt = append(cnt, i-st)
		}
n = len(cnt)
		ans := 0
		cur := 0
		next := 0
		next2 := 0
		for cur < n {
			if cnt[cur] > 1 {
				//t.delete(cnt[cur])
				cur++

			} else {
				cur++

				if next < cur {
					next = cur
				}
				if next2 < cur {
					next2=cur
				}

				for ; next < n && cnt[next] <= 2; next++ {
				}
				if next < n {
					cnt[next]--
				} else {

					for ; next2 < n && cnt[next2] != 2; next2++ {
					}
					if next2 < n {
						cnt[next2]--
					} else {
						cur++
					}

				}

				//mx := t.max()
				//if mx.key > 1 {
				//	mx.key--
				//	cnt[mx.ids[0]]--
				//} else {
				//	t.delete(cnt[cur])
				//	cur++
				//}
				//if cur < len(cnt) {
				//	t.delete(cnt[cur])
				//	cur++
				//}
			}
			if next < cur {
				next = cur
			}
			if next2 < cur {
				next2=cur
			}

			ans++
		}
		Fprintln(out, ans)
		return
	}

	var t int
	Fscan(in, &t)
	for Case := 1; Case <= t; Case++ {
		solve(Case)
	}
}

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

package main

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

type node struct {
	lr       [2]*node
	priority uint
	key      int
	ids []int
}

func (o *node) cmp(b int) int8 {
	switch {
	case b < o.key:
		return 0
	case b > o.key:
		return 1
	default:
		return -1
	}
}

func (o *node) rotate(d int8) *node {
	x := o.lr[d^1]
	o.lr[d^1] = x.lr[d]
	x.lr[d] = o
	return x
}

type treap struct {
	rd   uint
	root *node
}

func (t *treap) fastRand() uint {
	t.rd ^= t.rd << 13
	t.rd ^= t.rd >> 17
	t.rd ^= t.rd << 5
	return t.rd
}

func (t *treap) _put(o *node, key,i int) *node {
	if o == nil {
		return &node{priority: t.fastRand(), key: key, ids : []int{i}}
	}
	if d := o.cmp(key); d >= 0 {
		o.lr[d] = t._put(o.lr[d], key,i)
		if o.lr[d].priority > o.priority {
			o = o.rotate(d ^ 1)
		}
	} else {
		o.ids = append(o.ids, i)
	}
	return o
}

func (t *treap) put(key,i int) { t.root = t._put(t.root, key,i) }

func (t *treap) _delete(o *node, key int) *node {
	if o == nil {
		return nil
	}
	if d := o.cmp(key); d >= 0 {
		o.lr[d] = t._delete(o.lr[d], key)
	} else {
		if len(o.ids) > 1 {
			o.ids = o.ids[1:]
		} else {
			if o.lr[1] == nil {
				return o.lr[0]
			}
			if o.lr[0] == nil {
				return o.lr[1]
			}
			d = 0
			if o.lr[0].priority > o.lr[1].priority {
				d = 1
			}
			o = o.rotate(d)
			o.lr[d] = t._delete(o.lr[d], key)
		}
	}
	return o
}

func (t *treap) delete(key int) { t.root = t._delete(t.root, key) }

func (t *treap) get(key int) *node {
	for o := t.root; o != nil; {
		if d := o.cmp(key); d >= 0 {
			o = o.lr[d]
		} else {
			return o
		}
	}
	return nil
}

func (t *treap) max() (max *node) {
	for o := t.root; o != nil; o = o.lr[1] {
		max = o
	}
	return
}

func newTreap() *treap { return &treap{rd: 1} }

// 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(Case int) {
		var n int
		var s []byte
		Fscan(in, &n, &s)

		t := newTreap()
		cnt := []int{}
		for i := 0; i < n; {
			st := i
			v := s[st]
			for i++; i < n && s[i] == v; i++ {
			}
			t.put(i-st, len(cnt))
			cnt = append(cnt, i-st)
		}

		ans := 0
		cur := 0
		for cur < len(cnt) {
			if cnt[cur] > 1 {
				t.delete(cnt[cur])
				cur++
			} else {
				mx := t.max()
				if mx.key > 1 {
					mx.key--
					cnt[mx.ids[0]]--
				} else {
					t.delete(cnt[cur])
					cur++
				}
				if cur < len(cnt) {
					t.delete(cnt[cur])
					cur++
				}
			}

			ans++
		}
		Fprintln(out, ans)
		return
	}

	var t int
	Fscan(in, &t)
	for Case := 1; Case <= t; Case++ {
		solve(Case)
	}
}

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

package main

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

var reader = bufio.NewReader(os.Stdin)

func main() {
	var t int
	fmt.Fscan(reader, &t)

	for i := 0; i < t; i++ {
		var n int
		fmt.Fscan(reader, &n)

		var s string
		fmt.Fscan(reader, &s)

		fmt.Println(steps(s))
	}

}

func steps(s string) int {
	back := len(s) - 1
	front := len(s) - 1

	ans := 0

	for front >= 0 {
		for front > 0 && s[front-1] == s[front] {
			front--
		}

		if front-back > 0 {
			// we have something in the bank
			front = front - 1
			back = front
		} else {
			// we don't have anything in the bank
			front = front - 2
			back = front
		}
		ans++
	}

	if ans == 0 {
		ans++
	}

	return ans
}

package main

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

var reader = bufio.NewReader(os.Stdin)

func main() {
	var t int
	fmt.Fscan(reader, &t)

	for i := 0; i < t; i++ {
		var n int
		fmt.Fscan(reader, &n)

		var s string
		fmt.Fscan(reader, &s)

		fmt.Println(steps(s))
	}

}

func steps(s string) int {
	back := len(s) - 1
	front := len(s) - 1

	ans := 0

	for front >= 0 {
		for front > 0 && s[front-1] == s[front] {
			front--
		}

		if back-front > 0 {
			// we have something in the bank
			front = front - 1
			back = front
		} else {
			// we don't have anything in the bank
			front = front - 2
			back = front
		}
		ans++
	}

	return max(ans, 1)
}

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)

func main() {
	var t int
	fmt.Fscan(reader, &t)

	for i := 0; i < t; i++ {
		var n int
		fmt.Fscan(reader, &n)

		var s string
		fmt.Fscan(reader, &s)

		fmt.Println(steps(s))
	}

}

func steps(s string) int {
	back := len(s) - 1
	front := len(s) - 1

	ans := 0

	for front >= 0 {
		for front > 0 && s[front-1] == s[front] {
			front--
		}

		if front-back > 0 {
			// we have something in the bank
			front = front - 1
			back = front
		} else {
			// we don't have anything in the bank
			front = front - 2
			back = front
		}
		ans++

	}

	return ans
}


package main

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

// github.com/EndlessCheng/codeforces-go
func main() {
	in := bufio.NewReader(os.Stdin)
	var n, v, w int
	Fscan(in, &n)
	g := make([][]int, n+1)
	g[1] = []int{0}
	for m := n - 1; m > 0; m-- {
		Fscan(in, &v, &w)
		g[v] = append(g[v], w)
		g[w] = append(g[w], v)
	}

	g2 := make([][]int, n+1)
	g2[1] = []int{0}
	Fscan(in, &v)
	for q := []int{v}; len(q) > 0; {
		v, q = q[0], q[1:]
		for m := len(g[v]) - 1; m > 0; m-- {
			Fscan(in, &w)
			g2[v] = append(g2[v], w)
			g2[w] = append(g2[w], v)
			q = append(q, w)
		}
	}

	for i, e := range g {
		e2 := g2[i]
		if len(e) != len(e2) {
			Print("No")
			return
		}
		sort.Ints(e)
		sort.Ints(e2)
		for j, w := range e {
			if w != e2[j] {
				Print("No")
				return
			}
		}
	}
	Print("Yes")
}

package main

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

func solve(n int, vertices [][]int, tocheck []int) string {
	relorder := make([]int, n+1)
	q := make([]int, 0, n-1)
	q = append(q, 1)
	visited := make([]bool, n+1)
	answer := make([]int, 0, n)

	for idx, val := range tocheck {
		relorder[val] = idx
	}
	for _, lst := range vertices {
		sort.Slice(lst, func(i, j int) bool {
			return relorder[lst[i]] < relorder[lst[j]]
		})
	}
	for len(q) > 0 {
		elem := q[0]
		q = q[1:]
		visited[elem] = true
		answer = append(answer, elem)
		for _, v := range vertices[elem] {
			if !visited[v] {
				q = append(q, v)
			}
		}
	}
	for i, v := range answer {
		if tocheck[i] != v {
			return "NO"
		}
	}
	return "YES"
}

func main() {
	var n int
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &n)
	vertices := make([][]int, n+1)
	tocheck := make([]int, n)

	for i := 1; i <= n-1; i++ {
		var from, to int
		fmt.Fscan(in, &from, &to)

		vertices[to] = append(vertices[to], from)
		vertices[from] = append(vertices[from], to)
	}
	for i := 0; i < n; i++ {
		fmt.Fscan(in, &tocheck[i])
	}
	//fmt.Print(vertices)
	//fmt.Print(tocheck)
	res := solve(n, vertices, tocheck)
	fmt.Println(res)
}

package main

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

func qsort(a []int, relorder []int) []int {
	if len(a) < 2 {
		return a
	}

	left, right := 0, len(a)-1

	// Pick a pivot
	pivotIndex := rand.Int() % len(a)

	// Move the pivot to the right
	a[pivotIndex], a[right] = a[right], a[pivotIndex]

	// Pile elements smaller than the pivot on the left
	for i := range a {
		if relorder[a[i]] < relorder[a[right]] {
			a[i], a[left] = a[left], a[i]
			left++
		}
	}

	// Place the pivot after the last smaller element
	a[left], a[right] = a[right], a[left]

	// Go down the rabbit hole
	qsort(a[:left], relorder)
	qsort(a[left+1:], relorder)

	return a
}

func solve(n int, vertices [][]int, tocheck []int) string {
	relorder := make([]int, n+1)
	q := make([]int, 0, n-1)
	q = append(q, 1)
	visited := make([]bool, n+1)
	answer := make([]int, 0, n)

	for idx, val := range tocheck {
		relorder[val] = idx
	}
	for _, lst := range vertices {
		qsort(lst, relorder)
	}
	for len(q) > 0 {
		elem := q[0]
		q = q[1:]
		visited[elem] = true
		answer = append(answer, elem)
		for _, v := range vertices[elem] {
			if !visited[v] {
				q = append(q, v)
			}
		}
	}
	for i, v := range answer {
		if tocheck[i] != v {
			return "NO"
		}
	}
	return "YES"
}

func main() {
	var n int
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &n)
	vertices := make([][]int, n+1)
	tocheck := make([]int, n)

	for i := 1; i <= n-1; i++ {
		var from, to int
		fmt.Fscan(in, &from, &to)

		vertices[to] = append(vertices[to], from)
		vertices[from] = append(vertices[from], to)
	}
	for i := 0; i < n; i++ {
		fmt.Fscan(in, &tocheck[i])
	}
	//fmt.Print(vertices)
	//fmt.Print(tocheck)
	res := solve(n, vertices, tocheck)
	fmt.Println(res)
}

package main

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

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

	var n, v, w int
	Fscan(in, &n)
	g := make([][]int, n+1)
	g[1] = []int{0}
	for m := n - 1; m > 0; m-- {
		Fscan(in, &v, &w)
		g[v] = append(g[v], w)
		g[w] = append(g[w], v)
	}
	for _, e := range g {
		sort.Ints(e)
	}

	g2 := make([][]int, n+1)
	g2[1] = []int{0}
	Fscan(in, &v)
	for queue := []int{v}; len(queue) > 0; {
		v, queue = queue[0], queue[1:]
		for m := len(g[v]) - 1; m > 0; m-- {
			Fscan(in, &w)
			g2[v] = append(g2[v], w)
			g2[w] = append(g2[w], v)
			queue = append(queue, w)
		}
	}
	for _, e := range g2 {
		sort.Ints(e)
	}

	for i, e := range g {
		if len(e) != len(g2[i]) {
			Fprint(out, "No")
			return
		}
		for j, w := range e {
			if w != g2[i][j] {
				Fprint(out, "No")
				return
			}
		}
	}
	Fprint(out, "Yes")
}

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

package main

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

const (
	MaxN = 200005
)

var n int
var a, u, d []int
var g map[int]map[int]bool

func main() {
	buf := bufio.NewReader(os.Stdin)
	fmt.Fscanf(buf, "%d\n", &n)
	g = make(map[int]map[int]bool, n+1)
	a = make([]int, n)
	d = make([]int, n+1)
	u = make([]int, n+1)
	for i := 0; i < n - 1; i++ {
		var v1, v2 int
		fmt.Fscanf(buf, "%d %d\n", &v1, &v2)
		if _, ok := g[v1]; !ok {
			g[v1] = make(map[int]bool)
		}
		g[v1][v2] = true
		if _, ok := g[v2]; !ok {
			g[v2] = make(map[int]bool)
		}
		g[v2][v1] = true
	}
	for i := 1; i <= n; i++ {
		d[i] = len(g[i])
	}
	for i := 0; i < n; i++ {
		fmt.Fscanf(buf, "%d", &a[i])
	}

	if a[0] != 1 {
		fmt.Println("No")
		return
	}

	checked := 1
	u[a[0]] = 1
	for i := 0; i < n; i++ {
		for j := checked; j < n; j++ {
			if _, ok := g[a[i]][a[j]]; ok && u[a[j]] == 0 {
				u[a[j]] = 1
				checked++
				d[a[i]]--
				d[a[j]]--
			} else {
				break
			}
		}
		if d[a[i]] > 0 {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}

package main

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

func main(){
	var n int
	Scan(&n)
	g:=make([]map[int]bool,n+1)
	for i:=1;i<n+1;i++{
		g[i]=map[int]bool{}
	}
	in:=bufio.NewReader(os.Stdin)
	for i:=0;i<n-1;i++{
		var x,y int
		Fscan(in,&x,&y)
		g[x][y]=true
		g[y][x]=true
	}
	isCheckeds:=make([]bool,n+1)
	isCheckeds[1]=true
	checks:=[]int{1}
	checksLen:=1
	for checksLen>0{
		newChecks:=[]int{}
		for i:=0;i<checksLen;i++{
			for k:=range g[checks[i]]{
				if isCheckeds[k]{
					delete(g[checks[i]],k)
					continue
				}
				newChecks=append(newChecks,k)
				isCheckeds[k]=true
			}
		}
		checks=newChecks
		checksLen=len(checks)
	}
	var aI int
	Fscan(in,&aI)
	if aI!=1{
		Print("No")
		return
	}
	checks=[]int{1}
	checksLen=1
	for checksLen>0{
		newChecks:=[]int{}
		for i:=0;i<checksLen;i++{
			lenG:=len(g[checks[i]])
			for j:=0;j<lenG;j++{
				Fscan(in,&aI)
				if !g[checks[i]][aI]{
					Print("No")
					return
				}
				newChecks=append(newChecks,aI)
			}
		}
		checks=newChecks
		checksLen=len(checks)
	}

	Print("Yes")
}

package main

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

const (
	MaxN = 200005
)

var n int
var a, u, d []int
var g map[int]map[int]bool

func main() {
	buf := bufio.NewReader(os.Stdin)
	fmt.Fscanf(buf, "%d\n", &n)
	g = make(map[int]map[int]bool, n+1)
	a = make([]int, n)
	d = make([]int, n+1)
	u = make([]int, n+1)
	for i := 0; i < n - 1; i++ {
		var v1, v2 int
		fmt.Fscanf(buf, "%d %d\n", &v1, &v2)
		if _, ok := g[v1]; !ok {
			g[v1] = make(map[int]bool)
		}
		g[v1][v2] = true
		if _, ok := g[v2]; !ok {
			g[v2] = make(map[int]bool)
		}
		g[v2][v1] = true
	}
	for i := 1; i <= n; i++ {
		d[i] = len(g[i])
	}
	for i := 0; i < n; i++ {
		fmt.Fscanf(buf, "%d", &a[i])
	}

	checked := 1
	u[a[0]] = 1
	for i := 0; i < n; i++ {
		for j := checked; j < n; j++ {
			if _, ok := g[a[i]][a[j]]; ok && u[a[j]] == 0 {
				u[a[j]] = 1
				checked++
				d[a[i]]--
				d[a[j]]--
			} else {
				break
			}
		}
		if d[a[i]] > 0 {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}

package main

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

const (
	MaxN = 200005
)

var n int
var a, u, d []int
var g map[int]map[int]bool

func main() {
	buf := bufio.NewReader(os.Stdin)
	fmt.Fscanf(buf, "%d\n", &n)
	g = make(map[int]map[int]bool, n+1)
	a = make([]int, n)
	d = make([]int, n+1)
	u = make([]int, n+1)
	for i := 0; i < n - 1; i++ {
		var v1, v2 int
		fmt.Fscanf(buf, "%d %d\n", &v1, &v2)
		if _, ok := g[v1]; !ok {
			g[v1] = make(map[int]bool)
		}
		g[v1][v2] = true
		if _, ok := g[v2]; !ok {
			g[v2] = make(map[int]bool)
		}
		g[v2][v1] = true
	}
	for i := 1; i <= n; i++ {
		d[i] = len(g[i])
	}
	for i := 0; i < n; i++ {
		fmt.Fscanf(buf, "%d", &a[i])
	}

	if a[0] != 1 {
		fmt.Println("No")
		return
	}

	checked := 1
	u[a[0]] = 1
	for i := 0; i < n; i++ {
		for j := checked; j < n; j++ {
			if _, ok := g[a[i]][a[j]]; ok && u[a[j]] == 0 {
				u[a[j]] = 1
				checked++
				d[a[i]]--
				d[a[j]]--
			} else {
				break
			}
		}
		if d[a[i]] > 0 {
			fmt.Println(d)
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}

package main

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

func main(){
	var n int
	Scan(&n)
	g:=make([][]int,n+1)
	in:=bufio.NewReader(os.Stdin)
	for i:=0;i<n-1;i++{
		var x,y int
		Fscan(in,&x,&y)
		g[x]=append(g[x],y)
		g[y]=append(g[y],x)
	}
	lvls:=make([]int,n+1)
	lvls[1]=1
	children:=g[1]
	lvl:=2
	lvlCounts:=[]int{0,1}
	for len(children)>0{
		leng:=len(children)
		lvlCounts=append(lvlCounts,leng)
		for i:=0;i<leng;i++{
			lvls[children[i]]=lvl
			lengG:=len(g[children[i]])
			for j:=0;j<lengG;j++{
				if lvls[g[children[i]][j]]==0{
					children=append(children,g[children[i]][j])
				}
			}
		}
		children=children[leng:]
		lvl++
	}
	lvl=1
	for i:=0;i<n;i++{
		var aI int
		Fscan(in,&aI)
		if lvls[aI]!=lvl{
			Print("No")
			return
		}
		lvlCounts[lvl]--
		if lvlCounts[lvl]==0{
			lvl++
		}
	}

	Print("Yes")
}

package main

import (
	"container/list"
	"fmt"
	"sort"
)

type value struct {
	current int
	level   int
}

func solve(n int, vertices [][]int, tocheck []int) string {
	q := list.New()
	q.PushBack(value{1, 1})
	visited := make([]bool, n+1)
	level := 0
	start := 0
	for q.Len() > 0 {
		elem := q.Front().Value.(value)
		visited[elem.current] = true
		if level != elem.level {
			slice := tocheck[start : start+q.Len()]
			sort.Ints(slice)
			// fmt.Print(slice)
			for e := q.Front(); e != nil; e = e.Next() {
				idx := sort.SearchInts(slice, e.Value.(value).current)
				if idx == len(slice) {
					return "NO"
				}
			}
			level = elem.level
			start += q.Len()
		}
		q.Remove(q.Front())
		for _, v := range vertices[elem.current] {
			if !visited[v] {
				q.PushBack(value{v, elem.level + 1})
			}
		}
	}
	return "YES"
}

func main() {
	var n int
	fmt.Scan(&n)
	vertices := make([][]int, n+1)
	tocheck := make([]int, n)

	for i := 1; i <= n-1; i++ {
		var from, to int
		fmt.Scan(&from, &to)

		vertices[to] = append(vertices[to], from)
		vertices[from] = append(vertices[from], to)
	}
	for i := 0; i < n; i++ {
		fmt.Scan(&tocheck[i])
	}
	//fmt.Print(vertices)
	//fmt.Print(tocheck)
	res := solve(n, vertices, tocheck)
	fmt.Println(res)
}

package main

import (
	"container/list"
	"fmt"
	"sort"
)

type value struct {
	current int
	level   int
}

func solve(n int, vertices [][]int, tocheck []int) string {
	q := list.New()
	q.PushBack(value{1, 1})
	visited := make([]bool, n+1)
	level := 0
	start := 0
	for q.Len() > 0 {
		elem := q.Front().Value.(value)
		visited[elem.current] = true
		if level != elem.level {
			slice := tocheck[start : start+q.Len()]
			sort.Ints(slice)
			// fmt.Print(slice)
			for e := q.Front(); e != nil; e = e.Next() {
				idx := sort.SearchInts(slice, e.Value.(value).current)
				if idx == len(slice) {
					return "NO"
				}
			}
			level = elem.level
			start += q.Len()
		}
		q.Remove(q.Front())
		for _, v := range vertices[elem.current] {
			if !visited[v] {
				q.PushBack(value{v, elem.level + 1})
			}
		}
	}
	return "YES"
}

func main() {
	var n int
	fmt.Scanf("%d", &n)
	vertices := make([][]int, n+1)
	tocheck := make([]int, n)

	for i := 1; i <= n-1; i++ {
		var from, to int
		fmt.Scanf("%d %d ", &from, &to)

		vertices[to] = append(vertices[to], from)
		vertices[from] = append(vertices[from], to)
	}
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &tocheck[i])
	}
	// fmt.Print(vertices)
	// fmt.Print(tocheck)
	res := solve(n, vertices, tocheck)
	fmt.Println(res)
}

package main

import (
	"container/list"
	"fmt"
	"sort"
)

type value struct {
	current int
	level   int
}

func solve(n int, vertices [][]int, tocheck []int) string {
	q := list.New()
	q.PushBack(value{1, 1})
	visited := make([]bool, n+1)
	level := 0
	start := 0
	for q.Len() > 0 {
		elem := q.Front().Value.(value)
		visited[elem.current] = true
		if level != elem.level {
			slice := tocheck[start : start+q.Len()]
			sort.Ints(slice)
			//	fmt.Print(slice)
			for e := q.Front(); e != nil; e = e.Next() {
				idx := sort.SearchInts(slice, e.Value.(value).current)
				if idx == len(slice) {
					return "NO"
				}
			}
			level = elem.level
			start += q.Len()
		}
		q.Remove(q.Front())
		for _, v := range vertices[elem.current] {
			if !visited[v] {
				q.PushBack(value{v, elem.level + 1})
			}
		}
	}
	return "YES"
}

func main() {
	var n int
	fmt.Scanf("%d", &n)
	vertices := make([][]int, n+1)
	tocheck := make([]int, n)

	for i := 0; i < n-1; i++ {
		var from, to int
		fmt.Scanf("%d %d", &from, &to)

		vertices[to] = append(vertices[to], from)
		vertices[from] = append(vertices[from], to)
	}
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &tocheck[i])
	}
	// fmt.Print(vertices)
	// fmt.Print(tocheck)
	res := solve(n, vertices, tocheck)
	fmt.Println(res)
}

package main

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

const (
	MaxN = 200005
)

var n int
var a, d []int
var g [][]int

func bfs(v int) {
	q := []int{v}
	d[v] = 1
	for len(q) > 0 {
		t := q[0]
		q = q[1:]
		for _, v := range g[t] {
			if d[v] == 0 {
				d[v] = d[t] + 1
				q = append(q, v)
			}
		}
	}
}

func main() {
	buf := bufio.NewReader(os.Stdin)
	fmt.Fscanf(buf, "%d\n", &n)
	g = make([][]int, n+1)
	a = make([]int, n+1)
	d = make([]int, n+1)
	for i := 0; i < n - 1; i++ {
		var v1, v2 int
		fmt.Fscanf(buf, "%d %d\n", &v1, &v2)
		g[v1] = append(g[v1], v2)
		g[v2] = append(g[v2], v1)
	}
	for i := 0; i < n; i++ {
		fmt.Fscanf(buf, "%d", &a[i])
	}
	bfs(a[0])
	for i := 0; i < n - 1; i++ {
		if d[a[i]] > d[a[i+1]] {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}


package main

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

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

    var T, n int
    fmt.Fscan(r, &T)
    for t := 0; t < T; t++ {
        fmt.Fscan(r, &n)
        fmt.Fprint(w, 1, n-1, "\n")
    }
}

package main

import (
	"fmt"
)

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func main() {
	var n int
	_, err := fmt.Scanf("%d\n", &n)
	if err != nil {
		fmt.Println(err)
		return
	}
	for i := 0; i < n; i++ {
		var x int
		_, err = fmt.Scanf("%d\n", &x)
		if err != nil {
			fmt.Println(err)
			return
		}
		fmt.Println(x-1, 1)
	}
}

package main

import(
	"fmt"
)

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

	for ; t>0 ; t-- {
		var x int
		_, _ = fmt.Scan( &x)
		g,l:=1,x-1
		a,b:=g*l/g,g*l/l
		fmt.Println(a,b)

	}
}

package main

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

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

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

	for t := 0; t < ts; t++ {
		var x int
		fmt.Fscanf(r, "%d\n", &x)
		fmt.Printf("1 %d\n", x-1)
	}
}

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1325A(in io.Reader, out io.Writer) {
	var T, n int
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n)
		Fprintln(out, 1, n-1)
	}
}

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

package main

import "fmt"

func main() {
	T := 0
	fmt.Scanf("%d\n", &T)
	for i := 0; i < T; i++ {
		Val := 0
		fmt.Scanf("%d\n", &Val)
		fmt.Println(1, Val-1)
	}
}

package main

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

func main() {
	t := nextInt()
	for t > 0 {
		x := nextInt()
		print(x - 1, 1, "\n")
		t--
	}
	writer.Flush()
}

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

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

func nextInt() int {
	var n int
	fmt.Fscan(reader, &n)
	return n
}

package main

import "fmt"

func main()  {
	var T, x int
	_, _ = fmt.Scan(&T)
	for ;T > 0; T-- {
		_, _ = fmt.Scan(&x)
		fmt.Println(1,x-1)
	}
}

package main

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

func main() {
	input := bufio.NewScanner(os.Stdin)
	input.Scan()
	t, _ := strconv.Atoi(input.Text())
	for i := 0; i < t; i++ {
		input.Scan()
		x, _ := strconv.Atoi(input.Text())
		fmt.Printf("1 %v\n", x - 1)
	}
}

package main

import (
	"fmt"
)

func solve() {
	var x int
	fmt.Scan(&x)
	fmt.Printf("%d %d\n", 1, x-1)
}

func main() {
	var tst int
	fmt.Scan(&tst)
	for t := 0; t < tst; t++ {
		solve()
	}

}

package main

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

func smth(x string)(string){
	var n int
	n, _ = strconv.Atoi(x)
	return "1 " + strconv.Itoa(n - 1)
}
func main() {
	var line string
	var testcount int
	fmt.Scanln(&testcount)
	answer := ""
	reader := bufio.NewReader(os.Stdin)
	for i := 0; i < testcount; i++ {
		line, _ = reader.ReadString('\n')
		line = strings.TrimSpace(line)
		answer += smth(line)
		if i < testcount - 1{
			answer += "\n"
		}
	}
	fmt.Print(answer)
}

package main

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

func newScanner() *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	// buf := make([]byte, 10000)
	// scanner.Buffer(buf, 1000000)
	return scanner
}

func scanInt(s *bufio.Scanner) int {
	if s.Scan() {
		t := s.Text()
		if v, err := strconv.Atoi(t); err == nil {
			return v
		}
		panic(fmt.Sprintln("Could't scan int from input", t))
	}
	panic(s.Err())
}

func scanInts(s *bufio.Scanner, n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = scanInt(s)
	}
	return a
}

var sc *bufio.Scanner = newScanner()

func solve() {
	x := scanInt(sc)
	fmt.Println(1, x-1)
}

func main() {
	t := scanInt(sc)
	for i := 0; i < t; i++ {
		solve()
	}
}

package main

import (
	"bufio"
	"flag"
	"fmt"
	"log"
	"os"
	"runtime/pprof"
	"strconv"
	"strings"
)

func GCD(x, y int64) int64 {
	for y != 0 {
		x, y = y, x%y
	}
	return x
}

func LCM(x, y int64) int64 {
	return x / GCD(x, y) * y
}

func Find(x int64) (int64, int64) {
	var a, b int64
	if x % 2 == 0 {
		a = x / 2
		b = a
		return a, b
	}
	b = 1
	a = x - 1
	return a, b
}

var cpuprofile = flag.String("cpuprofile", "", "write cpu profile to file")

func main() {
	flag.Parse()
	if *cpuprofile != "" {
		f, err := os.Create(*cpuprofile)
		if err != nil {
			log.Fatal(err)
		}
		pprof.StartCPUProfile(f)
		defer pprof.StopCPUProfile()
	}
	var n, i uint64
	var t int64
	reader := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	_, err := fmt.Scanf("%d\n", &n)
	if err != nil {
		fmt.Printf("err1: %v", err.Error())
		os.Exit(1)
	}
	for i = 0; i < n; i++ {
		str, _ := reader.ReadString('\n')
		t, err = strconv.ParseInt(strings.TrimSpace(str), 10, 64)
		if err != nil {
			fmt.Printf("err2: %v", err.Error())
			os.Exit(1)
		}

		a, b := Find(t)
		//writer.WriteString(strconv.FormatInt(a, 10))
		//writer.WriteString(" ")
		//writer.WriteString(strconv.FormatInt(b, 10))
		fmt.Fprintf(writer, "%d %d\n", a, b)
	}
	writer.Flush()
}

package main

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

var (
    reader Reader = NewReader()
    writer Writer = NewWriter()
)

type Reader interface {
    Scanf(format string, a ...interface{})
    Int() int
    Int64() int64
    String() string
    IntStream(size int) <-chan int
    Int64Stream(size int) <-chan int64
    StringStream(size int) <-chan string
    IntSlice(size int) []int
    Int64Slice(size int) []int64
    StringSlice(size int) []string
}

type Writer interface {
    Printf(format string, a ...interface{})
    Flush()
}

type readerImpl struct {
    *bufio.Reader
}

func NewReader() Reader {
    return &readerImpl{Reader: bufio.NewReader(os.Stdin)}
}

func (impl *readerImpl) Scanf(f string, a ...interface{}) {
    fmt.Fscanf(impl.Reader, f, a...)
}

func (impl *readerImpl) Int() int {
    var ret int
    impl.Scanf("%d\n", &ret)
    return ret
}

func (impl *readerImpl) Int64() int64 {
    var ret int64
    impl.Scanf("%d\n", &ret)
    return ret
}

func (impl *readerImpl) String() string {
    var ret string
    impl.Scanf("%s\n", &ret)
    return ret
}

func (impl *readerImpl) IntStream(size int) <-chan int {
    c := make(chan int)
    go func() {
        for i := 0; i < size-1; i++ {
            var v int
            impl.Scanf("%d ", &v)
            c <- v
        }
        var v int
        impl.Scanf("%d\n", &v)
        c <- v
    }()
    return c
}

func (impl *readerImpl) Int64Stream(size int) <-chan int64 {
    c := make(chan int64)
    go func() {
        for i := 0; i < size-1; i++ {
            var v int64
            impl.Scanf("%d ", &v)
            c <- v
        }
        var v int64
        impl.Scanf("%d\n", &v)
        c <- v
    }()
    return c
}

func (impl *readerImpl) StringStream(size int) <-chan string {
    c := make(chan string)
    go func() {
        for i := 0; i < size-1; i++ {
            var v string
            impl.Scanf("%d ", &v)
            c <- v
        }
        var v string
        impl.Scanf("%d\n", &v)
        c <- v
    }()
    return c
}

func (impl *readerImpl) IntSlice(size int) []int {
    ret := make([]int, size)
    for i := 0; i < size-1; i++ {
        impl.Scanf("%d ", &ret[i])
    }
    impl.Scanf("%d\n", &ret[size-1])
    return ret
}

func (impl *readerImpl) Int64Slice(size int) []int64 {
    ret := make([]int64, size)
    for i := 0; i < size-1; i++ {
        impl.Scanf("%d ", &ret[i])
    }
    impl.Scanf("%d\n", &ret[size-1])
    return ret
}

func (impl *readerImpl) StringSlice(size int) []string {
    ret := make([]string, size)
    for i := 0; i < size-1; i++ {
        impl.Scanf("%s ", &ret[i])
    }
    impl.Scanf("%s\n", &ret[size-1])
    return ret
}

type writerImpl struct {
    *bufio.Writer
}

func NewWriter() Writer {
    return &writerImpl{Writer: bufio.NewWriter(os.Stdout)}
}

func (impl *writerImpl) Printf(f string, a ...interface{}) {
    fmt.Fprintf(impl.Writer, f, a...)
}

func (impl *writerImpl) Flush() {
    impl.Writer.Flush()
}

func main() {
    defer writer.Flush()
    t := reader.Int()
    for ; t > 0; t-- {
        x := reader.Int()
        a, b := sol(x)
        writer.Printf("%d %d\n", a, b)
    }
}

func sol(x int) (int, int) {
    if x % 2 == 0 {
        return x/2, x/2
    }
    return 1, x-1
}

package main

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

func main() {
	var t, n int
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		fmt.Fscan(in, &n)

		fmt.Println(1, n-1)

	}
}

package main

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

func main() {

	t := ScanInt64()
	for ; t > 0; t-- {
		n := ScanInt64()
		fmt.Println(n-1, 1)
	}

}

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

var O chan string
var in *bufio.Scanner
var oWg *sync.WaitGroup
var P func(a ...interface{}) (n int, err error)

func init() {
	P = fmt.Println

	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(1e+9))
	in.Split(bufio.ScanWords)

	O = make(chan string, 16)
	oWg = &sync.WaitGroup{}
	oWg.Add(1)

	writer := bufio.NewWriter(os.Stdout)
	go func() {
		defer oWg.Done()
		defer writer.Flush()

		for line := range O {
			writer.WriteString(line + "\n")
		}
	}()
}

func ScanWord() string { in.Scan(); return in.Text() }
func ScanInt() int     { i, _ := strconv.Atoi(ScanWord()); return i }
func ScanInt64() int64 { i, _ := strconv.ParseInt(ScanWord(), 10, 64); return i }
func ScanStringSlice(n int) []string {
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = ScanWord()
	}
	return s
}
func ScanIntSlice(n int) []int {
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = ScanInt()
	}
	return arr
}
func ScanInt64Slice(n int) []int64 {
	arr := make([]int64, n)
	for i := 0; i < n; i++ {
		arr[i] = ScanInt64()
	}
	return arr
}

/*********************** Utils ***********************/

func S(v interface{}) string { return fmt.Sprintf("%v", v) }
func SArr(a []int) string {
	sb := strings.Builder{}
	sb.Grow(len(a) * 9)
	for i := range a {
		sb.WriteString(strconv.Itoa(a[i]) + " ")
	}
	return sb.String()
}
func SArr64(a []int64) string {
	sb := strings.Builder{}
	sb.Grow(len(a) * 9)
	for i := range a {
		sb.WriteString(strconv.FormatInt(a[i], 10) + " ")
	}
	return sb.String()
}
func MnMx(args []int64) (int64, int64) {
	minVal, maxVal := int64(math.MaxInt64), int64(math.MinInt64)
	for _, v := range args {
		if v < minVal {
			minVal = v
		}
		if v > maxVal {
			maxVal = v
		}
	}
	return minVal, maxVal
}
func Mn(args []int64) int64 { mn, _ := MnMx(args); return mn }
func Mx(args []int64) int64 { _, mx := MnMx(args); return mx }
func LCM(a, b int64) int64  { return a / GCD(a, b) * b }
func GCD(a, b int64) int64 {
	if a == 0 {
		return b
	}
	return GCD(b%a, a)
}
func sortInt64Slice(a []int64) { sort.Slice(a, func(i, j int) bool { return a[i] < a[j] }) }
func abs(x int64) int64 {
	if x < 0 {
		return -x
	}
	return x
}
func MinimumMaximum(a, b int64) (int64, int64) {
	if a < b {
		return a, b
	}
	return b, a

}
func Minimum(a, b int64) int64 {
	min, _ := MinimumMaximum(a, b)
	return min

}
func Maximum(a, b int64) int64 {
	_, max := MinimumMaximum(a, b)
	return max

}

package main

import (
	"bufio"
	"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') {
			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 fillNNums(bs []byte, n int, res []int) {
	x := 0
	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])
	}
}

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

	tc := readNum(reader)

	for tc > 0 {
		tc--
		n := readNum(reader)
		a, b := solve(n)
		fmt.Printf("%d %d\n", a, b)
	}
}

func solve(x int) (int, int) {

	for g := 1; g*g <= x; g++ {
		if x%g != 0 {
			continue
		}
		h := x / g
		// g * h = x
		// let h = (1 + m * n)
		if h > 1 {
			mn := h - 1
			return g, g * mn
		}

		if g > 1 {
			mn := g - 1
			return h, h * mn
		}
	}

	return 1, 1
}

package main

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

func main() {

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

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

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

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

		fmt.Fprintln(out, x-1, 1)
	}

}

package main

import ("fmt")

// func calculate(y,d int32){
// 	answer := y%d
// 	if answer==0{
// 		fmt.Println("YES")
// 	}else{
// 		fmt.Println("NO")
// 	}
// }

func main(){
	var t int
	fmt.Scanln(&t)
	for i:=0;i<t;i++{
		var x int32
		//var y int32
		fmt.Scanln(&x)
		//fmt.ScanLN(&y)
		fmt.Println(1,x-1)
		//calculate(x,y)
	}
}

package main

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

var reader io.Reader
var scanner *bufio.Scanner

func Init(io io.Reader, max_token_size int) {
	reader = bufio.NewReader(io)
	scanner = bufio.NewScanner(reader)
	// max token size
	scanner.Split(bufio.ScanWords)
	scanner.Buffer([]byte{}, max_token_size)
}

func stderr(v ...interface{}) {
	fmt.Fprintln(os.Stderr, v...)
}

func die(v ...interface{}) {
	fmt.Fprintln(os.Stderr, v...)
	os.Exit(1)
}

func NextInt() int {
	bytes := NextBytes()
	i, err := Atoi(bytes)
	if err != nil {
		die(err)
	}
	return i
}
func NextInt64() int64 {
	bytes := NextBytes()
	i, err := Atoi64(bytes)
	if err != nil {
		die(err)
	}
	return i
}

func NextBytes() []byte {
	if !scanner.Scan() {
		die(scanner.Err())
	}
	bytes := scanner.Bytes()
	copied := make([]byte, len(bytes))
	copy(copied, bytes)
	return copied
}

func Atoi(b []byte) (int, error) {
	neg := false
	if b[0] == '+' {
		b = b[1:]
	} else if b[0] == '-' {
		neg = true
		b = b[1:]
	}
	n := 0
	for _, v := range b {
		if v < '0' || v > '9' {
			return 0, strconv.ErrSyntax
		}
		n = n*10 + int(v-'0')
	}
	if neg {
		return -n, nil
	}
	return n, nil
}

func Atoi64(b []byte) (int64, error) {
	neg := false
	if b[0] == '+' {
		b = b[1:]
	} else if b[0] == '-' {
		neg = true
		b = b[1:]
	}
	var n int64
	for _, v := range b {
		if v < '0' || v > '9' {
			return 0, strconv.ErrSyntax
		}
		n = n*10 + int64(v-'0')
	}
	if neg {
		return -n, nil
	}
	return n, nil
}

func ExtendByteArray(a []byte, size int) []byte {
	if size <= len(a) {
		return a
	} else {
		return append(a, make([]byte, size-len(a))...)
	}
}

func ExtendIntArray(a []int, size int) []int {
	if size <= len(a) {
		return a
	} else {
		return append(a, make([]int, size-len(a))...)
	}
}

func reverseInts(a []int) {
	for l, r := 0, len(a)-1; l < r; l, r = l+1, r-1 {
		a[l], a[r] = a[r], a[l]
	}
}

func unique(a []int) int {
	newLen := 0
	n := len(a)
	for i := 0; i < n; i++ {
		if newLen == 0 || a[i] != a[newLen-1] {
			a[newLen] = a[i]
			newLen++
		}
	}
	return newLen
}

func main() {
	inf := os.Stdin
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	// inf, err := os.Open("a.in")
	// if err != nil {
	// 	die(err)
	// }
	// out, err := os.Create("a.out")
	// if err != nil {
	// 	die(err)
	// }
	// defer out.Close()
	Init(inf, 1000010)

	T := NextInt()
	for t := 0; t < T; t++ {
		x := NextInt()
		fmt.Fprintln(out, 1, x-1)
	}
}

package main

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

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

func printf(format string, a ...interface{}) { fmt.Fprintf(out, format, a...) }
func nextInt() int {
	in.Scan()
	n, _ := strconv.Atoi(in.Text())
	return n
}

func main() {
	in.Split(bufio.ScanWords)
	defer out.Flush()
	for t := nextInt(); t > 0; t-- {
		printf("%d %d\n", 1, nextInt()-1)
	}
}

package main

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

func main() {

	t := ReadInt()
	for tidx:=1;tidx<=t;tidx++ {
		a:=ReadInt()-1
		fmt.Printf("%d %d\n", 1, a)
	}
}

////////////////////////////////////

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

var out chan string
var in *bufio.Scanner
var outWg *sync.WaitGroup

func ReadString() string {
	in.Scan()
	return in.Text()
}
func ReadStringSlice(n int) []string {
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = ReadString()
	}
	return s
}
func ReadInt() int {
	intStr := ReadString()
	i, _ := strconv.ParseInt(intStr, 10, 32)
	return int(i)
}
func ReadInt64() int64 {
	intstr := ReadString()
	i, _ := strconv.ParseInt(intstr, 10, 64)
	return int64(i)
}
func ReadIntSlice(n int) []int {
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = ReadInt()
	}
	return arr
}
func init() {
	//set input
	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(2e+5))
	in.Split(bufio.ScanWords)

	//set output
	out = make(chan string, 16)
	outWg = &sync.WaitGroup{}
	outWg.Add(1)

	writer := bufio.NewWriterSize(os.Stdout, int(2e+5))
	go func(write *bufio.Writer) {
		defer outWg.Done()
		defer write.Flush()

		for line := range out {
			write.WriteString(line + "\n")
		}
	}(writer)
}

package main

import (
	"bufio"
	"fmt"
)

func main() {
	// reader := bufio.NewReader(os.Stdin)
	var cases int
	fmt.Scanf("%d\n", &cases)
	for i := 0; i < cases; i++ {
		var x int64
		fmt.Scanf("%d\n", &x)
		a := 1
		b := x - 1
		fmt.Println(a, b)
	}
}

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

func main() {
	var t, n int
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		fmt.Fscan(in, &n)
		if n%2 == 0 {
			fmt.Println(2, n-2)
		} else {
			fmt.Println(1, n-1)
		}
	}
}

package main

import (
	"fmt"
)

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func main() {
	var n int
	_, err := fmt.Scanf("%d", &n)
	if err != nil {
		fmt.Println(err)
		return
	}
	for i := 0; i < n; i++ {
		var x int
		_, err = fmt.Scanf("%d", &x)
		if err != nil {
			fmt.Println(err)
			return
		}
		fmt.Println(x-1, 1)
	}
}

package main

import(
	"fmt"
)

func main(){
	var t int
	_, _ = fmt.Scanf("%d", &t)

	for ; t>0 ; t-- {
		var x int
		_, _ = fmt.Scanf("%d", &x)
		g,l:=1,x-1
		a,b:=g*l/g,g*l/l
		fmt.Println(a,b)

	}
}

package main

import(
	"fmt"
)

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

	for ; t>0 ; t-- {
		var x int
		fmt.Scanf("%d",&x)
		g,l:=1,x-1
		a,b:=g*l/g,g*l/l
		fmt.Println(a,b)
	}
}

package main

import "fmt"

func main() {
	var T int32
	fmt.Scan(&T)
	for i := int32(0); i < T; i++ {
		var Val int32
		fmt.Scanf("%d", &Val)
		fmt.Println(1, Val-1)
	}
}

package main

import "fmt"

func main() {
	var T int
	fmt.Scanf("%d", &T)
	for i := 0; i < T; i++ {
		var Val int
		fmt.Scanf("%d", &Val)
		fmt.Println(1, Val-1)
	}
}

package main

import "fmt"

func main()  {
	var T, x int
	_, _ = fmt.Scanf("%d", &T)
	for ;T > 0; T-- {
		_, _ = fmt.Scanf("%d",&x)
		fmt.Println(1,x-1)
	}
}


package main

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

func Solve(input io.Reader) (result string) {
	var first []byte
	var second []byte
	var origin []byte
	fmt.Fscan(input, &first, &second, &origin)

	dict := make([]byte, 255)
	for i := range first {
		dict[first[i]] = second[i]
		dict[first[i]-32] = second[i] - 32
	}
	for i := '0'; i <= '9'; i++ {
		dict[i] = byte(i)
	}
	preResult := make([]byte, len(origin))
	for i := range origin {
		preResult[i] = dict[origin[i]]
	}
	result = string(preResult) + "\n"
	return
}

func main() {
	fmt.Print(Solve(os.Stdin))
}

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() {
	var a, b, c string
	for I(&a, &b, &c) == nil {
		solve(a, b, c)
	}
	w.Flush()
}

func solve(a, b, c string) {
	m := make(map[rune]byte)
	cc := make([]byte, len(c))
	for i, ch := range a {
		m[ch] = b[i]
	}
	for i, ch := range c {
		if o, ok := m[ch]; ok {
			cc[i] = o
		} else if o, ok := m[ch+32]; ok {
			cc[i] = o - 32
		} else {
			cc[i] = c[i]
		}
	}
	O(string(cc), "\n")
}

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	a := *readString(reader)
	b := *readString(reader)
	s := *readString(reader)

	//fmt.Println(a)
	//fmt.Println(b)
	//fmt.Println(s)

	m := make(map[byte]byte)
	for i:=0; i<len(a); i++ {
		m[a[i]] = b[i]
		m[a[i]-32] = b[i] -32
	}

	for i:=0; i<len(s); i++ {
		c, ok := m[s[i]]
		if !ok {
			fmt.Print(string(s[i]))
		} else {
			fmt.Print(string(c))
		}
	}
	fmt.Println()

}

func readString(nr *bufio.Reader) *string {
	line, _, err := nr.ReadLine()
	if err!=nil {
		panic(err)
	}
	s := string(line)
	return &s
}

func readN() int {
	var a int
	fmt.Scan(&a)
	//a = 100000

	return a
}

func readA(n int) *[]int {
	a := make([]int, n)

	reader := bufio.NewReader(os.Stdin)

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

	return &a
}

package main

import (
	"fmt"
	"os"
)

func main() {
	var a, b, text []byte
	fmt.Fscan(os.Stdin, &a, &b, &text)
	m := make(map[byte]byte)
	for i := range a {
		m[a[i]] = b[i]
		m[a[i] - 32] = b[i] - 32
	}
	for i := range text {
	    if text[i] >= '0' && text[i] <= '9' {
	        fmt.Printf("%c", text[i])
	    } else {
		    fmt.Printf("%c", m[text[i]])
	    }
	}
}

package main

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

func solve() {
	a := readString()
	b := readString()
	text := readString()
	m := make(map[rune]rune)
	for k, v := range a {
		m[v] = rune(b[k])
		m[unicode.ToUpper(v)] = unicode.ToUpper(rune(b[k]))
	}
	var buffer bytes.Buffer
	for _, v := range text {
		if to, ok := m[v]; ok {
			buffer.WriteRune(to)
		} else {
			buffer.WriteRune(v)
		}

	}
	fmt.Println(buffer.String())
}

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

var scanner *bufio.Scanner

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

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

// IO

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

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
	v, _ := strconv.ParseInt(readString(), 10, 64)
	return v
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = readInt64()
	}
	return res
}

package main

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

func main() {
    reader := bufio.NewReader(os.Stdin)
    layoutA, _ := reader.ReadString('\n')
    layoutB, _ := reader.ReadString('\n')
    text, _ := reader.ReadString('\n')

    mappingA := make(map[rune]int)
    lettersA := strings.Split(layoutA, "")
    for i, s := range lettersA {
        for _, c := range s {
            mappingA[c] = i
        }
    }
    var lettersB []rune
    lettersB = make([]rune, len(lettersA), len(lettersA))
    for i, s := range strings.Split(layoutB, "") {
        for _, c := range s {
            lettersB[i] = c
        }
    }

    for _, c := range text {
        if unicode.IsDigit(c) {
            fmt.Printf("%c", c)
        } else if unicode.IsUpper(c) {
            j := mappingA[unicode.ToLower(c)]
            fmt.Printf("%c", unicode.ToUpper(lettersB[j]))
        } else {
            j := mappingA[c]
            fmt.Printf("%c", lettersB[j])
        }
    }

}

package main

import (
	"fmt"
	"strings"
)

func main() {
	var first, second, result string

	fmt.Scan(&first)
	fmt.Scan(&second)
	fmt.Scan(&result)

	splited := strings.Split(result, "")
	first = strings.ToLower(first)

	var finallText string
	for _, letter := range splited {

		index := strings.Index(first, strings.ToLower(letter))

		if index < 0 {
			finallText += letter
		} else {
			current := string(second[index])
			if letter == strings.ToUpper(letter) {
				current = strings.ToUpper(current)
			}

			finallText += current
		}

	}

	fmt.Println(finallText)
}

package main

import (
	"fmt"
	"strings"
)

func main() {
	var first, second, result string

	fmt.Scan(&first)
	fmt.Scan(&second)
	fmt.Scan(&result)

	splited := strings.Split(result, "")

	first += "1234567890"
	second += "1234567890"

	var finallText string
	for _, letter := range splited {

		index := strings.Index(first, strings.ToLower(letter))

		if letter == strings.ToUpper(letter) {
			finallText += strings.ToUpper(string(second[index]))
		} else {
			finallText += string(second[index])
		}
	}

	fmt.Println(finallText)
}

package main

import "fmt"
import "strings"

func main() {
	var f1 string
	var f2 string
	var s  string

	var m = make(map[string]string)

	fmt.Scanf("%s\n", &f1)
	fmt.Scanf("%s\n",   &f2)
	fmt.Scanf("%s\n",   &s)

	for i, c := range f1 {
		m[string(c)] = string(f2[i])
		m[strings.ToUpper(string(c))] = strings.ToUpper(string(f2[i]))
	}

	var ret string
	for _, c := range s {
		c2, ok := m[string(c)]
		if ok {
			ret += string(c2)
		} else {
			ret += string(c)
		}
	}

	fmt.Printf("%s\n", ret)
}

package main

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

func main() {
	sc := NewScanner()
	A := sc.NextLine()
	B := sc.NextLine()

	mp := map[byte]byte{}
	for i, v := range []byte(A) {
		mp[v] = B[i]
	}
	C := sc.NextLine()

	for _, v := range []byte(C) {

		t := bytes.ToLower([]byte{v})[0]
		a, ok := mp[t]
		if ok {
			if t != v {
				a = bytes.ToUpper([]byte{a})[0]
			}

			fmt.Print(string(a))
		} else {
			fmt.Print(string(v))
		}
	}
	fmt.Println()

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

package main

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

func fillKeys(keys *map[byte]byte, firstLayout, secondLayout string) {
	*keys = make(map[byte]byte, 0)
	for i := 0; i < len(firstLayout); i++ {
		(*keys)[firstLayout[i]] = secondLayout[i]
	}
}

func correctLayout(keys map[byte]byte, text string) string {
	return strings.Map(func(r rune) rune {
		if val, ok := keys[byte(r)]; ok {
			return rune(val)
		} else if val, ok := keys[byte(unicode.ToLower(r))]; ok {
			return unicode.ToUpper(rune(val))
		}

		return r
	}, text)
}

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

	var keys map[byte]byte
	var firstLayout, secondLayout, text string

	fmt.Fscan(reader, &firstLayout, &secondLayout, &text)

	fillKeys(&keys, firstLayout, secondLayout)

	fmt.Println(correctLayout(keys, text))
}

package main

import (
	"fmt"
)

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

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

func main() {

	var pos [26]int
	var kb1 string
	var kb2 string
	var msg string

	// kb1 = "qwertyuiopasdfghjklzxcvbnm"
	// kb2 = "veamhjsgqocnrbfxdtwkylupzi"
	// msg = "TwccpQZAvb2017"

	fmt.Scan(&kb1)
	fmt.Scan(&kb2)
	fmt.Scan(&msg)

	for i, c := range kb1 {
		j := c-'a'
		pos[j] = i
		// pos[0] = i
	}

	for _, c := range msg {
		if (digit(c)) {
			fmt.Printf("%c", c)
		} else if (upperCase(c)) {
			j := c - 'A'
			// fmt.Printf("%c %d\n", c, j)
			fmt.Printf("%c", kb2[pos[j]] - 32)
		} else {
			j := c - 'a'
			// fmt.Printf("%c %d\n", c, j)
			fmt.Printf("%c", kb2[pos[j]])
		}
	}
}

package main

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

func Solve(input io.Reader) (result string) {
	var first []byte
	var second []byte
	var origin []byte
	fmt.Fscan(input, &first, &second, &origin)

	dict := make([]byte, 255)
	for i := range first {
		dict[first[i]] = second[i]
		dict[first[i]-32] = second[i] - 32
	}
	for i := '0'; i < '9'; i++ {
		dict[i] = byte(i)
	}
	preResult := make([]byte, len(origin))
	for i := range origin {
		preResult[i] = dict[origin[i]]
	}
	result = string(preResult) + "\n"
	return
}

func main() {
	fmt.Print(Solve(os.Stdin))
}

package main

import "fmt"
import "strings"

func main() {
	var f1 string
	var f2 string
	var s  string

	var m = make(map[string]string)

	fmt.Scanf("%s\n", &f1)
	fmt.Scanf("%s",   &f2)
	fmt.Scanf("%s",   &s)

	for i, c := range f1 {
		m[string(c)] = string(f2[i])
		m[strings.ToUpper(string(c))] = strings.ToUpper(string(f2[i]))
	}

	var ret string
	for _, c := range s {
		c2, ok := m[string(c)]
		if ok {
			ret += string(c2)
		} else {
			ret += string(c)
		}
	}

	fmt.Printf("%s", ret)
}