package main

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

// github.com/EndlessCheng/codeforces-go
func CF1483D(_r io.Reader, out io.Writer) {
	in := bufio.NewReader(_r)
	var n, m, v, w, wt, q, ans int
	Fscan(in, &n, &m)
	type edge struct{ v, w, wt int }
	es := make([]edge, m)
	dis := make([][]int, n)
	for i := range dis {
		dis[i] = make([]int, n)
		for j := range dis[i] {
			dis[i][j] = 1e9
		}
		dis[i][i] = 0
	}
	for i := range es {
		Fscan(in, &v, &w, &wt)
		v--
		w--
		es[i] = edge{v, w, wt}
		dis[v][w] = wt
		dis[w][v] = wt
	}
	for k := range dis {
		for i := range dis {
			for j := range dis {
				dis[i][j] = min(dis[i][j], dis[i][k]+dis[k][j])
			}
		}
	}

	g := make([][]int, n)
	for i := range g {
		g[i] = make([]int, n)
	}
	for Fscan(in, &q); q > 0; q-- {
		Fscan(in, &v, &w, &wt)
		v--
		w--
		g[v][w] = wt
		g[w][v] = wt
	}
	for k := range dis {
		for i := range dis {
			for j := range dis {
				g[i][k] = max(g[i][k], g[i][j]-dis[k][j])
				g[k][j] = max(g[k][j], g[i][j]-dis[i][k])
			}
		}
	}
	for _, e := range es {
		if e.wt <= g[e.v][e.w] {
			ans++
		}
	}
	Fprint(out, ans)
}

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

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

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1483D(_r io.Reader, out io.Writer) {
	in := bufio.NewReader(_r)
	min := func(a, b int64) int64 {
		if a < b {
			return a
		}
		return b
	}
	max := func(a, b int64) int64 {
		if a > b {
			return a
		}
		return b
	}

	var n, m, v, w, wt, q, ans int
	Fscan(in, &n, &m)
	type edge struct{ v, w, wt int }
	es := make([]edge, m)
	d := make([][]int64, n)
	for i := range d {
		d[i] = make([]int64, n)
		for j := range d[i] {
			d[i][j] = 1e18
		}
		d[i][i] = 0
	}
	for i := range es {
		Fscan(in, &v, &w, &wt)
		v--
		w--
		es[i] = edge{v, w, wt}
		d[v][w] = int64(wt)
		d[w][v] = int64(wt)
	}
	for k := range d {
		for i := range d {
			for j := range d {
				d[i][j] = min(d[i][j], d[i][k]+d[k][j])
			}
		}
	}

	upp := make([][]int64, n)
	for i := range upp {
		upp[i] = make([]int64, n)
	}
	for Fscan(in, &q); q > 0; q-- {
		Fscan(in, &v, &w, &wt)
		v--
		w--
		upp[v][w] = int64(wt)
		upp[w][v] = int64(wt)
	}
	// 修改枚举方式，找一侧和另一侧的最大值
	for k := range d {
		for i := range d {
			for j := range d {
				upp[i][k] = max(upp[i][k], upp[i][j]-d[k][j])
				upp[k][j] = max(upp[k][j], upp[i][j]-d[i][k])
			}
		}
	}
	for _, e := range es {
		if int64(e.wt) <= upp[e.v][e.w] {
			ans++
		}
	}
	Fprint(out, ans)
}

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

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1483D(_r io.Reader, out io.Writer) {
	in := bufio.NewReader(_r)
	var n, m, v, w, wt, q, ans int
	Fscan(in, &n, &m)
	type edge struct{ v, w, wt int }
	es := make([]edge, m)
	dis := make([][]int, n)
	for i := range dis {
		dis[i] = make([]int, n)
		for j := range dis[i] {
			dis[i][j] = 1e9
		}
		dis[i][i] = 0
	}
	for i := range es {
		Fscan(in, &v, &w, &wt)
		v--
		w--
		es[i] = edge{v, w, wt}
		dis[v][w] = wt
		dis[w][v] = wt
	}
	for k := range dis {
		for i := range dis {
			for j := range dis {
				dis[i][j] = min(dis[i][j], dis[i][k]+dis[k][j])
			}
		}
	}

	g := make([][]int, n)
	for i := range g {
		g[i] = make([]int, n)
	}
	for Fscan(in, &q); q > 0; q-- {
		Fscan(in, &v, &w, &wt)
		v--
		w--
		g[v][w] = wt
		g[w][v] = wt
	}
	for k, dk := range dis {
		for i, di := range dis {
			for j, d := range dk {
				g[i][k] = max(g[i][k], g[i][j]-d)
				g[k][j] = max(g[k][j], g[i][j]-di[k])
			}
		}
	}
	for _, e := range es {
		if e.wt <= g[e.v][e.w] {
			ans++
		}
	}
	Fprint(out, ans)
}

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

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


package main

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

// github.com/EndlessCheng/codeforces-go
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	mp := [3][4]int64{{0, 1, 2, 3}, {0, 2, 3, 1}, {0, 3, 1, 2}}

	var t, n int64
	for Fscan(in, &t); t > 0; t-- {
		Fscan(in, &n)
		n--
		tp := n % 3
		i := 0
		for n /= 3; 1<<i <= n; i += 2 {
			n -= 1 << i
		}
		tail := int64(0)
		for i := 0; n > 0; n >>= 2 {
			tail |= mp[tp][n&3] << i
			i += 2
		}
		Fprintln(out, int64(1)<<i*(tp+1)|tail)
	}
}

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1338C(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	mp := [3][4]int64{{0, 1, 2, 3}, {0, 2, 3, 1}, {0, 3, 1, 2}}

	var t, n int64
	for Fscan(in, &t); t > 0; t-- {
		Fscan(in, &n)
		n--
		tp := n % 3
		n /= 3
		i := 0
		for ; 1<<i <= n; i += 2 {
			n -= 1 << i
		}
		tail := int64(0)
		for i := 0; n > 0; n >>= 2 {
			tail |= mp[tp][n&3] << i
			i += 2
		}
		Fprintln(out, int64(1)<<i*(tp+1)|tail)
	}
}

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

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1338C(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	mp := [3][4]int64{{0, 1, 2, 3}, {0, 2, 3, 1}, {0, 3, 1, 2}}

	var t, n int64
	for Fscan(in, &t); t > 0; t-- {
		Fscan(in, &n)
		n--
		tp := n % 3
		n /= 3
		sum := int64(0)
		low := int64(1)
		for i := 0; sum+1<<i <= n; i += 2 {
			sum += 1 << i
			low = 1 << (i + 2)
		}
		if tp == 1 {
			low <<= 1
		} else if tp == 2 {
			low |= low << 1
		}
		m := int64(0)
		i := 0
		for n -= sum; n > 0; n >>= 2 {
			m |= mp[tp][n&3] << i
			i += 2
		}
		Fprintln(out, low|m)
	}
}

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

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1338C(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	mp := [3][4]int64{{0, 1, 2, 3}, {0, 2, 3, 1}, {0, 3, 1, 2}}

	var t, n int64
	for Fscan(in, &t); t > 0; t-- {
		Fscan(in, &n)
		n--
		tp := n % 3
		i := 0
		for n /= 3; 1<<i <= n; i += 2 {
			n -= 1 << i
		}
		tail := int64(0)
		for i := 0; n > 0; n >>= 2 {
			tail |= mp[tp][n&3] << i
			i += 2
		}
		Fprintln(out, int64(1)<<i*(tp+1)|tail)
	}
}

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

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1338C(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	mp := [3][4]int64{{0, 1, 2, 3}, {0, 2, 3, 1}, {0, 3, 1, 2}}

	var t, n int64
	for Fscan(in, &t); t > 0; t-- {
		Fscan(in, &n)
		n--
		tp := n % 3
		n /= 3
		i := 0
		for ; 1<<i <= n; i += 2 {
			n -= 1 << i
		}
		head := int64(1) << i
		if tp == 1 {
			head <<= 1
		} else if tp == 2 {
			head |= head << 1
		}
		tail := int64(0)
		for i := 0; n > 0; n >>= 2 {
			tail |= mp[tp][n&3] << i
			i += 2
		}
		Fprintln(out, head|tail)
	}
}

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

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1338C(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	mp := [3][4]int64{{0, 1, 2, 3}, {0, 2, 3, 1}, {0, 3, 1, 2}}

	var t, n int64
	for Fscan(in, &t); t > 0; t-- {
		Fscan(in, &n)
		n--
		tp := n % 3
		n /= 3
		sum := int64(0)
		low := int64(1)
		for i := 0; sum+1<<i <= n; i += 2 {
			sum += 1 << i
			low = 1 << (i + 2)
		}
		if tp == 1 {
			low <<= 1
		} else if tp == 2 {
			low |= low << 1
		}
		m := int64(0)
		for n -= sum; n > 0; n >>= 2 {
			m = m<<2 | mp[tp][n&3]
		}
		Fprintln(out, low|m)
	}
}

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


package main

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

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

	var n, k int
	Fscan(in, &n, &k)
	g := make([][]int, n)
	for i := 0; i < n-1; i++ {
		var v, w int
		Fscan(in, &v, &w)
		v--
		w--
		g[v] = append(g[v], w)
		g[w] = append(g[w], v)
	}

	dep := make([]int, n)
	size := make([]int, n)
	var f func(v, fa, d int) int
	f = func(v, fa, d int) int {
		dep[v] = d
		sz := 1
		for _, w := range g[v] {
			if w != fa {
				sz += f(w, v, d+1)
			}
		}
		size[v] = sz
		return sz
	}
	f(0, -1, 0)

	vs := make([]int, n)
	for i := range vs {
		vs[i] = i
	}
	sort.Slice(vs, func(_i, _j int) bool {
		vi, vj := vs[_i], vs[_j]
		return dep[vi]-size[vi] > dep[vj]-size[vj]
	})
	used := make([]bool, n)
	for _, v := range vs[:k] {
		used[v] = true
	}

	ans := int64(0)
	var f2 func(v, fa int)
	f2 = func(v, fa int) {
		if used[v] {
			ans+=int64(dep[v])*int64(size[v])
			return
		}
		for _, w := range g[v] {
			if w != fa {
				f2(w,v)
			}
		}
	}
	f2(0, -1)

	Fprintln(out, ans)
}

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

/*
URL:
https://codeforces.com/problemset/problem/1336/A
*/

package main

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

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

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

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

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

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

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

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

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

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

var (
	n, k  int
	G     [200000 + 50][]int
	depth []int
	size  []int
	det   []int

	ans int64
)

func main() {
	n, k = ReadInt2()
	for i := 0; i < n-1; i++ {
		u, v := ReadInt2()
		u--
		v--

		G[u] = append(G[u], v)
		G[v] = append(G[v], u)
	}

	depth, size, det = make([]int, n), make([]int, n), make([]int, n)

	dfs(0, -1, 1)
	PrintfDebug("depth: %v\n", depth)
	PrintfDebug("size: %v\n", size)
	PrintfDebug("det: %v\n", det)

	sort.Sort(sort.Reverse(sort.IntSlice(det)))
	for i := 0; i < n-k; i++ {
		ans += int64(det[i])
	}
	fmt.Println(ans)
}

// 部分木のノード数を返す
func dfs(cid, pid, cd int) int {
	res := 1

	for _, nid := range G[cid] {
		if nid == pid {
			continue
		}

		res += dfs(nid, cid, cd+1)
	}

	depth[cid] = cd
	size[cid] = res
	det[cid] = size[cid] - depth[cid]

	return res
}

// func dfs(cid, pid, cdepth int) {
// 	depth[cid] = cdepth

// 	for _, nid := range G[cid] {
// 		if nid == pid {
// 			continue
// 		}

// 		dfs(nid, cid, cdepth+1)
// 	}
// }

// func calc(cid, pid int, score int64) {
// 	if !flags[cid] {
// 		score++
// 	} else {
// 		ans += score
// 	}

// 	for _, nid := range G[cid] {
// 		if nid == pid {
// 			continue
// 		}

// 		calc(nid, cid, score)
// 	}
// }

// type Node struct {
// 	id, depth, numc int
// }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	return res
}

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

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

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

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

	return string(res)
}

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

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

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

	return string(res)
}

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

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

package main

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

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }
// https://www.codementor.io/@tucnak/using-golang-for-competitive-programming-h8lhvxzt3

func main() {
	var N int
	var K int
	scanf("%d %d\n", &N, &K)

	graph := make([][]int, N + 1)

	for i := 0; i < N - 1; i++ {
		var a, b int
		scanf("%d %d\n", &a, &b)
		if len(graph[a]) == 0 {
			graph[a] = make([]int, 0)
		}
		if len(graph[b]) == 0 {
			graph[b] = make([]int, 0)
		}
		graph[a] = append(graph[a], b)
		graph[b] = append(graph[b], a)
	}

	subtree_sum := make([]int64, N + 1)
	len_from_root := make([]int64, N + 1)
	visited := make([]int, N + 1)
	visited2 := make([]int, N + 1)

	depth(1, 0, len_from_root, visited, graph)
	compute_subset_size(1, subtree_sum, visited2, graph)
	nodes := make([]int, 0)
	for i := 1; i <= N; i++ {
		nodes = append(nodes, i)
	}

	sort.Slice(nodes, func(i, j int) bool {
		x := nodes[i]
		y := nodes[j]
		a := subtree_sum[x] - 1 - len_from_root[x]
		b := subtree_sum[y] - 1 - len_from_root[y]

		return a > b
	})

	var ans int64
	ans = 0

	for k := 0; k < N - K; k++ {
		i := nodes[k]
		ans += subtree_sum[i] - 1 - len_from_root[i]
	}

	defer writer.Flush()
	printf("%d\n", ans)
}

func depth(node int, d int64, dd []int64, visited []int, graph [][]int) {
	visited[node] = 1
	dd[node] = d
	neighbors := graph[node]
	for _, nei := range neighbors {
		if visited[nei] != 1 {
			depth(nei, d + 1, dd, visited, graph)
		}
	}
}

func compute_subset_size(node int, subset_size []int64, visited []int, graph [][]int) int64 {
	visited[node] = 1
	var s int64
	s = 1

	neighbors := graph[node]

	for _, nei := range neighbors {
		if visited[nei] != 1 {
			s += compute_subset_size(nei, subset_size, visited, graph)
		}
	}

	subset_size[node] = s
	return s
}

package main

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

const N = 200200
var n, k int
var a[][] int
var sub[N] int
var dp[] int
var visit[N] bool

func dfs(u int)  {
	visit[u] = true
	sub[u] = 1
	for _, v := range a[u] {
		if visit[v] == false {
			dp[v] = dp[u] + 1
			dfs(v)
			sub[u] += sub[v]
		}
	}
}

func main()  {
	var reader = bufio.NewReader(os.Stdin)
	var writer = bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	fmt.Fscanf(reader, "%d %d\n", &n, &k)

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

	for i := 1; i < n; i++ {
		var u, v int
		fmt.Fscanf(reader, "%d %d\n", &u, &v)
		u--
		v--
		a[u] = append(a[u], v)
		a[v] = append(a[v], u)
	}
	dp = make([]int, n)
	dfs(0)

	//fmt.Println(dp)

	for i := 0; i < n; i++ {
		dp[i] = sub[i] - dp[i] - 1
	}

	sort.Ints(dp)
	//fmt.Println(dp)

	var ret = int64(0)
	var d = n - k
	for i := n - 1; i >= n - d; i-- {
		ret += int64(dp[i])
	}

	fmt.Fprintf(writer, "%d\n", ret)
}

package main

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

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

type writerImpl struct {
	*bufio.Writer
}

func NewBufferedWriter(writer io.Writer) BufferedWriter {
	return &writerImpl{Writer: bufio.NewWriter(writer)}
}

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

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

type WordScanner interface {
	NextInt() int
	NextInt64() int64
	NextString() string
}

type wordScannerImpl struct {
	*bufio.Scanner
}

func NewWordScanner(reader io.Reader) WordScanner {
	s := bufio.NewScanner(reader)
	s.Split(bufio.ScanWords)
	// adjust the following size as needed
	// 2 << 17 is good enough to scan strings of len 2*10^5
	// it could go as high as 2 << 26 before cf judge breaks
	size := 2 << 20
	buf := make([]byte, size)
	s.Buffer(buf, size)
	return &wordScannerImpl{Scanner: s}
}

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

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

func (impl *wordScannerImpl) NextString() string {
	impl.Scan()
	return impl.Text()
}

var reader = NewWordScanner(os.Stdin)
var writer = NewBufferedWriter(os.Stdout)

type node struct {
	val  int64
	rest []*node
}

func main() {
	defer writer.Flush()
	n, k := reader.NextInt64(), reader.NextInt64()
	nodes := map[int64]*node{}
	for ; n > 1; n-- {
		u, v := reader.NextInt64(), reader.NextInt64()
		if nodes[u] == nil {
			nodes[u] = &node{val: u, rest: []*node{}}
		}
		if nodes[v] == nil {
			nodes[v] = &node{val: v, rest: []*node{}}
		}
		nodes[u].rest = append(nodes[u].rest, nodes[v])
		nodes[v].rest = append(nodes[v].rest, nodes[u])
	}
	explored := map[*node]bool{nodes[1]: true}
	vals := []int64{}
	var explore func(*node, int64) int64
	explore = func(n *node, d int64) int64 {
        nChild := int64(0)
        for _, n := range n.rest {
            if !explored[n] {
                explored[n] = true
                nChild += explore(nodes[n.val], d+1)
            }
        }
        vals = append(vals, d - 1 - nChild)
		return nChild+1
	}
    explore(nodes[1], 1)
	sort.Slice(vals, func(a, b int) bool {
		return vals[a] < vals[b]
	})
	//writer.Printf("%v\n", vals)
    ans := int64(0)
    ptr := len(vals)-1
    for ; k > 0; k-- {
        ans += vals[ptr]
        ptr--
    }
    writer.Printf("%d\n", ans)
}

package main

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

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

type writerImpl struct {
	*bufio.Writer
}

func NewBufferedWriter(writer io.Writer) BufferedWriter {
	return &writerImpl{Writer: bufio.NewWriter(writer)}
}

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

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

type WordScanner interface {
	NextInt() int
	NextInt64() int64
	NextString() string
}

type wordScannerImpl struct {
	*bufio.Scanner
}

func NewWordScanner(reader io.Reader) WordScanner {
	s := bufio.NewScanner(reader)
	s.Split(bufio.ScanWords)
	// adjust the following size as needed
	// 2 << 17 is good enough to scan strings of len 2*10^5
	// it could go as high as 2 << 26 before cf judge breaks
	size := 2 << 20
	buf := make([]byte, size)
	s.Buffer(buf, size)
	return &wordScannerImpl{Scanner: s}
}

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

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

func (impl *wordScannerImpl) NextString() string {
	impl.Scan()
	return impl.Text()
}

var reader = NewWordScanner(os.Stdin)
var writer = NewBufferedWriter(os.Stdout)

func main() {
	defer writer.Flush()
	n, k := reader.NextInt64(), reader.NextInt64()
	edges := make([][]int64, n)
	for i := int64(0); i < n-1; i++ {
		u, v := reader.NextInt64(), reader.NextInt64()
		edges[u-1] = append(edges[u-1], v-1)
		edges[v-1] = append(edges[v-1], u-1)
	}
	explored := map[int64]bool{0: true}
	vals := make([]int64, n)
	var dfs func(int64, int64) int64
	dfs = func(n int64, d int64) int64 {
		nChild := int64(0)
		for _, i := range edges[n] {
			if !explored[i] {
				explored[i] = true
				nChild += dfs(i, d+1)
			}
		}
		vals[n] = d - 1 - nChild
		return nChild + 1
	}
	dfs(0, 1)
	sort.Slice(vals, func(a, b int) bool {
		return vals[a] < vals[b]
	})
	ans := int64(0)
	ptr := len(vals) - 1
	for ; k > 0; k-- {
		ans += vals[ptr]
		ptr--
	}
	writer.Printf("%d\n", ans)
}

/*
URL:
https://codeforces.com/problemset/problem/1336/A
*/

package main

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

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

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

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

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

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

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

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

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

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

var (
	n, k  int
	G     [200000 + 50][]int
	depth []int
	flags []bool

	ans int64
)

func main() {
	n, k = ReadInt2()
	for i := 0; i < n-1; i++ {
		u, v := ReadInt2()
		u--
		v--

		G[u] = append(G[u], v)
		G[v] = append(G[v], u)
	}

	depth = make([]int, n)
	dfs(0, -1, 0)

	nodes := []Node{}
	for i := 0; i < n; i++ {
		var childlen int
		if i == 0 {
			childlen = len(G[i])
		} else {
			childlen = len(G[i]) - 1
		}
		nodes = append(nodes, Node{id: i, depth: depth[i], numc: childlen})
	}

	sort.SliceStable(nodes, func(i, j int) bool {
		if nodes[i].depth > nodes[j].depth {
			return true
		} else if nodes[i].depth < nodes[j].depth {
			return false
		} else {
			return nodes[i].numc < nodes[j].numc
		}
	})

	flags = make([]bool, n)
	for i := 0; i < k; i++ {
		flags[nodes[i].id] = true
	}

	calc(0, -1, 0)

	fmt.Println(ans)
}

func dfs(cid, pid, cdepth int) {
	depth[cid] = cdepth

	for _, nid := range G[cid] {
		if nid == pid {
			continue
		}

		dfs(nid, cid, cdepth+1)
	}
}

func calc(cid, pid int, score int64) {
	if !flags[cid] {
		score++
	} else {
		ans += score
	}

	for _, nid := range G[cid] {
		if nid == pid {
			continue
		}

		calc(nid, cid, score)
	}
}

type Node struct {
	id, depth, numc int
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	return res
}

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

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

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

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

	return string(res)
}

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

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

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

	return string(res)
}

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

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

package main

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

const N = 200200
var n, k int
var a[][] int
var sub[N] int
var dp[] int
var visit[N] bool

func dfs(u int)  {
	visit[u] = true
	sub[u] = 1
	for _, v := range a[u] {
		if visit[v] == false {
			dp[v] = dp[u] + 1
			dfs(v)
			sub[u] += sub[v]
		}
	}
}

func main()  {
	var reader = bufio.NewReader(os.Stdin)
	var writer = bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	fmt.Fscanf(reader, "%d %d\n", &n, &k)

	a = make([][]int, n + 1)
	for i := 1; i <= n; i++ {
		a[i] = make([]int, 0)
	}

	for i := 1; i < n; i++ {
		var u, v int
		fmt.Fscanf(reader, "%d %d\n", &u, &v)
		a[u] = append(a[u], v)
		a[v] = append(a[v], u)
	}
	dp = make([]int, n + 1)
	dfs(1)
	for i := 1; i <= n; i++ {
		dp[i] = dp[i] - sub[i] + 1
	}
	sort.Ints(dp)
	var ret = int64(0)

	for i := n; i >= n - k + 1; i-- {
		ret += int64(dp[i])
	}

	fmt.Fprintf(writer, "%d\n", ret)
}

package main

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

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }
// https://www.codementor.io/@tucnak/using-golang-for-competitive-programming-h8lhvxzt3

func main() {
	var N int
	var K int
	scanf("%d %d\n", &N, &K)

	graph := make([][]int, N + 1)

	for i := 0; i < N - 1; i++ {
		var a, b int
		scanf("%d %d\n", &a, &b)
		if len(graph[a]) == 0 {
			graph[a] = make([]int, 0)
		}
		if len(graph[b]) == 0 {
			graph[b] = make([]int, 0)
		}
		graph[a] = append(graph[a], b)
		graph[b] = append(graph[b], a)
	}

	subtree_sum := make([]int, N + 1)
	len_from_root := make([]int, N + 1)
	visited := make([]int, N + 1)
	visited2 := make([]int, N + 1)

	depth(1, 0, len_from_root, visited, graph)
	compute_subset_size(1, subtree_sum, visited2, graph)
	nodes := make([]int, 0)
	for i := 1; i <= N; i++ {
		nodes = append(nodes, i)
	}

	sort.Slice(nodes, func(i, j int) bool {
		x := nodes[i]
		y := nodes[j]
		a := subtree_sum[x] - 1 - len_from_root[x]
		b := subtree_sum[y] - 1 - len_from_root[y]

		return a > b
	})

	ans := 0

	for k := 0; k < N - K; k++ {
		i := nodes[k]
		ans += subtree_sum[i] - 1 - len_from_root[i]
	}

	defer writer.Flush()
	printf("%d\n", ans)
}

func depth(node int, d int, dd []int, visited []int, graph [][]int) {
	visited[node] = 1
	dd[node] = d
	neighbors := graph[node]
	for _, nei := range neighbors {
		if visited[nei] != 1 {
			depth(nei, d + 1, dd, visited, graph)
		}
	}
}

func compute_subset_size(node int, subset_size []int, visited []int, graph [][]int) int {
	visited[node] = 1
	s := 1

	neighbors := graph[node]

	for _, nei := range neighbors {
		if visited[nei] != 1 {
			s += compute_subset_size(nei, subset_size, visited, graph)
		}
	}

	subset_size[node] = s
	return s
}

package main

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

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

type writerImpl struct {
	*bufio.Writer
}

func NewBufferedWriter(writer io.Writer) BufferedWriter {
	return &writerImpl{Writer: bufio.NewWriter(writer)}
}

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

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

type WordScanner interface {
	NextInt() int
	NextInt64() int64
	NextString() string
}

type wordScannerImpl struct {
	*bufio.Scanner
}

func NewWordScanner(reader io.Reader) WordScanner {
	s := bufio.NewScanner(reader)
	s.Split(bufio.ScanWords)
	// adjust the following size as needed
	// 2 << 17 is good enough to scan strings of len 2*10^5
	// it could go as high as 2 << 26 before cf judge breaks
	size := 2 << 20
	buf := make([]byte, size)
	s.Buffer(buf, size)
	return &wordScannerImpl{Scanner: s}
}

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

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

func (impl *wordScannerImpl) NextString() string {
	impl.Scan()
	return impl.Text()
}

var reader = NewWordScanner(os.Stdin)
var writer = NewBufferedWriter(os.Stdout)

type node struct {
	val  int64
	rest []*node
}

func main() {
	defer writer.Flush()
	n, k := reader.NextInt64(), reader.NextInt64()
	nodes := map[int64]*node{}
	for ; n > 1; n-- {
		u, v := reader.NextInt64(), reader.NextInt64()
		if nodes[u] == nil {
			nodes[u] = &node{val: u, rest: []*node{}}
		}
		if nodes[v] == nil {
			nodes[v] = &node{val: v, rest: []*node{}}
		}
		nodes[u].rest = append(nodes[u].rest, nodes[v])
		nodes[v].rest = append(nodes[v].rest, nodes[u])
	}
	explored := map[*node]bool{nodes[1]: true}
	toExplore := []*node{nodes[1]}
	depths := []int64{}
	for len(toExplore) > 0 {
		currN := int64(0)
		next := []*node{}
		for _, e := range toExplore {
			hasChild := false
			for _, n := range e.rest {
				if !explored[n] {
					next = append(next, n)
					explored[n] = true
					hasChild = true
				}
			}
			if !hasChild {
				currN++
			}
		}
		depths = append(depths, currN)
		toExplore = next
	}
	//writer.Printf("%v\n", depths)
	weights := []int64{}
	for i, d := range depths {
		for ; d > 0; d-- {
			start := int64(i)
			for start > 0 {
				weights = append(weights, start)
				start -= 2
			}
		}
	}
	sort.Slice(weights, func(a, b int) bool {
		return weights[a] < weights[b]
	})
	//writer.Printf("%v\n", weights)
	ret := int64(0)
    ptr := len(weights)-1
    for {
        if k == 0 {
            break
        }
        ret += weights[ptr]
        ptr--
        k--
    }
	writer.Printf("%d\n", ret)
}

package main

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

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

type writerImpl struct {
	*bufio.Writer
}

func NewBufferedWriter(writer io.Writer) BufferedWriter {
	return &writerImpl{Writer: bufio.NewWriter(writer)}
}

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

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

type WordScanner interface {
	NextInt() int
	NextInt64() int64
	NextString() string
}

type wordScannerImpl struct {
	*bufio.Scanner
}

func NewWordScanner(reader io.Reader) WordScanner {
	s := bufio.NewScanner(reader)
	s.Split(bufio.ScanWords)
	// adjust the following size as needed
	// 2 << 17 is good enough to scan strings of len 2*10^5
	// it could go as high as 2 << 26 before cf judge breaks
	size := 2 << 20
	buf := make([]byte, size)
	s.Buffer(buf, size)
	return &wordScannerImpl{Scanner: s}
}

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

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

func (impl *wordScannerImpl) NextString() string {
	impl.Scan()
	return impl.Text()
}

var reader = NewWordScanner(os.Stdin)
var writer = NewBufferedWriter(os.Stdout)

type node struct {
	val  int64
	rest []*node
}

func main() {
	defer writer.Flush()
	n, k := reader.NextInt64(), reader.NextInt64()
	nodes := map[int64]*node{}
	for ; n > 1; n-- {
		u, v := reader.NextInt64(), reader.NextInt64()
		if nodes[u] == nil {
			nodes[u] = &node{val: u, rest: []*node{}}
		}
		if nodes[v] == nil {
			nodes[v] = &node{val: v, rest: []*node{}}
		}
		nodes[u].rest = append(nodes[u].rest, nodes[v])
		nodes[v].rest = append(nodes[v].rest, nodes[u])
	}
	explored := map[*node]bool{nodes[1]: true}
	toExplore := []*node{nodes[1]}
	depths := []int64{}
	for len(toExplore) > 0 {
		currN := int64(0)
		next := []*node{}
		for _, e := range toExplore {
			hasChild := false
			for _, n := range e.rest {
				if !explored[n] {
					next = append(next, n)
					explored[n] = true
					hasChild = true
				}
			}
			if !hasChild {
				currN++
			}
		}
		depths = append(depths, currN)
		toExplore = next
	}
	//writer.Printf("%v\n", depths)
	weights := []int64{}
	for i, d := range depths {
		for ; d > 0; d-- {
			start := int64(i)
			for start > 0 {
				weights = append(weights, start)
				start -= 2
			}
		}
	}
	sort.Slice(weights, func(a, b int) bool {
		return weights[a] < weights[b]
	})
	//writer.Printf("%v\n", weights)
	ret := int64(0)
    ptr := len(weights)-1
    for {
        if k <= 0 || ptr < 0 {
            break
        }
        ret += weights[ptr]
        ptr--
        k--
    }
	writer.Printf("%d\n", ret)
}


package main

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

func main() {
    scanner := bufio.NewScanner(os.Stdin)
    scanner.Split(bufio.ScanWords)
    var n int
    fmt.Scan(&n)
    min, ans := 1000000001, -1
    for i := 0; i < n; i++ {
        scanner.Scan()
        a, _ := strconv.Atoi(scanner.Text())
        if min == a {
            ans = -1
        } else if min > a {
            min = a
            ans = i+1
        }
    }
    if ans == -1 { fmt.Println("Still Rozdil") } else { fmt.Println(ans) }
}

package main

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

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

	n := io.NextInt()
	a := io.NextInts(n)
	mn := int(1e9)

	for _, i := range a {
		if i < mn {
			mn = i
		}
	}
	c := 0
	for _, i := range a {
		if i == mn {
			c++
		}
	}
	if c > 1 {
		io.Println("Still Rozdil")
		return
	}
	for j, i := range a {
		if i == mn {
			io.Println(j + 1)
		}
	}
}

type FastIO struct {
	*bufio.Reader
	*bufio.Writer
	c [1]byte
}

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

func (f *FastIO) readC() byte {
	f.Read(f.c[:])
	return f.c[0]
}

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

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

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

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

func (f *FastIO) Print(a ...interface{}) {
	fmt.Fprint(f.Writer, a...)
}

func (f *FastIO) PrintInts(a ...int) {
	if len(a) > 0 {
		f.Print(a[0])
		for _, x := range a[1:] {
			f.Print(" ", x)
		}
	}
}

func (f *FastIO) PrintlnInts(a ...int) {
	f.PrintInts(a...)
	f.Println()
}

package main

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

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

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

var n int

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

	a := make([]int, n)
	m := make(map[int]int)

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

	if n == 1 {
		printf("%d\n", 1)
		return
	}

	sort.Ints(a)
	if a[0] == a[1] {
		printf("Still Rozdil\n")
	} else {
		printf("%d\n", m[a[0]])
	}
}

package main

import (
	"fmt"
	//"sort"
	//"unicode/utf8"
	"bufio"
	"os"
	"strconv"
)

func main() {
	var i,j,l,m,n,k int64
	k=1<<30
	fmt.Scan(&n)
	input := bufio.NewScanner(os.Stdin)
    	input.Split(bufio.ScanWords)
	for i=1;i<=n;i++ {
	       	input.Scan()
	       	aa, _ := strconv.Atoi(input.Text())
	       	m=int64(aa)
	       	if m<k {
	       		k=m
	       		j=i
	       		l=1
	       	} else if m==k {
	       		l=0
	       	}
	}
	if l!=0 {
		fmt.Println(j)
	} else {
		fmt.Println("Still Rozdil")
	}

}

package main

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

func scanInt(scanner *bufio.Scanner) int {
	scanner.Scan()
	x, _ := strconv.Atoi(scanner.Text())
	return x
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	n := scanInt(scanner)
	best_i, best_x, best_count := 0, scanInt(scanner), 1
	for i := 1; i < n; i++ {
		x := scanInt(scanner)
		if x == best_x {
			best_count++
		} else if x < best_x {
			best_i, best_x, best_count = i, x, 1
		}
	}
	if best_count == 1 {
		writer.WriteString(fmt.Sprintf("%d\n", best_i+1))
	} else {
		writer.WriteString("Still Rozdil\n")
	}
}

package main

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

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

	n := io.NextInt()
	a := io.NextInts(n)
	sort.Ints(a)

	if n > 1 && a[0] == a[1] {
		io.Println("Still Rozdil")
	} else {
		io.Println(a[0])
	}

}

type FastIO struct {
	*bufio.Reader
	*bufio.Writer
	c [1]byte
}

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

func (f *FastIO) readC() byte {
	f.Read(f.c[:])
	return f.c[0]
}

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

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

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

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

func (f *FastIO) Print(a ...interface{}) {
	fmt.Fprint(f.Writer, a...)
}

func (f *FastIO) PrintInts(a ...int) {
	if len(a) > 0 {
		f.Print(a[0])
		for _, x := range a[1:] {
			f.Print(" ", x)
		}
	}
}

func (f *FastIO) PrintlnInts(a ...int) {
	f.PrintInts(a...)
	f.Println()
}

package main

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

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

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

var n int

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

	a := make([]int, n)
	m := make(map[int]int)

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

	if n == 1 {
		printf("%d\n", a[0])
		return
	}

	sort.Ints(a)
	if a[0] == a[1] {
		printf("Still Rozdil\n")
	} else {
		printf("%d\n", m[a[0]])
	}
}


package main

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

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

func CF1647A(in io.Reader, out io.Writer) {
	r := bufio.NewReader(in)
	w := bufio.NewWriter(out)
	defer w.Flush()

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

		if n <= 2 {
			fmt.Fprintln(w, n)
			continue
		}

		body := make([]byte, 0)
		left, right := n/3, n%3
		if left > 0 {
			body = append(body, bytes.Repeat([]byte("21"), int(left))...)
		}
		switch right {
		case 1:
			body = append([]byte{'1'}, body...)
		case 2:
			body = append(body, []byte{'2'}...)
		}
		fmt.Fprintln(w, string(body))
	}

}

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

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

package main

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

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

	var T, n int
	for Fscan(in, &T); T > 0; T-- {
		if Fscan(in, &n); n%3 == 0 {
			Fprintln(out, strings.Repeat("21", n/3))
		} else if n%3 == 1 {
			Fprintln(out, strings.Repeat("12", n/3)+"1")
		} else {
			Fprintln(out, strings.Repeat("21", n/3)+"2")
		}
	}
}

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

package main

import "fmt"

func main() {
	var T, n int
	fmt.Scan(&T)
	for ; T > 0; T -- {
		fmt.Scan(&n)
		var v int
		if n % 3 > 0 {
			v = n % 3
			fmt.Print(v)
			n = n / 3 * 3
		}
		for i := 0; i < n/3; i ++ {
			if v == 2 {
				fmt.Print("12")
			} else {
				fmt.Print("21")
			}
		}
		fmt.Println()
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	var n, t int
	Fscan(in, &t)
	for t > 0 {
		Fscan(in, &n)
		if n%3 == 1 {
			Fprint(out, 1)
			n--
		}
		for n > 0 {
			Fprint(out, 2)
			n -= 2
			if n == 0 {
				break
			}
			Fprint(out, 1)
			n--
		}
		Fprintln(out, "")
		t--
	}
	out.Flush()
}

package main

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

func solve() {
	f := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	N, n := 0, 0
	fmt.Fscan(f, &N)
	for i := 0; i < N; i++ {
		fmt.Fscan(f, &n)
		if n%3 == 1 {
			fmt.Fprint(w, 1)
			n--
		}
		for n > 0 {
			fmt.Fprint(w, 2)
			n -= 2
			if n == 0 {
				break
			}
			fmt.Fprint(w, 1)
			n--
		}
		fmt.Fprintln(w, "")
	}
	w.Flush()
}

func main() {
	solve()
}

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 int
		fmt.Fscan(in, &n)
		if n%3 == 0 {
			for i := 0; i < n/3; i++ {
				fmt.Print("21")
			}
			fmt.Println("")
			continue
		}
		if (n+1)%3 == 0 {
			for i := 0; i < (n-2)/3; i++ {
				fmt.Print("21")
			}
			fmt.Println("2")
			continue
		}
		if (n-1)%3 == 0 {
			for i := 0; i < (n-1)/3; i++ {
				fmt.Print("12")
			}
			fmt.Println("1")
			continue
		}
	}

}

package main

import "fmt"

func main() {
	var (
		testCase int
		N        int32
		sum      int32
		answer   string
		oneOrTwo bool
	)
	// Taking input from user
	fmt.Scanln(&testCase)
	for i := 0; i < int(testCase); i++ {
		sum = 0
		answer = ""
		fmt.Scanln(&N)
		switch N % 3 {
		case 0, 2:
			oneOrTwo = true

		case 1:
			oneOrTwo = false
		}
		for sum < N {
			if oneOrTwo {
				answer += "2"
				sum += 2
				oneOrTwo = false
			} else {
				answer += "1"
				sum += 1
				oneOrTwo = true
			}
		}
		fmt.Println(answer)
	}

}

package main

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

func main() {
	var (
		t int
	)

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

	for t > 0 {
		t--

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

		var ans string
		sum := 0
		i := 0
		for sum < n {
			if i & 1 == 1 {
				ans += "1"
				sum += 1
			} else {
				ans += "2"
				sum += 2
			}
			i++
		}

		if sum == n {
           		fmt.Println(ans)
		} else {
			ans = ""
			sum = 0
			i = 1
			for sum < n {
				if i & 1 == 1 {
					ans += "1"
					sum += 1
				} else {
					ans += "2"
					sum += 2
				}
				i++
			}
			fmt.Println(ans)
		}
	}
}

package main

import (
	"fmt"
	"strings"
)

func res(t int) string {
	out := strings.Repeat("21", t / 3)
	if t % 3 == 0 {
		return out
	}
	if t % 3 == 1 {
		return "1" + out
	}
	return out + "2"
}

func main() {
	var n int
	fmt.Scanln(&n)
	for i := 0 ; i < n; i++ {
		var t int
		fmt.Scanln(&t)
		fmt.Println(res(t))
	}
}

package main

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

/*
5
6
7
8
9
10
---
2121
12121
21212
212121
1212121
*/

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

	s := make([]rune, 1)
	s[0] = '1'

	even := true

	for n > 0 {
		if even {
			n -= 2
			s = append(s, '2')
		} else {
			n -= 1
			s = append(s, '1')
		}

		even = !even
	}

	if n == 0 {
		s = s[1:]
	} else {
		s = s[:len(s)-1]
	}

	fmt.Fprintln(writer, string(s))
}

//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 int) int {
	quot := num / div
	if num%div != 0 {
		quot++
	}
	return quot
}

//goland:noinspection GoUnusedFunction
func min(nums ...int) int {
	minimum := nums[0]
	for _, num := range nums {
		if num < minimum {
			minimum = num
		}
	}
	return minimum
}

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

	return nums[idx]
}

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

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

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

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

	return true
}

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

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

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

	num = abs(num)

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

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

package main

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

func main() {
	_r, _w := os.Stdin, os.Stdout
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	var solve func()
	// Todo...
	solve = func() {
		var n int
		Fscan(in, &n)
		x := make([]int, n)
		for i := 0; i < n; i++ {
			x[i] = 1
		}
		j := 0
		var ans = make([]int, 0)
		for j+1 < n {
			ans = append(ans, 2)
			j += 2
			if j < n {
				ans = append(ans, 1)
				j++
			}
		}
		if j < n {
			ans = append(ans, 1)
		}
		if len(ans) > 2 && ans[len(ans)-1] == ans[len(ans)-2] {
			Fprint(out, ans[len(ans)-1])
			for i := 0; i < len(ans)-1; i++ {
				Fprint(out, ans[i])
			}
			Fprintln(out)
			return
		}
		for i := 0; i < len(ans); i++ {
			Fprint(out, ans[i])
		}
		Fprintln(out)
	}
	// End...
	var T int = 1
	Fscan(in, &T)
	for i := 0; i < T; i++ {
		solve()
	}
}
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
}

package main

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

// A. Madoka and Math Dad

func solve() {

	var n int

	scanf("%d\n", &n)

	if n%3 == 0 {
		loopp(0, n/3, "21")
	} else if n %3 == 1 {
		printf("1")
		loopp(0, n/3, "21")
	} else {
		printf("2")
		loopp(0, n/3, "12")
	}
	println()
}

func main() {

	var t int

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

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

	writer.Flush()
}

// Constants

const (
	N  = 1e5
	M  = 1e6
	B  = 1e9
	BB = 1e18
)

// Data structures

type Pair struct {
	First, Second int
}

type Pairs []Pair

func (p Pairs) Len() int           { return len(p) }
func (p Pairs) Less(i, j int) bool { return p[i].First < p[j].First }
func (p Pairs) Swap(i, j int)      { p[i], p[j] = p[j], p[i] }

type PriorityQueue struct {
	v    []int
	Size int
}

func (pq *PriorityQueue) build(a []int) {

	pq.v = a
	pq.Size += len(a)

	pq.heap()
}

func (pq *PriorityQueue) heap() {

	// builds a max heap

	n := pq.Size
	r := (n / 2) - 1

	for i := r; i >= 0; i-- {
		pq.heapify(i)
	}

}

func (pq *PriorityQueue) heapify(index int) {

	root := index
	lc := 2*index + 1
	rc := 2*index + 2

	if lc < pq.Size && pq.v[lc] > pq.v[root] {
		root = lc
	}
	if rc < pq.Size && pq.v[rc] > pq.v[root] {
		root = rc
	}

	if root != index {
		pq.v[index], pq.v[root] = pq.v[root], pq.v[index]
		pq.heapify(root)
	}
}

func (pq *PriorityQueue) add(n int) {

	pq.v = append(pq.v, n)
	pq.Size++

	pq.heapify(0)
}

func (pq *PriorityQueue) front() int {

	if pq.Size > 0 {
		// store the first element
		n := pq.v[0]
		// remove element
		pq.v = pq.v[1:]
		pq.Size--

		return n
	}

	return -1
}

func (pq *PriorityQueue) empty() bool {
	return pq.Size == 0
}

// Util functions

func tos(n int) string {
	return strconv.Itoa(n)
}

func toi(s string) int {
	// ignore error
	n, _ := strconv.Atoi(s)

	return n
}

func pow(b, n uint) uint {

	if n == 0 {
		return 1
	}

	var a uint = 1

	for n >= 1 {
		a = b * a
		n--
	}

	return a
}

func flip(b uint) uint {

	if b == 0 {
		return 1
	}

	return 0
}

func bin(dec uint) []uint {

	bin := []uint{}

	for dec > 0 {
		if dec%2 != 0 {
			bin = append(bin, 1)
		} else {
			bin = append(bin, 0)
		}

		dec = dec / 2
	}

	for i, j := 0, len(bin)-1; i < j; i, j = i+1, j-1 {
		bin[i], bin[j] = bin[j], bin[i]
	}

	return bin
}

func dec(b []uint) uint {

	var dec uint = 0

	for i, v := range b {
		dec += (2 << i) * v
	}

	return dec
}

func loopp(l, r int, s string) {

	// loop print
	for i := l; i < r; i++ {
		printf("%s", s)
	}
}

// Use buffering when reading/writing data as the default fmt.Scanx/fmt.Printx
// functions doesn't.

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

func scanf(f string, a ...interface{}) {
	fmt.Fscanf(reader, f, a...)
}

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

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

package main

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

// A. Madoka and Math Dad

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

	return b
}

func solve() {

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

	if n == 1 {
		println("1")
	} else if n == 2 {
		println("2")
	} else {
		// combination of ones an twos
		// naive solution (start both strings an choose one)
		var out1, out2 string
		var sum1, sum2 int

		toggle := true

		for sum1 <= n || sum2 <= n {
			if toggle {
				sum1 += 1
				sum2 += 2
				out1 += "1"
				out2 += "2"
			} else {
				sum1 += 2
				sum2 += 1
				out1 += "2"
				out2 += "1"
			}

			if sum1 == n || sum2 == n {
				break
			}

			toggle = !toggle
		}

		if sum1 == sum2 {
			println(out2)
		} else {
			if sum1 == n {
				println(out1)
			} else if sum2 == n {
				println(out2)
			}
		}
	}
}

func main() {

	var t int

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

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

	writer.Flush()
}

// Constants

const (
	N  = 1e5
	M  = 1e6
	B  = 1e9
	BB = 1e18
)

// Data structures

type Pair struct {
	First, Second int
}

type Pairs []Pair

func (p Pairs) Len() int           { return len(p) }
func (p Pairs) Less(i, j int) bool { return p[i].First < p[j].First }
func (p Pairs) Swap(i, j int)      { p[i], p[j] = p[j], p[i] }

type PriorityQueue struct {
	v    []int
	Size int
}

func (pq *PriorityQueue) build(a []int) {

	pq.v = a
	pq.Size += len(a)

	pq.heap()
}

func (pq *PriorityQueue) heap() {

	// builds a max heap

	n := pq.Size
	r := (n / 2) - 1

	for i := r; i >= 0; i-- {
		pq.heapify(i)
	}

}

func (pq *PriorityQueue) heapify(index int) {

	root := index
	lc := 2*index + 1
	rc := 2*index + 2

	if lc < pq.Size && pq.v[lc] > pq.v[root] {
		root = lc
	}
	if rc < pq.Size && pq.v[rc] > pq.v[root] {
		root = rc
	}

	if root != index {
		pq.v[index], pq.v[root] = pq.v[root], pq.v[index]
		pq.heapify(root)
	}
}

func (pq *PriorityQueue) add(n int) {

	pq.v = append(pq.v, n)
	pq.Size++

	pq.heapify(0)
}

func (pq *PriorityQueue) front() int {

	if pq.Size > 0 {
		// store the first element
		n := pq.v[0]
		// remove element
		pq.v = pq.v[1:]
		pq.Size--

		return n
	}

	return -1
}

func (pq *PriorityQueue) empty() bool {
	return pq.Size == 0
}

// Util functions

func tos(n int) string {
	return strconv.Itoa(n)
}

func toi(s string) int {
	// ignore error
	n, _ := strconv.Atoi(s)

	return n
}

func pow(b, n uint) uint {

	if n == 0 {
		return 1
	}

	var a uint = 1

	for n >= 1 {
		a = b * a
		n--
	}

	return a
}

func flip(b uint) uint {

	if b == 0 {
		return 1
	}

	return 0
}

func bin(dec uint) []uint {

	bin := []uint{}

	for dec > 0 {
		if dec%2 != 0 {
			bin = append(bin, 1)
		} else {
			bin = append(bin, 0)
		}

		dec = dec / 2
	}

	for i, j := 0, len(bin)-1; i < j; i, j = i+1, j-1 {
		bin[i], bin[j] = bin[j], bin[i]
	}

	return bin
}

func dec(b []uint) uint {

	var dec uint = 0

	for i, v := range b {
		dec += (2 << i) * v
	}

	return dec
}

// Use buffering when reading/writing data as the default fmt.Scanx/fmt.Printx
// functions doesn't.

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

func scanf(f string, a ...interface{}) {
	fmt.Fscanf(reader, f, a...)
}

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

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

package main

import (
	"fmt"
)

func main() {
	var t int
	fmt.Scanf("%d\n", &t)
	for t := t; t > 0; t-- {
		var n int
		fmt.Scanf("%d\n", &n)
		cur := 2
		m := n
		for n > 0 {
			n -= cur
			if n < 0 {
				cur = 1
				break
			} else if n == 0 {
				cur = 2
				break
			}
			cur = 3 - cur
		}
		n = m
		var res []byte
		for n > 0 {
			res = append(res, byte(cur+'0'))
			n -= cur
			cur = 3 - cur
		}
		fmt.Println(string(res))
	}
}

package main

import "fmt"

func xuli() {
	var (
		n int
		s string
	)
	fmt.Scan(&n)
	t := n % 3
	if t == 1 {
		s = s + "1"
	}
	for i := 3; i <= n; i += 3 {
		s = s + "21"
	}
	if t == 2 {
		s = s + "2"
	}
	fmt.Print(s + "\n")
}

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

package main

import "fmt"

func xuli() {
	var (
		n int
	)
	fmt.Scan(&n)
	t := n % 3
	if t == 1 {
		fmt.Print(1)
	}
	for i := 3; i <= n; i += 3 {
		fmt.Print(21)
	}
	if t == 2 {
		fmt.Print(2)
	}
	fmt.Print("\n")
}

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

package main

import (
	"fmt"
)

func main() {
	var n, k int
	fmt.Scan(&k)
	for i := k; i > 0; i-- {
		fmt.Scan(&n)
		if n%3 == 0 {
			for j := n / 3; j > 0; j-- {
				fmt.Print("21")
			}
		} else if n%3 == 1 {
			for j := n / 3; j > 0; j-- {
				fmt.Print("12")
			}
			fmt.Print("1")
		} else if n%3 == 2 {
			for j := n / 3; j > 0; j-- {
				fmt.Print("21")
			}
			fmt.Print("2")
		}
		fmt.Println()
	}
}

package main

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

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

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

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

		var f int
		if n%3 == 0 || (n-2)%3 == 0 {
			f = 1
		}

		for n > 0 {
			if f == 1 {
				fmt.Fprint(out, 2)
				n -= 2
			} else {
				fmt.Fprint(out, 1)
				n -= 1
			}
			f ^= 1
		}
		fmt.Fprintln(out)
	}
}

package main
import(
    "fmt"
    "bufio"
    "os"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var n int
		fmt.Fscan(in,&n)
		var output string
		if n%3 == 1 {
			for j:=1;j<=n/3;j++{
				output+="12"
			}
			output+="1"
		} else {
			for j:=1;j<=n/3;j++{
				output+="21"
			}
			if n%3 == 2 {
				output+="2"
			}
		}
		fmt.Fprintln(out,output)
	}
}

package main
import(
    "fmt"
    "bufio"
    "os"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var n int
		fmt.Fscan(in,&n)
		var output string
		if n%3 == 0 {
			for j:=1;j<=n/3;j++{
				output+="21"
			}
		} else if n%3 == 1 {
			for j:=1;j<=n/3;j++{
				output+="12"
			}
			output+="1"
		} else {
			for j:=1;j<=n/3;j++{
				output+="21"
			}
			output+="2"
		}
		fmt.Fprintln(out,output)
	}
}

package main

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

const (
	INF = 3e5 + 10
)

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

	var t int
	Fscan(in, &t)

	for k := 0; k < t; k++ {
		var n int
		Fscan(in, &n)

		m := n

		var ans string
		res1 := ""
		flag := 1
		for m > 0 {
			res1 += strconv.Itoa(flag)
			m -= flag
			if flag == 1 {
				flag = 2
			} else {
				flag = 1
			}
		}

		if m == 0 {
			ans = res1
		}

		m = n
		res1 = ""
		flag = 2
		for m > 0 {
			res1 += strconv.Itoa(flag)
			m -= flag
			if flag == 1 {
				flag = 2
			} else {
				flag = 1
			}
		}

		if m == 0 && res1 > ans {
			ans = res1

		}
		Fprintln(out, ans)

	}

}

package main

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

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

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

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

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

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

/**
Run solve the problem CF1647A
Date: 22/03/22
User: pepradere
URL: https://codeforces.com/problemset/problem/1647/A
Problem: CF1647A
**/
func (in *CF1647A) Run() {
	for t := in.NextInt(); t > 0; t-- {
		n := in.NextInt()
		if n == 1 {
			fmt.Println(1)
		} else if n == 2 {
			fmt.Println(2)
		} else {
			ans := ""
			if (n-1)%3 == 0 {
				sum := 0
				for i := 0; sum+3 <= n; i++ {
					ans = ans + "12"
					sum += 3
				}

				if sum < n {
					ans = ans + fmt.Sprintf("%d", n-sum)
				}

			} else {
				sum := 0
				for i := 0; sum+3 <= n; i++ {
					ans = ans + "21"
					sum += 3
				}

				if sum < n {
					ans = ans + fmt.Sprintf("%d", n-sum)
				}
			}
			fmt.Println(ans)
		}
	}
}

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

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

package main
import "fmt"
func main(){
	var t,n int
	for fmt.Scan(&t);t!=0;t-- {
		fmt.Scan(&n)
		if(n%3 == 1) {
			fmt.Print(1)
		}
		for i := 0;i<n/3;i++{
			fmt.Print(21)
		}
		if (n%3==2){
			fmt.Print(2)
		}
		fmt.Print("\n")

	}
}

package main

import (
	"fmt"
)

func main() {
	var q int
	fmt.Scan(&q)
	for i := 0; i < q; i++ {
		var n int
		fmt.Scan(&n)
		var resSize int = (n / 3) * 2
		var nextSymb byte = '1'
		if n%3 != 0 {
			resSize++
		}
		if n%3 != 1 {
			nextSymb = '2'
		}
		res := make([]byte, resSize)
		for j, _ := range res {
			res[j] = nextSymb
			if nextSymb == '1' {
				nextSymb++
			} else {
				nextSymb--
			}
		}
		fmt.Println(string(res))
	}
}

package main

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

// A. Madoka and Math Dad

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

	return b
}

func solve() {

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

	if n == 1 {
		println("1")
	} else if n == 2 {
		println("2")
	} else {
		// combination of ones an twos
		// naive solution (start both strings an choose one)
		var out1, out2 string
		var sum1, sum2 int

		toggle := true

		for sum1 <= n || sum2 <= n {
			if toggle {
				sum1 += 1
				sum2 += 2
				out1 += "1"
				out2 += "2"
			} else {
				sum1 += 2
				sum2 += 1
				out1 += "2"
				out2 += "1"
			}

			if sum1 == n || sum2 == n {
				break
			}

			toggle = !toggle
		}

		if sum1 == sum2 {
			println(out2)
		} else {
			if sum1 == n {
				println(out1, sum1)
			} else if sum2 == n {
				println(out2, sum2)
			}
		}
	}
}

func main() {

	var t int

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

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

	writer.Flush()
}

// Constants

const (
	N  = 1e5
	M  = 1e6
	B  = 1e9
	BB = 1e18
)

// Data structures

type Pair struct {
	First, Second int
}

type Pairs []Pair

func (p Pairs) Len() int           { return len(p) }
func (p Pairs) Less(i, j int) bool { return p[i].First < p[j].First }
func (p Pairs) Swap(i, j int)      { p[i], p[j] = p[j], p[i] }

type PriorityQueue struct {
	v    []int
	Size int
}

func (pq *PriorityQueue) build(a []int) {

	pq.v = a
	pq.Size += len(a)

	pq.heap()
}

func (pq *PriorityQueue) heap() {

	// builds a max heap

	n := pq.Size
	r := (n / 2) - 1

	for i := r; i >= 0; i-- {
		pq.heapify(i)
	}

}

func (pq *PriorityQueue) heapify(index int) {

	root := index
	lc := 2*index + 1
	rc := 2*index + 2

	if lc < pq.Size && pq.v[lc] > pq.v[root] {
		root = lc
	}
	if rc < pq.Size && pq.v[rc] > pq.v[root] {
		root = rc
	}

	if root != index {
		pq.v[index], pq.v[root] = pq.v[root], pq.v[index]
		pq.heapify(root)
	}
}

func (pq *PriorityQueue) add(n int) {

	pq.v = append(pq.v, n)
	pq.Size++

	pq.heapify(0)
}

func (pq *PriorityQueue) front() int {

	if pq.Size > 0 {
		// store the first element
		n := pq.v[0]
		// remove element
		pq.v = pq.v[1:]
		pq.Size--

		return n
	}

	return -1
}

func (pq *PriorityQueue) empty() bool {
	return pq.Size == 0
}

// Util functions

func tos(n int) string {
	return strconv.Itoa(n)
}

func toi(s string) int {
	// ignore error
	n, _ := strconv.Atoi(s)

	return n
}

func pow(b, n uint) uint {

	if n == 0 {
		return 1
	}

	var a uint = 1

	for n >= 1 {
		a = b * a
		n--
	}

	return a
}

func flip(b uint) uint {

	if b == 0 {
		return 1
	}

	return 0
}

func bin(dec uint) []uint {

	bin := []uint{}

	for dec > 0 {
		if dec%2 != 0 {
			bin = append(bin, 1)
		} else {
			bin = append(bin, 0)
		}

		dec = dec / 2
	}

	for i, j := 0, len(bin)-1; i < j; i, j = i+1, j-1 {
		bin[i], bin[j] = bin[j], bin[i]
	}

	return bin
}

func dec(b []uint) uint {

	var dec uint = 0

	for i, v := range b {
		dec += (2 << i) * v
	}

	return dec
}

// Use buffering when reading/writing data as the default fmt.Scanx/fmt.Printx
// functions doesn't.

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

func scanf(f string, a ...interface{}) {
	fmt.Fscanf(reader, f, a...)
}

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

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

package main

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

// A. Madoka and Math Dad

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

	return b
}

func solve() {

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

	if n == 1 {
		println("1")
	} else if n == 2 {
		println("2")
	} else {
		// combination of ones an twos
		// naive solution (start both strings an choose one)
		var out1, out2 string
		var sum1, sum2 int

		toggle := true

		for sum1 <= n || sum2 <= n {
			if toggle {
				sum1 += 1
				sum2 += 2
				out1 += "1"
				out2 += "2"
			} else {
				sum1 += 2
				sum2 += 1
				out1 += "2"
				out2 += "1"
			}

			if sum1 == n || sum2 == n {
				break
			}

			toggle = !toggle
		}

		if sum1 == sum2 {
			n1, _ := strconv.Atoi(out1)
			n2, _ := strconv.Atoi(out2)

			println(max(n1, n2))
		} else {

			if sum1 == n {
				println(out1)
			} else if sum2 == n {
				println(out2)
			}
		}
	}
}

func main() {

	var t int

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

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

	writer.Flush()
}

// Constants

const (
	N  = 1e5
	M  = 1e6
	B  = 1e9
	BB = 1e18
)

// Data structures

type Pair struct {
	First, Second int
}

type Pairs []Pair

func (p Pairs) Len() int           { return len(p) }
func (p Pairs) Less(i, j int) bool { return p[i].First < p[j].First }
func (p Pairs) Swap(i, j int)      { p[i], p[j] = p[j], p[i] }

type PriorityQueue struct {
	v    []int
	Size int
}

func (pq *PriorityQueue) build(a []int) {

	pq.v = a
	pq.Size += len(a)

	pq.heap()
}

func (pq *PriorityQueue) heap() {

	// builds a max heap

	n := pq.Size
	r := (n / 2) - 1

	for i := r; i >= 0; i-- {
		pq.heapify(i)
	}

}

func (pq *PriorityQueue) heapify(index int) {

	root := index
	lc := 2*index + 1
	rc := 2*index + 2

	if lc < pq.Size && pq.v[lc] > pq.v[root] {
		root = lc
	}
	if rc < pq.Size && pq.v[rc] > pq.v[root] {
		root = rc
	}

	if root != index {
		pq.v[index], pq.v[root] = pq.v[root], pq.v[index]
		pq.heapify(root)
	}
}

func (pq *PriorityQueue) add(n int) {

	pq.v = append(pq.v, n)
	pq.Size++

	pq.heapify(0)
}

func (pq *PriorityQueue) front() int {

	if pq.Size > 0 {
		// store the first element
		n := pq.v[0]
		// remove element
		pq.v = pq.v[1:]
		pq.Size--

		return n
	}

	return -1
}

func (pq *PriorityQueue) empty() bool {
	return pq.Size == 0
}

// Util functions

func tos(n int) string {
	return strconv.Itoa(n)
}

func toi(s string) int {
	// ignore error
	n, _ := strconv.Atoi(s)

	return n
}

func pow(b, n uint) uint {

	if n == 0 {
		return 1
	}

	var a uint = 1

	for n >= 1 {
		a = b * a
		n--
	}

	return a
}

func flip(b uint) uint {

	if b == 0 {
		return 1
	}

	return 0
}

func bin(dec uint) []uint {

	bin := []uint{}

	for dec > 0 {
		if dec%2 != 0 {
			bin = append(bin, 1)
		} else {
			bin = append(bin, 0)
		}

		dec = dec / 2
	}

	for i, j := 0, len(bin)-1; i < j; i, j = i+1, j-1 {
		bin[i], bin[j] = bin[j], bin[i]
	}

	return bin
}

func dec(b []uint) uint {

	var dec uint = 0

	for i, v := range b {
		dec += (2 << i) * v
	}

	return dec
}

// Use buffering when reading/writing data as the default fmt.Scanx/fmt.Printx
// functions doesn't.

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

func scanf(f string, a ...interface{}) {
	fmt.Fscanf(reader, f, a...)
}

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

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

package main

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

// A. Madoka and Math Dad

func solve() {

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

	if n == 1 {
		println("1")
	} else if n == 2 {
		println("2")
	} else {
		// combination of ones an twos
		// naive solution (start both strings an choose one)
		var out1, out2 string
		var sum1, sum2 int

		toggle := true

		for sum1 <= n || sum2 <= n {
			if toggle {
				sum1 += 1
				sum2 += 2
				out1 += "1"
				out2 += "2"
			} else {
				sum1 += 2
				sum2 += 1
				out1 += "2"
				out2 += "1"
			}

			if sum1 == n || sum2 == n {
				break
			}

			toggle = !toggle
		}

		if sum1 == n {
			println(out1)
		} else if sum2 == n {
			println(out2)
		}
	}
}

func main() {

	var t int

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

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

	writer.Flush()
}

// Constants

const (
	N  = 1e5
	M  = 1e6
	B  = 1e9
	BB = 1e18
)

// Data structures

type Pair struct {
	First, Second int
}

type Pairs []Pair

func (p Pairs) Len() int           { return len(p) }
func (p Pairs) Less(i, j int) bool { return p[i].First < p[j].First }
func (p Pairs) Swap(i, j int)      { p[i], p[j] = p[j], p[i] }

type PriorityQueue struct {
	v    []int
	Size int
}

func (pq *PriorityQueue) build(a []int) {

	pq.v = a
	pq.Size += len(a)

	pq.heap()
}

func (pq *PriorityQueue) heap() {

	// builds a max heap

	n := pq.Size
	r := (n / 2) - 1

	for i := r; i >= 0; i-- {
		pq.heapify(i)
	}

}

func (pq *PriorityQueue) heapify(index int) {

	root := index
	lc := 2*index + 1
	rc := 2*index + 2

	if lc < pq.Size && pq.v[lc] > pq.v[root] {
		root = lc
	}
	if rc < pq.Size && pq.v[rc] > pq.v[root] {
		root = rc
	}

	if root != index {
		pq.v[index], pq.v[root] = pq.v[root], pq.v[index]
		pq.heapify(root)
	}
}

func (pq *PriorityQueue) add(n int) {

	pq.v = append(pq.v, n)
	pq.Size++

	pq.heapify(0)
}

func (pq *PriorityQueue) front() int {

	if pq.Size > 0 {
		// store the first element
		n := pq.v[0]
		// remove element
		pq.v = pq.v[1:]
		pq.Size--

		return n
	}

	return -1
}

func (pq *PriorityQueue) empty() bool {
	return pq.Size == 0
}

// Util functions

func tos(n int) string {
	return strconv.Itoa(n)
}

func toi(s string) int {
	// ignore error
	n, _ := strconv.Atoi(s)

	return n
}

func pow(b, n uint) uint {

	if n == 0 {
		return 1
	}

	var a uint = 1

	for n >= 1 {
		a = b * a
		n--
	}

	return a
}

func flip(b uint) uint {

	if b == 0 {
		return 1
	}

	return 0
}

func bin(dec uint) []uint {

	bin := []uint{}

	for dec > 0 {
		if dec%2 != 0 {
			bin = append(bin, 1)
		} else {
			bin = append(bin, 0)
		}

		dec = dec / 2
	}

	for i, j := 0, len(bin)-1; i < j; i, j = i+1, j-1 {
		bin[i], bin[j] = bin[j], bin[i]
	}

	return bin
}

func dec(b []uint) uint {

	var dec uint = 0

	for i, v := range b {
		dec += (2 << i) * v
	}

	return dec
}

// Use buffering when reading/writing data as the default fmt.Scanx/fmt.Printx
// functions doesn't.

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

func scanf(f string, a ...interface{}) {
	fmt.Fscanf(reader, f, a...)
}

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

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

package main

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

// A. Madoka and Math Dad

func solve() {

	var n, sum int
	var s string

	scanf("%d\n", &n)

	sum = 0
	one := true

	if (n&1 == 1 && n > 1) || n == 2 {
		one = false
	}

	for {
		if sum < n {
			if one {
				s += "1"
				sum += 1
			} else {
				s += "2"
				sum += 2
			}

			one = !one
		} else if sum >= n {
			break
		}
	}

	println(s)
}

func main() {

	var t int

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

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

	writer.Flush()
}

// Constants

const (
	N = 1e5
	M = 1e6
	B = 1e9
	BB = 1e18
)

// Data structures

type Pair struct {
	First, Second int
}

type Pairs []Pair

func (p Pairs) Len() int           { return len(p) }
func (p Pairs) Less(i, j int) bool { return p[i].First < p[j].First }
func (p Pairs) Swap(i, j int)      { p[i], p[j] = p[j], p[i] }

type PriorityQueue struct {
	v    []int
	Size int
}

func (pq *PriorityQueue) build(a []int) {

	pq.v = a
	pq.Size += len(a)

	pq.heap()
}

func (pq *PriorityQueue) heap() {

	// builds a max heap

	n := pq.Size
	r := (n / 2) - 1

	for i := r; i >= 0; i-- {
		pq.heapify(i)
	}

}

func (pq *PriorityQueue) heapify(index int) {

	root := index
	lc := 2*index + 1
	rc := 2*index + 2

	if lc < pq.Size && pq.v[lc] > pq.v[root] {
		root = lc
	}
	if rc < pq.Size && pq.v[rc] > pq.v[root] {
		root = rc
	}

	if root != index {
		pq.v[index], pq.v[root] = pq.v[root], pq.v[index]
		pq.heapify(root)
	}
}

func (pq *PriorityQueue) add(n int) {

	pq.v = append(pq.v, n)
	pq.Size++

	pq.heapify(0)
}

func (pq *PriorityQueue) front() int {

	if pq.Size > 0 {
		// store the first element
		n := pq.v[0]
		// remove element
		pq.v = pq.v[1:]
		pq.Size--

		return n
	}

	return -1
}

func (pq *PriorityQueue) empty() bool {
	return pq.Size == 0
}

// Util functions

func tos(n int) string {
	return strconv.Itoa(n)
}

func toi(s string) int {
	// ignore error
	n, _ := strconv.Atoi(s)

	return n
}

func pow(b, n uint) uint {

	if n == 0 {
		return 1
	}

	var a uint = 1

	for n >= 1 {
		a = b * a
		n--
	}

	return a
}

func flip(b uint) uint {

	if b == 0 {
		return 1
	}

	return 0
}

func bin(dec uint) []uint {

	bin := []uint{}

	for dec > 0 {
		if dec%2 != 0 {
			bin = append(bin, 1)
		} else {
			bin = append(bin, 0)
		}

		dec = dec / 2
	}

	for i, j := 0, len(bin)-1; i < j; i, j = i+1, j-1 {
        bin[i], bin[j] = bin[j], bin[i]
    }

	return bin
}

func dec(b []uint) uint {

	var dec uint = 0

	for i, v := range b {
		dec += (2 << i) * v
	}

	return dec
}

// Use buffering when reading/writing data as the default fmt.Scanx/fmt.Printx
// functions doesn't.

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

func scanf(f string, a ...interface{}) {
	fmt.Fscanf(reader, f, a...)
}

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

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

package main

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

// A. Madoka and Math Dad

func solve() {

	var n, sum int
	var s string

	scanf("%d\n", &n)

	sum = 0
	one := true

	if n&1 == 1 || n == 2 {
		one = false
	}

	for {
		if sum < n {
			if one {
				s += "1"
				sum += 1
			} else {
				s += "2"
				sum += 2
			}

			one = !one
		} else if sum >= n {
			break
		}
	}

	println(s)
}

func main() {

	var t int

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

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

	writer.Flush()
}

// Constants

const (
	N = 1e5
	M = 1e6
	B = 1e9
	BB = 1e18
)

// Data structures

type Pair struct {
	First, Second int
}

type Pairs []Pair

func (p Pairs) Len() int           { return len(p) }
func (p Pairs) Less(i, j int) bool { return p[i].First < p[j].First }
func (p Pairs) Swap(i, j int)      { p[i], p[j] = p[j], p[i] }

type PriorityQueue struct {
	v    []int
	Size int
}

func (pq *PriorityQueue) build(a []int) {

	pq.v = a
	pq.Size += len(a)

	pq.heap()
}

func (pq *PriorityQueue) heap() {

	// builds a max heap

	n := pq.Size
	r := (n / 2) - 1

	for i := r; i >= 0; i-- {
		pq.heapify(i)
	}

}

func (pq *PriorityQueue) heapify(index int) {

	root := index
	lc := 2*index + 1
	rc := 2*index + 2

	if lc < pq.Size && pq.v[lc] > pq.v[root] {
		root = lc
	}
	if rc < pq.Size && pq.v[rc] > pq.v[root] {
		root = rc
	}

	if root != index {
		pq.v[index], pq.v[root] = pq.v[root], pq.v[index]
		pq.heapify(root)
	}
}

func (pq *PriorityQueue) add(n int) {

	pq.v = append(pq.v, n)
	pq.Size++

	pq.heapify(0)
}

func (pq *PriorityQueue) front() int {

	if pq.Size > 0 {
		// store the first element
		n := pq.v[0]
		// remove element
		pq.v = pq.v[1:]
		pq.Size--

		return n
	}

	return -1
}

func (pq *PriorityQueue) empty() bool {
	return pq.Size == 0
}

// Util functions

func tos(n int) string {
	return strconv.Itoa(n)
}

func toi(s string) int {
	// ignore error
	n, _ := strconv.Atoi(s)

	return n
}

func pow(b, n uint) uint {

	if n == 0 {
		return 1
	}

	var a uint = 1

	for n >= 1 {
		a = b * a
		n--
	}

	return a
}

func flip(b uint) uint {

	if b == 0 {
		return 1
	}

	return 0
}

func bin(dec uint) []uint {

	bin := []uint{}

	for dec > 0 {
		if dec%2 != 0 {
			bin = append(bin, 1)
		} else {
			bin = append(bin, 0)
		}

		dec = dec / 2
	}

	for i, j := 0, len(bin)-1; i < j; i, j = i+1, j-1 {
        bin[i], bin[j] = bin[j], bin[i]
    }

	return bin
}

func dec(b []uint) uint {

	var dec uint = 0

	for i, v := range b {
		dec += (2 << i) * v
	}

	return dec
}

// Use buffering when reading/writing data as the default fmt.Scanx/fmt.Printx
// functions doesn't.

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

func scanf(f string, a ...interface{}) {
	fmt.Fscanf(reader, f, a...)
}

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

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

package main

import "fmt"

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

		var n int
		fmt.Scanf("%d", &n)
		cur := 2
		m := n
		for n > 0 {
			n -= cur
			if n < 0 {
				cur = 1
				break
			} else if n == 0 {
				cur = 2
				break
			}
			cur = 3 - cur
		}
		n = m
		for n > 0 {
			fmt.Printf("%d", cur)
			n -= cur
			cur = 3 - cur
		}
		fmt.Printf("\n")
	}
}

package main

import "fmt"

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

		var n int
		fmt.Scanf("%d", &n)
		cur := 2
		m := n
		for n > 0 {
			n -= cur
			if n < 0 {
				cur = 1
				break
			} else if n == 0 {
				cur = 2
				break
			}
			cur = 3 - cur
		}
		n = m
		for n > 0 {
			fmt.Printf("%d", cur)
			n -= cur
			cur = 3 - cur
		}
		fmt.Println("")
	}
}

package main

import "fmt"

func xuli() {
	var (
		n int
	)
	fmt.Scan(&n)
	t := n % 3
	if t == 1 {
		print(1)
	}
	for i := 3; i <= n; i += 3 {
		print(21)
	}
	if t == 2 {
		print(2)
	}
	print("\n")
}

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

package main

import "fmt"

func main(){
	var n,k int
	fmt.Scan(&k)
	for k>0{
		fmt.Scan(&n)
		if n == 1 {
			fmt.Println(1)
		} else if n == 2 {
			fmt.Println(2)
		} else if n % 2 == 0 {
			i:=1
			for n > 0 {
				fmt.Print(i)
				n = n-i
				if(i==2){
					i=1
				}else{
					i=2
				}
			}
			fmt.Println()
		} else {
			i:=2
			for n > 0 {
				fmt.Print(i)
				n = n-i
				if(i==2){
					i=1
				}else{
					i=2
				}
			}
			fmt.Println()
		}
		k--
	}
}

package main

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

type point struct {
	x, w int64
}

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

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

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

		var f int
		if n%3 == 0 || (n-2)%3 == 0 {
			f = 1
		}

		fmt.Fprintf(out, "%d: ", n)
		for n > 0 {
			if f == 1 {
				fmt.Fprint(out, 2)
				n -= 2
			} else {
				fmt.Fprint(out, 1)
				n -= 1
			}
			f ^= 1
		}
		fmt.Fprintln(out)
	}
}

package main

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

type point struct {
	x, w int64
}

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

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

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

		if n <= 2 {
			fmt.Fprintln(out, n)
		} else {
			var f int
			if n%2 != 1 {
				f = 1
			}

			for n > 0 {
				if f == 0 {
					fmt.Fprint(out, 2)
					n -= 2
				} else {
					fmt.Fprint(out, 1)
					n -= 1
				}
				f ^= 1
			}
			fmt.Fprintln(out)
		}
	}
}

package main

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

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

func CF1647A(in io.Reader, out io.Writer) {
	r := bufio.NewReader(in)
	w := bufio.NewWriter(out)
	defer w.Flush()

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

		if n <= 2 {
			fmt.Fprintln(w, n)
			continue
		}

		if n%2 == 1 {
			body := make([]byte, n/2+1)
			for i := range body {
				if i%2 == 0 {
					body[i] = '2'
				} else {
					body[i] = '1'
				}
			}
			fmt.Fprintln(w, string(body))
		} else {
			body := make([]byte, n/2+1)
			for i := range body {
				if i%2 == 0 {
					body[i] = '1'
				} else {
					body[i] = '2'
				}
			}
			fmt.Fprintln(w, string(body))
		}
	}

}

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

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

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 int
	Fscan(in, &t)

	for k := 0; k < t; k++ {
		var n int
		Fscan(in, &n)

		m := n

		var ans int
		res1 := 0
		flag := 1
		for m > 0 {
			res1 = res1*10 + flag
			m -= flag
			if flag == 1 {
				flag = 2
			} else {
				flag = 1
			}
		}

		if m == 0 {
			ans = res1
		}

		m = n
		res1 = 0
		flag = 2
		for m > 0 {
			res1 = res1*10 + flag
			m -= flag
			if flag == 1 {
				flag = 2
			} else {
				flag = 1
			}
		}

		if m == 0 && res1 > ans {
			ans = res1

		}
		Fprintln(out, ans)

	}

}

package main

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

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

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

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

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

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

/**
Run solve the problem CF1647A
Date: 22/03/22
User: pepradere
URL: https://codeforces.com/problemset/problem/1647/A
Problem: CF1647A
**/
func (in *CF1647A) Run() {
	for t := in.NextInt(); t > 0; t-- {
		n := in.NextInt()
		if n == 1 {
			fmt.Println(1)
		} else if n == 2 {
			fmt.Println(2)
		} else {
			twos := int(math.Ceil(float64(n)/2.)) - 1
			ones := n - 2*twos

			ans := ""
			if ones > twos {
				sum := 0
				for i := 0; i < twos; i++ {
					ans = ans + "12"
					sum += 3
				}

				if sum < n {
					ans = ans + fmt.Sprintf("%d", n-sum)
				}

			} else {
				sum :=  0
				for i := 0; i < ones; i++ {
					ans = ans + "21"
					sum += 3
				}

				if sum < n {
					ans = ans + fmt.Sprintf("%d", n-sum)
				}
			}
			fmt.Println(ans)
		}
	}
}

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

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

package main
import "fmt"
func main(){
	var t,n int
	fmt.Scan(&t)
	for fmt.Scan(&t);t!=0;t-- {
		fmt.Scan(&n)
		if(n%3 == 1) {
			fmt.Print(1)
		}
		for i := 0;i<n/3;i++{
			fmt.Print(21)
		}
		if (n%3==2){
			fmt.Print(2)
		}
		fmt.Print("\n")

	}
}

package main

import (
	"fmt"
)

func main() {
	var q int
	fmt.Scan(&q)
	for i := 0; i < q; i++ {
		var n int
		fmt.Scan(&n)
		var resSize int = (n / 3) * 2
		var nextSymb byte = '1'
		if n%3 != 0 {
			resSize++
			if n%3 != 1 {
				nextSymb = '2'
			}
		}
		res := make([]byte, resSize)
		for j, _ := range res {
			res[j] = nextSymb
			if nextSymb == '1' {
				nextSymb++
			} else {
				nextSymb--
			}
		}
		fmt.Println(string(res))
	}
}