You are given a string, consisting of lowercase Latin letters.A pair of neighbouring letters in a string is considered ugly if these letters are also neighbouring in a alphabet. For example, string "abaca" contains ugly pairs at positions $$$(1, 2)$$$ — "ab" and $$$(2, 3)$$$ — "ba". Letters 'a' and 'z' aren't considered neighbouring in a alphabet.Can you rearrange the letters of a given string so that there are no ugly pairs? You can choose any order of the letters of the given string but you can't add any new letters or remove the existing ones. You can also leave the order the same.If there are multiple answers, print any of them.You also have to answer $$$T$$$ separate queries.

The first line contains a single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of queries. Each of the next $$$T$$$ lines contains string $$$s$$$ $$$(1 \le |s| \le 100)$$$ — the string for the next query. It is guaranteed that it contains only lowercase Latin letters. Note that in hacks you have to set $$$T = 1$$$.

Print $$$T$$$ lines. The $$$i$$$-th line should contain the answer to the $$$i$$$-th query. If the answer for the $$$i$$$-th query exists, then print such a rearrangment of letters of the given string that it contains no ugly pairs. You can choose any order of the letters of the given string but you can't add any new letters or remove the existing ones. You can also leave the order the same. If there are multiple answers, print any of them. Otherwise print "No answer" for that query.

NoteIn the first example answer "bdac" is also correct.The second example showcases the fact that only neighbouring in alphabet letters are not allowed. The same letter is ok.There are lots of valid answers for the third example.

package main

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

func solve(j Jam) {
	T := int16(j.Int())
	for t := int16(0); t < T; t++ {
		in := j.Str()
		runeCount := make([]int, 26)
		for _, r := range []rune(in) {
			rIdx := int(r - 'a')
			runeCount[rIdx] += 1
		}
		presentRunes := make([]int, 0, 26)
		for r := range runeCount {
			if runeCount[r] > 0 {
				presentRunes = append(presentRunes, r)
			}
		}
		result := make([]rune, 0)
		seed := presentRunes[0]
		for i := 0; i < runeCount[seed]; i++ {
			result = append(result, rune('a'+seed))
		}
		presentRunes = presentRunes[1:]
		left, right := seed, seed
		retryRunes := make([]int, 0, 26)
		for _, r := range presentRunes {
			if right+1 != r {
				for i := 0; i < runeCount[r]; i++ {
					result = append(result, rune('a'+r))
				}
				right = r
			} else if left+1 != r {
				for i := 0; i < runeCount[r]; i++ {
					result = append([]rune{rune('a' + r)}, result...)
				}
				left = r
			} else {
				retryRunes = append(retryRunes, r)
			}
		}
		valid := true
		for _, r := range retryRunes {
			if abs(right-r) != 1 {
				for i := 0; i < runeCount[r]; i++ {
					result = append(result, rune('a'+r))
				}
				right = r
			} else if abs(left-r) != 1 {
				for i := 0; i < runeCount[r]; i++ {
					result = append([]rune{rune('a' + r)}, result...)
				}
				left = r
			} else {
				valid = false
				break
			}
		}
		if !valid {
			j.P("No answer\n")
		} else {
			j.P("%s\n", string(result))
		}
	}
}

func main() {
	jam, closeFunc := JamNew()
	defer closeFunc()
	solve(jam)
}

type Jam interface {
	Scanner() *bufio.Scanner
	Writer() *bufio.Writer
	Close()

	Str() string
	Int() int64
	Float() float64

	P(format string, values ...interface{})
	PF(format string, values ...interface{})
}

func JamNew() (Jam, func()) {
	if len(os.Args) > 1 {
		panic("running with input file path is not supported")
	}

	var scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 0, 1024*1024), 1024*1024)

	var writer = bufio.NewWriter(os.Stdout)
	jam := &jam{scanner, writer}
	return jam, jam.Close
}

type jam struct {
	sc *bufio.Scanner
	wr *bufio.Writer
}

func (j *jam) Close() {
	if err := j.wr.Flush(); err != nil {
		panic(err)
	}
}

func (j *jam) Scanner() *bufio.Scanner {
	return j.sc
}

func (j *jam) Writer() *bufio.Writer {
	return j.wr
}

func (j *jam) Str() string {
	if !j.sc.Scan() {
		panic("failed to scan next token")
	}

	return j.sc.Text()
}

func (j *jam) Int() int64 {
	if !j.sc.Scan() {
		panic("failed to scan next token")
	}

	res, err := strconv.ParseInt(j.sc.Text(), 10, 64)
	if err != nil {
		panic(err)
	}

	_, _ = fmt.Fprintf(os.Stderr, "scanned %d", res)
	_ = os.Stderr.Sync()

	return res
}

func (j *jam) Float() float64 {
	j.sc.Scan()
	res, err := strconv.ParseFloat(j.sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return res
}

func (j *jam) P(format string, values ...interface{}) {
	_, err := fmt.Fprintf(j.wr, format, values...)
	if err != nil {
		panic(err)
	}
}

func (j *jam) PF(format string, values ...interface{}) {
	_, err := fmt.Fprintf(j.wr, format, values...)
	if err != nil {
		panic(err)
	}
	if err = j.wr.Flush(); err != nil {
		panic(err)
	}
}

//	GoLang shorthand methods for math go below
//	TODO wipe unused methods before submitting

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

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

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

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

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

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

package main

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

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

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

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

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

func main() {
	// code GOes here

	var T int
	for scan(&T); T>0; T-- {
		var (
			cnt [26](int)
			s string
			minv int = 27
			maxv int = -1
		)
		scan(&s)
		for _, c := range s {
			cnt[c-'a'] += 1
			minv = min(minv, int(c-'a'))
			maxv = max(maxv, int(c-'a'))
		}

		if minv == maxv {
			print(s,"\n")
		} else if maxv-minv > 2 {
			last := 27
			for i:=0; i<26; i++ {
				if i%2 != minv%2 {
					if cnt[i] > 0 {
						last = i
					}
					for j:=0; j<cnt[i]; j++ {
						print(string(i+'a'))
					}
				}
			}
			if last-minv > 1 {
				for i:=0; i<26; i++ {
					if i%2 == minv%2 {
						for j:=0; j<cnt[i]; j++ {
							print(string(i+'a'))
						}
					}
				}
			} else {
				for i:=25; i>=0; i-- {
					if i%2 == minv%2 {
						for j:=0; j<cnt[i]; j++ {
							print(string(i+'a'))
						}
					}
				}
			}
			print("\n")
		} else if cnt[(minv+maxv)/2] == 0 {
			print(s, "\n")
		} else {
			print("No answer\n")
		}
	}

	writer.Flush()
	return
}

package main

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

func abs(x int) int {
    if x >= 0 {
        return x
    } else {
        return -x
    }
}

func main() {
    input := bufio.NewScanner(os.Stdin)
    input.Split(bufio.ScanWords)

    input.Scan()
    t, _ := strconv.Atoi(input.Text())

    for kase := 1; kase <= t; kase++ {
        input.Scan()
        s := input.Text()

        odd := make([]byte, 0)
        even := make([]byte, 0)
        for i := 0; i < len(s); i++ {
            ord := int(s[i]) - int('a')
            if ord % 2 == 0 {
                even = append(even, s[i])
            } else {
                odd = append(odd, s[i])
            }
        }

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

        var result string
        if len(odd) == 0 || len(even) == 0 {
            result = s
        } else if (abs(int(even[len(even) - 1]) - int(odd[0])) != 1) {
            result = string(even) + string(odd)
        } else if (abs(int(odd[len(odd) - 1]) - int(even[0])) != 1) {
            result = string(odd) + string(even)
        } else {
            fmt.Println("No answer")
            continue
        }

        fmt.Println(result)
    }
}

package main

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

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

func Sol1156B(reader io.Reader, writer io.Writer) {
	in := bufio.NewReader(reader)
	out := bufio.NewWriter(writer)
	defer out.Flush()

	const na = "No answer"

	var n int
	Fscan(in, &n)
	for ; n > 0; n-- {
		var s string
		Fscan(in, &s)

		cnt := make([]int, 26)
		for _, b := range s {
			cnt[b-'a']++
		}
		indexes := []int{}
		for i, c := range cnt {
			if c > 0 {
				indexes = append(indexes, i)
			}
		}

		ans := ""
		switch len(indexes) {
		case 1:
			ans = s
		case 2:
			if indexes[0]+1 == indexes[1] {
				ans = na
			} else {
				ans = s
			}
		case 3:
			i0, i1, i2 := indexes[0], indexes[1], indexes[2]
			if i0+1 == i1 && i1+1 == i2 {
				ans = na
			} else if i0+1 == i1 {
				ans = strings.Repeat(string('a'+i0), cnt[i0]) +
					strings.Repeat(string('a'+i2), cnt[i2]) +
					strings.Repeat(string('a'+i1), cnt[i1])
			} else if i1+1 == i2 {
				ans = strings.Repeat(string('a'+i1), cnt[i1]) +
					strings.Repeat(string('a'+i0), cnt[i0]) +
					strings.Repeat(string('a'+i2), cnt[i2])
			} else {
				ans = s
			}
		default:
			for i := 1; i < len(indexes); i += 2 {
				idx := indexes[i]
				ans += strings.Repeat(string('a'+idx), cnt[idx])
			}
			for i := 0; i < len(indexes); i += 2 {
				idx := indexes[i]
				ans += strings.Repeat(string('a'+idx), cnt[idx])
			}
		}
		Fprintln(out, ans)
	}
}

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

package main

import (
	"bufio"
	"bytes"
	"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 ok(s string) bool {
	n := len(s)
	for i := 0; i < n-1; i++ {
		diff := int(s[i]) - int(s[i+1])
		if diff == 1 || diff == -1 {
			return false
		}
	}
	return true
}

func solve(s string) {
	var odd, even bytes.Buffer
	for _, c := range s {
		if int(c) % 2 == 0 {
			even.WriteByte(byte(c))
		} else {
			odd.WriteByte(byte(c))
		}
	}
	o := odd.String()
	e := even.String()

	oo := []byte(o)
	ee := []byte(e)

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

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

	o = string(oo)
	e = string(ee)

	if ok(o + e) {
		printf("%s\n", o + e)
	} else if ok(e + o) {
		printf("%s\n", e + o)
	} else {
		printf("No answer\n")
	}
}

func main() {
	defer writer.Flush()

	var T int
	scanf("%d\n", &T)
	for i := 0; i < T; i++ {
		var s string
		scanf("%s\n", &s)
		solve(s)
	}
}

package main

import (
	"fmt"
)

func main() {

	alph := "abcdefghijklmnopqrstuvwxyz"

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

	for ; tcase > 0; tcase -= 1 {
		var s string
		var cnt [30]int
		dis := 0
		order := ""

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

		for _, j := range s {
			if cnt[j-'a'] == 0 {
				dis += 1
			}
			cnt[j-'a'] += 1
		}

		for i := 0; i < 26; i += 1 {
			if cnt[i] > 0 {
				order += string(alph[i])
			}
		}

		a, b := "", ""

		for i := range order {
			if i%2 == 0 {
				for ; cnt[order[i]-'a'] > 0; cnt[order[i]-'a'] -= 1 {
					a = a + order[i:i+1]
				}
			} else {
				for ; cnt[order[i]-'a'] > 0; cnt[order[i]-'a'] -= 1 {
					b = b + order[i:i+1]
				}
			}
			//				log.Print(i, j, res)
		}

		if dis == 1 {
			fmt.Println(s)
		} else if a[len(a)-1]+1 != b[0] && a[len(a)-1]-1 != b[0] {
			fmt.Println(a + b)
		} else if b[len(b)-1]+1 != a[0] && b[len(b)-1]-1 != a[0] {
			fmt.Println(b + a)
		} else {
			fmt.Println("No answer")
		}

	}
}

package main

import (
	"fmt"
	"log"
)

func main() {

	alph := "abcdefghijklmnopqrstuvwxyz"

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

	for ; tcase > 0; tcase -= 1 {
		var s string
		var cnt [30]int
		dis := 0
		order := ""

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

		for _, j := range s {
			if cnt[j-'a'] == 0 {
				dis += 1
			}
			cnt[j-'a'] += 1
		}

		for i := 0; i < 26; i += 1 {
			if cnt[i] > 0 {
				order += string(alph[i])
			}
		}

		a, b := "", ""

		for i := range order {
			if i%2 == 0 {
				for ; cnt[order[i]-'a'] > 0; cnt[order[i]-'a'] -= 1 {
					a = a + order[i:i+1]
				}
			} else {
				for ; cnt[order[i]-'a'] > 0; cnt[order[i]-'a'] -= 1 {
					b = b + order[i:i+1]
				}
			}
			//				log.Print(i, j, res)
		}
		log.Println(a + b)
		if dis == 1 {
			fmt.Println(s)
		} else if a[len(a)-1]+1 != b[0] && a[len(a)-1]-1 != b[0] {
			fmt.Println(a + b)
		} else if b[len(b)-1]+1 != a[0] && b[len(b)-1]-1 != a[0] {
			fmt.Println(b + a)
		} else {
			fmt.Println("No answer")
		}

	}
}

package main

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

func solve(j Jam) {
	T := int16(j.Int())
	for t := int16(0); t < T; t++ {
		in := j.Str()
		runeCount := make([]int, 26)
		for _, r := range []rune(in) {
			runeCount[r-'a'] += 1
		}
		presentRunes := make([]int, 0, 26)
		for r := range runeCount {
			if runeCount[r] > 0 {
				presentRunes = append(presentRunes, r)
			}
		}
		result := make([]rune, 0)
		start := 0
		mid := (len(presentRunes)) / 2
		for start * 2 < len(presentRunes) {
			if mid < len(presentRunes) {
				for s := 0; s < runeCount[presentRunes[mid]]; s++ {
					result = append(result, rune('a' + presentRunes[mid]))
				}
			}
			if start < len(presentRunes) / 2 {
				for s := 0; s < runeCount[presentRunes[start]]; s++ {
					result = append(result, rune('a'+presentRunes[start]))
				}
			}
			start += 1
			mid += 1
		}
		valid := true
		for i := 0; i + 1 < len(result); i++ {
			if abs(int(result[i] - result[i+1])) == 1 {
				valid = false
				break
			}
		}
		if !valid {
			j.P("No answer\n")
		} else {
			j.P("%s\n", string(result))
		}
	}
}

func main() {
	jam, closeFunc := JamNew()
	defer closeFunc()
	solve(jam)
}

type Jam interface {
	Scanner() *bufio.Scanner
	Writer() *bufio.Writer
	Close()

	Str() string
	Int() int64
	Float() float64

	P(format string, values ...interface{})
	PF(format string, values ...interface{})
}

func JamNew() (Jam, func()) {
	if len(os.Args) > 1 {
		panic("running with input file path is not supported")
	}

	var scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 0, 1024*1024), 1024*1024)

	var writer = bufio.NewWriter(os.Stdout)
	jam := &jam{scanner, writer}
	return jam, jam.Close
}

type jam struct {
	sc *bufio.Scanner
	wr *bufio.Writer
}

func (j *jam) Close() {
	if err := j.wr.Flush(); err != nil {
		panic(err)
	}
}

func (j *jam) Scanner() *bufio.Scanner {
	return j.sc
}

func (j *jam) Writer() *bufio.Writer {
	return j.wr
}

func (j *jam) Str() string {
	if !j.sc.Scan() {
		panic("failed to scan next token")
	}

	return j.sc.Text()
}

func (j *jam) Int() int64 {
	if !j.sc.Scan() {
		panic("failed to scan next token")
	}

	res, err := strconv.ParseInt(j.sc.Text(), 10, 64)
	if err != nil {
		panic(err)
	}

	_, _ = fmt.Fprintf(os.Stderr, "scanned %d", res)
	_ = os.Stderr.Sync()

	return res
}

func (j *jam) Float() float64 {
	j.sc.Scan()
	res, err := strconv.ParseFloat(j.sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return res
}

func (j *jam) P(format string, values ...interface{}) {
	_, err := fmt.Fprintf(j.wr, format, values...)
	if err != nil {
		panic(err)
	}
}

func (j *jam) PF(format string, values ...interface{}) {
	_, err := fmt.Fprintf(j.wr, format, values...)
	if err != nil {
		panic(err)
	}
	if err = j.wr.Flush(); err != nil {
		panic(err)
	}
}

//	GoLang shorthand methods for math go below
//	TODO wipe unused methods before submitting

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

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

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

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

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

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

package main

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

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

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

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

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

func main() {
	// code GOes here

	var T int
	for scan(&T); T>0; T-- {
		var (
			cnt [26](int)
			s string
			minv int = 27
			maxv int = -1
		)
		scan(&s)
		for _, c := range s {
			cnt[c-'a'] += 1
			minv = min(minv, int(c-'a'))
			maxv = max(maxv, int(c-'a'))
		}

		if minv == maxv {
			print(s,"\n")
		} else if maxv-minv > 2 {
			last := 27
			for i:=0; i<26; i++ {
				if i%2 != minv%2 {
					if cnt[i] > 0 {
						last = i
					}
					for j:=0; j<cnt[i]; j++ {
						print(string(i+'a'))
					}
				}
			}
			if last-minv > 1 {
				for i:=0; i<26; i++ {
					if i%2 == minv%2 {
						for j:=0; j<cnt[i]; j++ {
							print(string(i+'a'))
						}
					}
				}
			} else {
				for i:=25; i>=0; i-- {
					if i%2 == minv%2 {
						for j:=0; j<cnt[i]; j++ {
							print(string(i+'a'))
						}
					}
				}
			}
			print("\n")
		} else {
			print("No answer\n")
		}
	}

	writer.Flush()
	return
}

package main

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

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

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

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

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

func main() {
	// code GOes here

	var T int
	for scan(&T); T>0; T-- {
		var (
			cnt [26](int)
			s string
			minv int = 27
			maxv int = -1
		)
		scan(&s)
		for _, c := range s {
			cnt[c-'a'] += 1
			minv = min(minv, int(c-'a'))
			maxv = max(maxv, int(c-'a'))
		}

		if minv == maxv {
			print(s,"\n")
		} else if maxv-minv > 2 {
			for i:=0; i<26; i++ {
				if i%2 != minv%2 {
					for j:=0; j<cnt[i]; j++ {
						print(string(i+'a'))
					}
				}
			}
			for i:=0; i<26; i++ {
				if i%2 == minv%2 {
					for j:=0; j<cnt[i]; j++ {
						print(string(i+'a'))
					}
				}
			}
			print("\n")
		} else {
			print("No answer\n")
		}
	}

	writer.Flush()
	return
}

package main

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

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

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

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

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

func main() {
	// code GOes here

	var T int
	for scan(&T); T>0; T-- {
		var (
			cnt [26](int)
			s string
			minv int = 27
			maxv int = -1
		)
		scan(&s)
		for _, c := range s {
			cnt[c-'a'] += 1
			minv = min(minv, int(c-'a'))
			maxv = max(maxv, int(c-'a'))
		}

		if minv == maxv {
			print(s,"\n")
		} else if maxv-minv > 2 {
			for i:=0; i<26; i++ {
				if i%2 == maxv%2 {
					for j:=0; j<cnt[i]; j++ {
						print(string(i+'a'))
					}
				}
			}
			for i:=0; i<26; i++ {
				if i%2 != maxv%2 {
					for j:=0; j<cnt[i]; j++ {
						print(string(i+'a'))
					}
				}
			}
			print("\n")
		} else {
			print("No answer\n")
		}
	}

	writer.Flush()
	return
}

package main

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

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

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

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

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

func main() {
	// code GOes here

	var T int
	for scan(&T); T>0; T-- {
		var (
			cnt [26](int)
			s string
			minv int = 27
			maxv int = -1
		)
		scan(&s)
		for _, c := range s {
			cnt[c-'a'] += 1
			minv = min(minv, int(c-'a'))
			maxv = max(maxv, int(c-'a'))
		}

		if minv == maxv {
			print(s,"\n")
		} else if maxv-minv > 2 {
			for i:=0; i<26; i++ {
				if i%2 == maxv%2 {
					for j:=0; j<cnt[i]; j++ {
						print(string(i+'a'))
					}
				}
			}
			for i:=25; i>=0; i-- {
				if i%2 != maxv%2 {
					for j:=0; j<cnt[i]; j++ {
						print(string(i+'a'))
					}
				}
			}
			print("\n")
		} else {
			print("No answer\n")
		}
	}

	writer.Flush()
	return
}

package main

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

func abs(x int) int {
    if x >= 0 {
        return x
    } else {
        return -x
    }
}

func main() {
    input := bufio.NewScanner(os.Stdin)
    input.Split(bufio.ScanWords)

    input.Scan()
    t, _ := strconv.Atoi(input.Text())

    for kase := 1; kase <= t; kase++ {
        input.Scan()
        s := input.Text()

        odd := make([]byte, 0)
        even := make([]byte, 0)
        for i := 0; i < len(s); i++ {
            ord := int(s[i]) - int('a')
            if ord % 2 == 0 {
                even = append(even, s[i])
            } else {
                odd = append(odd, s[i])
            }
        }

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

        var result string
        if len(odd) == 0 || len(even) == 0 {
            result = s
        } else if (abs(int(even[len(even) - 1]) - int(odd[0])) != 1) {
            result = string(even) + string(odd)
        } else if (abs(int(odd[len(odd) - 1]) - int(even[0])) != 1) {
            result = string(odd) + string(even)
        } else {
            fmt.Println("No answer")
            return
        }

        fmt.Println(result)
    }
}

package main

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

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

func Sol1156B(reader io.Reader, writer io.Writer) {
	in := bufio.NewReader(reader)
	out := bufio.NewWriter(writer)
	defer out.Flush()

	const na = "No answer"

	var n int
	Fscan(in, &n)
	for ; n > 0; n-- {
		var s string
		Fscan(in, &s)

		cnt := make([]int, 26)
		for _, b := range s {
			cnt[b-'a']++
		}
		indexes := []int{}
		for i, c := range cnt {
			if c > 0 {
				indexes = append(indexes, i)
			}
		}

		ans := ""
		switch len(indexes) {
		case 1:
			ans = s
		case 2:
			if indexes[0]+1 == indexes[1] {
				ans = na
			} else {
				ans = s
			}
		case 3:
			i0, i1, i2 := indexes[0], indexes[1], indexes[2]
			if i0+1 == i1 && i0+2 == i2 {
				ans = na
			} else if i0+1 == i1 {
				ans = strings.Repeat(string('a'+i0), cnt[i0]) +
					strings.Repeat(string('a'+i2), cnt[i2]) +
					strings.Repeat(string('a'+i1), cnt[i1])
			} else if i0+2 == i2 {
				ans = strings.Repeat(string('a'+i1), cnt[i1]) +
					strings.Repeat(string('a'+i0), cnt[i0]) +
					strings.Repeat(string('a'+i2), cnt[i2])
			} else {
				ans = s
			}
		default:
			for i := 1; i < len(indexes); i += 2 {
				idx := indexes[i]
				ans += strings.Repeat(string('a'+idx), cnt[idx])
			}
			for i := 0; i < len(indexes); i += 2 {
				idx := indexes[i]
				ans += strings.Repeat(string('a'+idx), cnt[idx])
			}
		}
		Fprintln(out, ans)
	}
}

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

package main

import (
	"bufio"
	"bytes"
	"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 ok(s string) bool {
	n := len(s)
	for i := 0; i < n-1; i++ {
		diff := int(s[i] - s[i+1])
		if diff == 1 || diff == -1 {
			return false
		}
	}
	return true
}

func solve(s string) {
	var odd, even bytes.Buffer
	for _, c := range s {
		if int(c) % 2 == 0 {
			even.WriteByte(byte(c))
		} else {
			odd.WriteByte(byte(c))
		}
	}
	o := odd.String()
	e := even.String()

	oo := []byte(o)
	ee := []byte(e)

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

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

	o = string(oo)
	e = string(ee)

	if ok(o + e) {
		printf("%s\n", o + e)
	} else if ok(e + o) {
		printf("%s\n", e + o)
	} else {
		printf("No answer\n")
	}
}

func main() {
	defer writer.Flush()

	var T int
	scanf("%d\n", &T)
	for i := 0; i < T; i++ {
		var s string
		scanf("%s\n", &s)
		solve(s)
	}
}

package main

import (
	"fmt"
)

func main() {

	alph := "abcdefghijklmnopqrstuvwxyz"

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

	for ; tcase > 0; tcase -= 1 {
		var s string
		var cnt [30]int
		dis := 0
		order := ""

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

		for _, j := range s {
			if cnt[j-'a'] == 0 {
				dis += 1
			}
			cnt[j-'a'] += 1
		}

		for i := 0; i < 26; i += 1 {
			if cnt[i] > 0 {
				order += string(alph[i])
			}
		}

		res := ""

		for i, j, k := 0, (len(order))/2, 0; len(res) < len(s); k ^= 1 {
			if k == 1 && i <= len(order)/2 {
				for ; cnt[order[i]-'a'] > 0; cnt[order[i]-'a'] -= 1 {
					res = res + order[i:i+1]
				}
				i += 1
			}
			if k == 0 && j < len(order) {
				for ; cnt[order[j]-'a'] > 0; cnt[order[j]-'a'] -= 1 {
					res = res + order[j:j+1]
				}
				j += 1
			}
			//				log.Print(i, j, res)
		}

		check := true

		for i := 1; i < len(res) && check; i += 1 {
			if res[i]-1 == res[i-1] || res[i]+1 == res[i-1] {
				check = false
			}
		}
		//log.Print(res)
		if check {
			fmt.Println(res)
		} else {
			fmt.Println("No answer")
		}

	}
}

package main

import (
	"fmt"
)

func main() {

	alph := "abcdefghijklmnopqrstuvwxyz"

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

	for ; tcase > 0; tcase -= 1 {
		var s string
		var cnt [30]int
		dis := 0
		order := ""

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

		for _, j := range s {
			if cnt[j-'a'] == 0 {
				dis += 1
			}
			cnt[j-'a'] += 1
		}

		for i := 0; i < 26; i += 1 {
			if cnt[i] > 0 {
				order += string(alph[i])
			}
		}

		res := ""

		for i, j, k := 0, (len(order)+1)/2, 0; len(res) < len(s); k ^= 1 {
			if k == 1 && i <= len(order)/2 {
				for ; cnt[order[i]-'a'] > 0; cnt[order[i]-'a'] -= 1 {
					res = res + order[i:i+1]
				}
				i += 1
			}
			if k == 0 && j < len(order) {
				for ; cnt[order[j]-'a'] > 0; cnt[order[j]-'a'] -= 1 {
					res = res + order[j:j+1]
				}
				j += 1
			}
			//				log.Print(i, j, res)
		}

		check := true

		for i := 1; i < len(res) && check; i += 1 {
			if res[i]-1 == res[i-1] || res[i]+1 == res[i-1] {
				check = false
			}
		}
		//log.Print(res)
		if check {
			fmt.Println(res)
		} else {
			fmt.Println("No answer")
		}

	}
}


This is the hard version of the problem. The only difference between the two versions is that the harder version asks additionally for a minimum number of subsegments.Tokitsukaze has a binary string $$$s$$$ of length $$$n$$$, consisting only of zeros and ones, $$$n$$$ is even.Now Tokitsukaze divides $$$s$$$ into the minimum number of contiguous subsegments, and for each subsegment, all bits in each subsegment are the same. After that, $$$s$$$ is considered good if the lengths of all subsegments are even.For example, if $$$s$$$ is "11001111", it will be divided into "11", "00" and "1111". Their lengths are $$$2$$$, $$$2$$$, $$$4$$$ respectively, which are all even numbers, so "11001111" is good. Another example, if $$$s$$$ is "1110011000", it will be divided into "111", "00", "11" and "000", and their lengths are $$$3$$$, $$$2$$$, $$$2$$$, $$$3$$$. Obviously, "1110011000" is not good.Tokitsukaze wants to make $$$s$$$ good by changing the values of some positions in $$$s$$$. Specifically, she can perform the operation any number of times: change the value of $$$s_i$$$ to '0' or '1' ($$$1 \leq i \leq n$$$). Can you tell her the minimum number of operations to make $$$s$$$ good? Meanwhile, she also wants to know the minimum number of subsegments that $$$s$$$ can be divided into among all solutions with the minimum number of operations.

The first contains a single positive integer $$$t$$$ ($$$1 \leq t \leq 10\,000$$$) — the number of test cases. For each test case, the first line contains a single integer $$$n$$$ ($$$2 \leq n \leq 2 \cdot 10^5$$$) — the length of $$$s$$$, it is guaranteed that $$$n$$$ is even. The second line contains a binary string $$$s$$$ of length $$$n$$$, consisting only of zeros and ones. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2 \cdot 10^5$$$.

For each test case, print a single line with two integers — the minimum number of operations to make $$$s$$$ good, and the minimum number of subsegments that $$$s$$$ can be divided into among all solutions with the minimum number of operations.

NoteIn the first test case, one of the ways to make $$$s$$$ good is the following.Change $$$s_3$$$, $$$s_6$$$ and $$$s_7$$$ to '0', after that $$$s$$$ becomes "1100000000", it can be divided into "11" and "00000000", which lengths are $$$2$$$ and $$$8$$$ respectively, the number of subsegments of it is $$$2$$$. There are other ways to operate $$$3$$$ times to make $$$s$$$ good, such as "1111110000", "1100001100", "1111001100", the number of subsegments of them are $$$2$$$, $$$4$$$, $$$4$$$ respectively. It's easy to find that the minimum number of subsegments among all solutions with the minimum number of operations is $$$2$$$.In the second, third and fourth test cases, $$$s$$$ is good initially, so no operation is required.

package main

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

func solve(in io.Reader, out io.Writer) {
	var n int
	var s string
	Fscan(in, &n, &s)

	Fscanf(in, "%s", &s)

	//Fprintln(out, n, "         ", s)
	var prev uint8 = '2'
	notEqCnt := 0
	segmentCnt := 0

	for i := 0; i < n; i += 2 {
		if s[i] != s[i+1] {
			notEqCnt++
		} else if prev != s[i] {
			prev = s[i]
			segmentCnt++
		}
	}
	if segmentCnt == 0 {
		segmentCnt = 1
	}

	Fprintf(out, "%d %d\n", notEqCnt, segmentCnt)
	//Fprintln(out, notEqCnt)

}

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var T int
	for Fscan(in, &T); T > 0; T-- {
		solve(in, out)
	}
}

package main

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

type Int int64

const (
	INF = 3e5 + 10
	L0  = Int(0)
	L1  = Int(1)
)

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

	var t int
	Fscan(in, &t)

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

		dp := MakeGrid(n+1, 2)
		f := MakeGrid(n+1, 2)

		for i := 1; i < n; i += 2 {
			dp[i][0] = Int(n)
			dp[i][1] = Int(n)

			to0 := L0
			if s[i-1] == '1' {
				to0++
			}
			if s[i] == '1' {
				to0++
			}

			to1 := L0
			if s[i-1] == '0' {
				to1++
			}
			if s[i] == '0' {
				to1++
			}

			if i > 2 {
				if dp[i-2][0] == dp[i-2][1] {
					dp[i][0] = dp[i-2][0] + to0
					dp[i][1] = dp[i-2][1] + to1

					f[i][0] = Min(f[i-2][0], f[i-2][1]+1)
					f[i][1] = Min(f[i-2][0]+1, f[i-2][1])
				} else if dp[i-2][0] < dp[i-2][1] {
					dp[i][0] = dp[i-2][0] + to0
					f[i][0] = f[i-2][0]

					dp[i][1] = dp[i-2][0] + to1
					f[i][1] = f[i-2][0] + 1
				} else {
					dp[i][0] = dp[i-2][1] + to0
					f[i][0] = f[i-2][1] + 1

					dp[i][1] = dp[i-2][1] + to1
					f[i][1] = f[i-2][1]
				}

			} else {
				dp[i][0] = to0
				dp[i][1] = to1
				f[i][0] = 1
				f[i][1] = 1
			}

			if i == n-1 {
				if dp[i][0] == dp[i][1] {
					Fprintln(out, dp[i][0], Min(f[i][0], f[i][1]))

				} else if dp[i][0] < dp[i][1] {
					Fprintln(out, dp[i][0], f[i][0])
				} else {
					Fprintln(out, dp[i][1], f[i][1])
				}
			}
		}
	}

}

func MakeGrid(h, w int) [][]Int {
	index := make([][]Int, h)
	data := make([]Int, h*w)
	for i := 0; i < h; i++ {
		index[i] = data[i*w : (i+1)*w]
	}
	return index
}

func Abs(x Int) Int {
	if x > 0 {
		return x
	}
	return -x
}

func Min(nums ...Int) Int {
	return nums[MinIdx(nums...)]
}

func MinIdx(nums ...Int) Int {
	maxNumIdx := L0
	for i, num := range nums {
		if num < nums[maxNumIdx] {
			maxNumIdx = Int(i)
		}
	}
	return maxNumIdx
}

func Max(nums ...Int) Int {
	return nums[MaxIdx(nums...)]
}

func MaxIdx(nums ...Int) Int {
	maxNumIdx := L0
	for i, num := range nums {
		if num > nums[maxNumIdx] {
			maxNumIdx = Int(i)
		}
	}
	return maxNumIdx
}

var (
	mod  Int
	fmod func(Int) Int = doNothing
)

// SetMod sets the mod. It must be called first.
func SetMod(newMod Int) {
	mod = newMod
	fmod = dynamicMod
}

func dynamicMod(m Int) Int {
	m %= mod
	if m < 0 {
		return m + mod
	}
	return m
}

func doNothing(m Int) Int {
	return m
}

// Mod returns m % mod.
func (m Int) Mod() Int {
	return fmod(m)
}

// Inv returns modular multiplicative inverse
func (m Int) Inv() Int {
	return m.Pow(Int(0).Sub(2))
}

// Pow returns m^n
func (m Int) Pow(n Int) Int {
	p := Int(1)
	for n > 0 {
		if n&1 == 1 {
			p.MulAs(m)
		}
		m.MulAs(m)
		n >>= 1
	}
	return p
}

// Add returns m+x
func (m Int) Add(x Int) Int {
	return (m + x).Mod()
}

// Sub returns m-x
func (m Int) Sub(x Int) Int {
	return (m - x).Mod()
}

// Mul returns m*x
func (m Int) Mul(x Int) Int {
	return (m * x).Mod()
}

// Div returns m/x
func (m Int) Div(x Int) Int {
	return m.Mul(x.Inv())
}

// AddAs assigns *m + x to *m and returns m
func (m *Int) AddAs(x Int) *Int {
	*m = m.Add(x)
	return m
}

// SubAs assigns *m - x to *m and returns m
func (m *Int) SubAs(x Int) *Int {
	*m = m.Sub(x)
	return m
}

// MulAs assigns *m * x to *m and returns m
func (m *Int) MulAs(x Int) *Int {
	*m = m.Mul(x)
	return m
}

// DivAs assigns *m / x to *m and returns m
func (m *Int) DivAs(x Int) *Int {
	*m = m.Div(x)
	return m
}

func (m *Int) MaxAs(x ...Int) *Int {
	*m = Max(append(x, *m)...)
	return m
}

func (m *Int) MinAs(x ...Int) *Int {
	*m = Min(append(x, *m)...)
	return m
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)
var wrtr = bufio.NewWriterSize(os.Stdout, 10_000_000)
var rdr = bufio.NewScanner(os.Stdin)
func gs() string  { rdr.Scan(); return rdr.Text() }
func gi() int     { i,e := strconv.Atoi(gs()); if e != nil {panic(e)}; return i }
func min(a,b int) int { if a > b { return b }; return a }
const inf = 1000000000
func main() {
	//f1, _ := os.Create("cpu.prof"); pprof.StartCPUProfile(f1); defer pprof.StopCPUProfile()
	defer wrtr.Flush()
	infn := ""; if infn == "" && len(os.Args) > 1 {	infn = os.Args[1] }
	if infn != "" {	f, e := os.Open(infn); if e != nil { panic(e) }; rdr = bufio.NewScanner(f) }
	rdr.Split(bufio.ScanWords); rdr.Buffer(make([]byte,1024),1_000_000_000)
	// PROGRAM STARTS HERE
	T := gi()
	for tt:=1;tt<=T;tt++ {
		N := gi(); S := gs()
		dp0,dp1,ans := 0,0,0
		for i:=0;i<N;i+=2 {
			s := S[i:i+2]
			if i == 0 {
				if s == "00" {
					dp0,dp1 = 1,inf
				} else if s == "11" {
					dp0,dp1 = inf,1
				} else {
					ans++; dp0,dp1 = 1,1
				}
			} else {
				if s == "00" {
					dp0,dp1 = min(dp0,1+dp1),inf
				} else if s == "11" {
					dp0,dp1 = inf,min(dp0+1,dp1)
				} else {
					ans++;
					dp0,dp1 = min(dp0,dp1+1),min(dp1,dp0+1)
				}
			}
		}
		fmt.Fprintf(wrtr,"%v %v\n",ans,min(dp0,dp1))
	}
}

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1678B2(_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)
		ans, seg := 0, 0
		for i, pre := 0, byte(0); i < n; i += 2 {
			if s[i] != s[i+1] {
				ans++
			} else if s[i] != pre {
				seg++
				pre = s[i]
			}
		}
		if seg == 0 {
			seg = 1
		}
		Fprintln(out, ans, seg)
	}
}

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

package main

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

const eof = 0

type any = interface{}

type MyIO struct {
	in  *os.File
	out *bufio.Writer
	_i  int
	_n  int
	buf []byte
}

func NewIO(in *os.File, out *os.File) *MyIO {
	return &MyIO{
		in,
		bufio.NewWriter(out),
		0, 0, make([]byte, 1<<12),
	}
}

func (myio *MyIO) rc() byte {
	if myio._i == myio._n {
		myio._n, _ = myio.in.Read(myio.buf)
		if myio._n == 0 { // EOF
			return eof
		}
		myio._i = 0
	}
	b := myio.buf[myio._i]
	myio._i++
	return b
}

func (myio *MyIO) ReadInt() (x int) {
	rc := myio.rc
	b := rc()
	neg := false

	for ; '0' > b || b > '9'; b = rc() {
		if b == eof {
			return
		}
		if b == '-' {
			neg = true
		}
	}
	for ; '0' <= b && b <= '9'; b = rc() {
		x = x*10 + int(b&15)
	}
	if neg {
		return -x
	}
	return x
}

func (myio *MyIO) ReadBytes() (s []byte) {
	rc := myio.rc
	b := rc()
	for ; b <= ' '; b = rc() {
	}
	for ; b > ' '; b = rc() {
		s = append(s, b)
	}
	return
}

func (myio *MyIO) ReadStr() (s string) {
	return string(myio.ReadBytes())
}

func (myio *MyIO) Flush() {
	myio.out.Flush()
}

func (myio *MyIO) Printf(format string, a ...any) (n int, err error) {
	return fmt.Fprintf(myio.out, format, a...)
}

func (myio *MyIO) Println(a ...any) (n int, err error) {
	return fmt.Fprintln(myio.out, a...)
}

func (myio *MyIO) Print(a ...any) (n int, err error) {
	return fmt.Fprint(myio.out, a...)
}

const inf = 10000000

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

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

func main() {
	myio := NewIO(os.Stdin, os.Stdout)
	defer myio.Flush()

	t := myio.ReadInt()
	sol := func() {
		n := myio.ReadInt()
		b := myio.ReadBytes()
		c := 0
		d0 := 0
		d1 := 0
		var nd0, nd1 int
		for i := 0; i < n; i += 2 {
			if b[i] != b[i+1] {
				// change to 0
				nd0 = min(d0, d1+1)
				// change to 1
				nd1 = min(d1, d0+1)
				c++
			} else {
				if b[i] == '0' {
					nd0 = min(d0, d1+1)
					nd1 = inf
				} else {
					nd0 = inf
					nd1 = min(d1, d0+1)
				}
			}
			d0, d1 = nd0, nd1
		}
		myio.Println(c, min(d0, d1)+1)
	}
	for ; t > 0; t-- {
		sol()
	}
}

package main

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

func solve(in io.Reader, out io.Writer) {
	var n int
	var s string
	Fscan(in, &n, &s)

	Fscanf(in, "%s", &s)

	//Fprintln(out, n, "         ", s)
	var prev uint8 = '2'
	notEqCnt := 0
	segmentCnt := 0

	for i := 0; i < n; i += 2 {
		if s[i] != s[i+1] {
			notEqCnt++
		} else if prev != s[i] {
			prev = s[i]
			segmentCnt++
		}
	}

	Fprintf(out, "%d %d\n", notEqCnt, segmentCnt)
	//Fprintln(out, notEqCnt)

}

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var T int
	for Fscan(in, &T); T > 0; T-- {
		solve(in, out)
	}
}

package main

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

type Int int64

const (
	INF = 3e5 + 10
	L0  = Int(0)
	L1  = Int(1)
)

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

	var t int
	Fscan(in, &t)

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

		dp := MakeGrid(n+1, 2)
		f := MakeGrid(n+1, 2)

		for i := 1; i < n; i += 2 {
			dp[i][0] = Int(n)
			dp[i][1] = Int(n)

			to0 := L0
			if s[i-1] == '1' {
				to0++
			}
			if s[i] == '1' {
				to0++
			}

			to1 := L0
			if s[i-1] == '0' {
				to1++
			}
			if s[i] == '0' {
				to1++
			}

			if i > 2 {
				if dp[i-2][0] < dp[i-2][1] {
					dp[i][0] = dp[i-2][0] + to0
					f[i][0] = f[i-2][0]
				} else {
					dp[i][0] = dp[i-2][1] + to0
					f[i][0] = f[i-2][1] + 1
				}

				if dp[i-2][0] < dp[i-2][1] {
					dp[i][1] = dp[i-2][0] + to1
					f[i][1] = f[i-2][0] + 1
				} else {
					dp[i][1] = dp[i-2][1] + to1
					f[i][1] = f[i-2][1]
				}

			} else {
				dp[i][0] = to0
				dp[i][1] = to1
				f[i][0] = 1
				f[i][1] = 1
			}

			if i == n-1 {
				if dp[i][0] < dp[i][1] {
					Fprintln(out, dp[i][0], f[i][0])
				} else {
					Fprintln(out, dp[i][1], f[i][1])
				}
			}
		}
	}

}

func MakeGrid(h, w int) [][]Int {
	index := make([][]Int, h)
	data := make([]Int, h*w)
	for i := 0; i < h; i++ {
		index[i] = data[i*w : (i+1)*w]
	}
	return index
}

func Abs(x Int) Int {
	if x > 0 {
		return x
	}
	return -x
}

func Min(nums ...Int) Int {
	return nums[MinIdx(nums...)]
}

func MinIdx(nums ...Int) Int {
	maxNumIdx := L0
	for i, num := range nums {
		if num < nums[maxNumIdx] {
			maxNumIdx = Int(i)
		}
	}
	return maxNumIdx
}

func Max(nums ...Int) Int {
	return nums[MaxIdx(nums...)]
}

func MaxIdx(nums ...Int) Int {
	maxNumIdx := L0
	for i, num := range nums {
		if num > nums[maxNumIdx] {
			maxNumIdx = Int(i)
		}
	}
	return maxNumIdx
}

var (
	mod  Int
	fmod func(Int) Int = doNothing
)

// SetMod sets the mod. It must be called first.
func SetMod(newMod Int) {
	mod = newMod
	fmod = dynamicMod
}

func dynamicMod(m Int) Int {
	m %= mod
	if m < 0 {
		return m + mod
	}
	return m
}

func doNothing(m Int) Int {
	return m
}

// Mod returns m % mod.
func (m Int) Mod() Int {
	return fmod(m)
}

// Inv returns modular multiplicative inverse
func (m Int) Inv() Int {
	return m.Pow(Int(0).Sub(2))
}

// Pow returns m^n
func (m Int) Pow(n Int) Int {
	p := Int(1)
	for n > 0 {
		if n&1 == 1 {
			p.MulAs(m)
		}
		m.MulAs(m)
		n >>= 1
	}
	return p
}

// Add returns m+x
func (m Int) Add(x Int) Int {
	return (m + x).Mod()
}

// Sub returns m-x
func (m Int) Sub(x Int) Int {
	return (m - x).Mod()
}

// Mul returns m*x
func (m Int) Mul(x Int) Int {
	return (m * x).Mod()
}

// Div returns m/x
func (m Int) Div(x Int) Int {
	return m.Mul(x.Inv())
}

// AddAs assigns *m + x to *m and returns m
func (m *Int) AddAs(x Int) *Int {
	*m = m.Add(x)
	return m
}

// SubAs assigns *m - x to *m and returns m
func (m *Int) SubAs(x Int) *Int {
	*m = m.Sub(x)
	return m
}

// MulAs assigns *m * x to *m and returns m
func (m *Int) MulAs(x Int) *Int {
	*m = m.Mul(x)
	return m
}

// DivAs assigns *m / x to *m and returns m
func (m *Int) DivAs(x Int) *Int {
	*m = m.Div(x)
	return m
}

func (m *Int) MaxAs(x ...Int) *Int {
	*m = Max(append(x, *m)...)
	return m
}

func (m *Int) MinAs(x ...Int) *Int {
	*m = Min(append(x, *m)...)
	return m
}


Vasya learns to type. He has an unusual keyboard at his disposal: it is rectangular and it has n rows of keys containing m keys in each row. Besides, the keys are of two types. Some of the keys have lowercase Latin letters on them and some of the keys work like the "Shift" key on standard keyboards, that is, they make lowercase letters uppercase.Vasya can press one or two keys with one hand. However, he can only press two keys if the Euclidean distance between the centers of the keys does not exceed x. The keys are considered as squares with a side equal to 1. There are no empty spaces between neighbouring keys.Vasya is a very lazy boy, that's why he tries to type with one hand as he eats chips with his other one. However, it is possible that some symbol can't be typed with one hand only, because the distance between it and the closest "Shift" key is strictly larger than x. In this case he will have to use his other hand. Having typed the symbol, Vasya returns other hand back to the chips.You are given Vasya's keyboard and the text. Count the minimum number of times Vasya will have to use the other hand.

The first line contains three integers n, m, x (1 ≤ n, m ≤ 30, 1 ≤ x ≤ 50). Next n lines contain descriptions of all the keyboard keys. Each line contains the descriptions of exactly m keys, without spaces. The letter keys are marked with the corresponding lowercase letters. The "Shift" keys are marked with the "S" symbol.  Then follow the length of the text q (1 ≤ q ≤ 5·105). The last line contains the text T, which consists of q symbols, which are uppercase and lowercase Latin letters.

If Vasya can type the text, then print the minimum number of times he will have to use his other hand. Otherwise, print "-1" (without the quotes).

3 9 4
qwertyuio
asdfghjkl
SzxcvbnmS
35
TheQuIcKbRoWnFOXjummsovertHeLazYDOG

NoteIn the first sample the symbol "A" is impossible to print as there's no "Shift" key on the keyboard.In the second sample the symbol "e" is impossible to print as there's no such key on the keyboard.In the fourth sample the symbols "T", "G" are impossible to print with one hand. The other letters that are on the keyboard can be printed. Those symbols come up in the text twice, thus, the answer is 2.

package main

import (
	"fmt"
	"io/ioutil"
	"os"
	"bytes"
)

func main() {
	bs, _ := ioutil.ReadAll(os.Stdin)
	reader := bytes.NewBuffer(bs)
	var n, m, x, q int
	fmt.Fscanf(reader, "%d %d %d\n", &n, &m, &x)
	keyboard := make([]string, n)
	shift := [][2]int{}
	for i := 0;i < n;i ++ {
		fmt.Fscanf(reader, "%s\n", &keyboard[i])
		for j := 0;j < len(keyboard[i]);j ++ {
			if keyboard[i][j] == 'S' {
				shift = append(shift, [2]int{i, j})
			}
		}
	}
	fmt.Fscanf(reader, "%d\n", &q)
	var T string
	fmt.Fscanf(reader, "%s", &T)
	var lower [26]bool
	var upper [26]bool
	for i := 0;i < n;i ++ {
		for j := 0;j < m;j ++ {
			if keyboard[i][j] != 'S' {
				pos := int(keyboard[i][j] - 'a')
				lower[pos] = true
				for k := 0;k < len(shift);k ++ {
					r, c := shift[k][0], shift[k][1]
					if (r - i) * (r - i) + (c - j) * (c - j) <= x * x {
						upper[pos] = true
					}
				}
			}
		}
	}
	ans := 0
	for i := 0;i < len(T);i ++ {
		if T[i] >= 'a' && T[i] <= 'z' && !lower[int(T[i] - 'a')] {
			fmt.Printf("-1")
			return
		} else if T[i] >= 'A' && T[i] <= 'Z' {
			if len(shift) == 0 || !lower[int(T[i] - 'A')] {
				fmt.Printf("-1")
				return
			} else if !upper[int(T[i] - 'A')] {
				ans ++
			}
		}
	}
	fmt.Printf("%d", ans)
}

package main

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

var scanner *bufio.Scanner

func getI64() int64 {
  scanner.Scan()
  x, _ := strconv.ParseInt(scanner.Text(), 10, 64)
  return x
}
func getI() int {
  return int(getI64())
}
func getF() float64 {
  scanner.Scan()
  x, _ := strconv.ParseFloat(scanner.Text(), 64)
  return x
}
func getS() string {
  scanner.Scan()
  return scanner.Text()
}

type Key struct {
  R, C int
  Ch rune
}

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

  var n, m, x int
  line, _ := reader.ReadString('\n')
  fmt.Sscanf(line, "%d %d %d", &n, &m, &x)
  keys := []Key{}
  for r := 0; r < n; r++ {
    line, _ := reader.ReadString('\n')
    s := strings.TrimSpace(line)
    for c, ch := range s {
      keys = append(keys, Key{ r, c, ch })
    }
  }
  cost := map[rune]int{}
  for i := 0; i < len(keys); i++ {
    a := keys[i]
    if a.Ch != 'S' {
      cost[a.Ch] = 1
      continue
    }
    for j := 0; j < len(keys); j++ {
      b := keys[j]
      if b.Ch != 'S' {
        ch := b.Ch - 'a' + 'A'
        if cost[ch] == 1 {
          continue
        }
        cost[ch] = 2
        d2 := (a.R - b.R)*(a.R - b.R) + (a.C - b.C)*(a.C - b.C)
        if d2 <= x*x {
          cost[ch] = 1
        }
      }
    }
  }
  reader.ReadString('\n')
  line, _ = reader.ReadString('\n')
  s := strings.TrimSpace(line)
  result := 0
  for _, ch := range s {
    c, found := cost[ch]
    if !found {
      writer.WriteString("-1\n")
      return
    }
    result += c-1
  }
  writer.WriteString(fmt.Sprintf("%d\n", result))
}


You are standing at the point $$$0$$$ on a coordinate line. Your goal is to reach the point $$$n$$$. In one minute, you can move by $$$2$$$ or by $$$3$$$ to the left or to the right (i. e., if your current coordinate is $$$x$$$, it can become $$$x-3$$$, $$$x-2$$$, $$$x+2$$$ or $$$x+3$$$). Note that the new coordinate can become negative.Your task is to find the minimum number of minutes required to get from the point $$$0$$$ to the point $$$n$$$.You have to answer $$$t$$$ independent test cases.

The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ lines describing the test cases follow. The $$$i$$$-th of these lines contains one integer $$$n$$$ ($$$1 \le n \le 10^9$$$) — the goal of the $$$i$$$-th test case.

For each test case, print one integer — the minimum number of minutes required to get from the point $$$0$$$ to the point $$$n$$$ for the corresponding test case.

package main

import (
	"fmt"
)

func main() {
	var t, n int
	fmt.Scanf("%d\n", &t)
	for i := 0; i < t; i++ {
		fmt.Scanf("%d\n", &n)
		if n == 1 {
			fmt.Println(2)
		} else {
			fmt.Println((n-1)/3 + 1)
		}
	}
}

package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	var temp []int

	for scanner.Scan() {
		d, _ := strconv.Atoi(scanner.Text())
		temp = append(temp, d)
	}
	for i := 1; i < len(temp); i++ {
		if temp[i]%3 == 0 {
			fmt.Println(temp[i] / 3)
		} else if temp[i] == 1 {
			fmt.Println(2)
		} else {
			fmt.Println(temp[i]/3 + 1)
		}
	}
}

package main

import (
	"fmt"
)

func main() {
	var line int
	fmt.Scanf("%d\n", &line)
	for i := 0; i < line; i++ {
		var num int
		fmt.Scanf("%d\n", &num)
		if num == 1 {
			fmt.Println(2)
			continue
		}
		switch num % 6 {
		case 0, 3:
			fmt.Println(num / 3)
		case 1:
			fmt.Println(num/3 + 1)
		case 2, 4, 5:
			fmt.Println(num/3 + 1)
		}
	}
}

package main

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

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

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

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

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

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

/**
Run solve the problem CF1716A
Date: 5/08/22
User: pepradere
URL: https://codeforces.com/problemset/problem/1716/A
Problem: CF1716A
**/
func (in *CF1716A) Run() {
	for t := in.NextInt(); t > 0; t-- {
		n := in.NextInt64()
		ans := int64(math.Ceil(float64(n) / 3.))
		if n == 1 {
			fmt.Println(2)
		} else {
			fmt.Println(ans)
		}
	}
}

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

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

package main

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

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

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

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

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

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

/**
Run solve the problem CF1716A
Date: 5/08/22
User: pepradere
URL: https://codeforces.com/problemset/problem/1716/A
Problem: CF1716A
**/
func (in *CF1716A) Run() {
	for t := in.NextInt(); t > 0; t-- {
		n := in.NextInt64()
		ans := int64(math.Ceil(float64(n) / 3.))
		if n == 1 {
			fmt.Println(2)
		} else if n%3 == 0 {
			fmt.Println(ans)
		} else if n%2 == 0 {
			fmt.Println(ans)
		} else {
			fmt.Println(ans)
		}

	}
}

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

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

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	for i:=0; i < n; i++ {
		var val int
		fmt.Scan(&val)
		if val == 1 {
			fmt.Println(2)
			continue
		}
		res := val / 3
		if val % 3 != 0 {
			res += 1
		}
		fmt.Println(res)
	}
}

package main

import "fmt"

func ans(n int) int {
	if n == 1 {
		return 2
	}
	if n == 2 {
		return 1
	}
	if n%3 == 0 {
		return n / 3
	} else {
		return n/3 + 1
	}
	//var newews int
	//if n == 1 {
	//	return
	//}
	//if n == 2 {
	//	return
	//}
	////dp := make([]int, n+1)
	//first := 0
	//second := 2
	//third := 1
	////dp[0] = 0
	////dp[1] = 2
	////dp[2] = 1
	//for i := 3; i <= n; i++ {
	//	//dp[i] = min(dp[i-2], dp[i-3]) + 1
	//	newews = min(first, second) + 1
	//	first, second, third = second, third, newews
	//	if _, ok := (*hashmap)[i]; ok {
	//		(*hashmap)[i] = third
	//	}
	//}
}

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

func main() {
	n := 0
	_, _ = fmt.Scanf("%d\n", &n)
	tmp := 0
	//max := 0
	//req := make([]int, n)
	//hashmap := make(map[int]int, n)

	for i := 0; i < n; i++ {
		_, _ = fmt.Scanf("%d\n", &tmp)
		fmt.Println(ans(tmp))
		//req[i] = tmp
		//hashmap[tmp] = 0
		//if tmp > max {
		//	max = tmp
		//}
	}
	//hashmap[1] = 2
	//hashmap[2] = 1
	//ans(max, &hashmap)
	//for i := range req {
	//	fmt.Println(hashmap[req[i]])
	//}
}

package main
import(
    "fmt"
)
func main() {
	var t int
	fmt.Scan(&t)
	for i:=0;i<t;i++{
		var x int
		fmt.Scan(&x)
		if abs(x) == 2 {
			fmt.Println(1)
		} else if abs(x) == 4 || abs(x) == 1 {
			fmt.Println(2)
		} else if x%3 == 2 {
			fmt.Println(x/3+1)
		} else if x%3 == 1 {
			fmt.Println(x/3+1)
		} else if x%3 == 0 {
			fmt.Println(x/3)
		} else {
			fmt.Println(0)
		}
	}
}
func abs(x int) int {
	var result int
	if x > 0 {
		result = x
	} else {
		if x < 0 {
			result = x*-1
		}
	}
	return result
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	tString, _ := in.ReadString('\n')
	t, _ := strconv.Atoi(strings.TrimSpace(tString))
	for i := 0; i < t; i++ {
		nString, _ := in.ReadString('\n')
		n, _ := strconv.Atoi(strings.TrimSpace(nString))
		if n < 0 {
			n = -n
		}
		ans := 0
		switch n {
		case 1:
			ans = 2
		case 3, 2:
			ans = 1
		default:
			if n%3 == 0 {
				ans = n / 3
			} else {
				ans = n/3 + 1
			}
		}
		fmt.Println(ans)
	}
}

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

func main() {
    defer writer.Flush()
    var t, n int32
    scanf("%d\n", &t)
    for ; t > 0; t-- {
        scanf("%d\n", &n)
        switch {
        case n == 1:
            printf("%d\n", 2)
        default:
            printf("%d\n", S(n))
        }
    }
}

func S(num int32) int32 {
	return (num + 2) / 3
}

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

/*
You are standing at the point 0 on a coordinate line. Your goal is to reach the point n. In one minute, you can move by 2 or by 3 to the left or to the right (i. e., if your current coordinate is x, it can become x−3, x−2, x+2 or x+3

). Note that the new coordinate can become negative.

Your task is to find the minimum number of minutes required to get from the point 0
to the point n

.

You have to answer t

independent test cases.
Input

The first line of the input contains one integer t
(1≤t≤104) — the number of test cases. Then t

lines describing the test cases follow.

The i
-th of these lines contains one integer n (1≤n≤109) — the goal of the i

-th test case.
Output

For each test case, print one integer — the minimum number of minutes required to get from the point 0
to the point n for the corresponding test case.
*/

package main

import (
	"fmt"
	"math"
)

func minMoves(n int) int {
	if n == 1 {
		return 2
	}
	if n%3 == 0 {
		return n / 3
	} else if n%2 == 0 {
		return int(math.Ceil(float64(n) / 3))
	} else {
		return int(math.Ceil(float64(n) / 3))
	}
}

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

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1716A(_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-- {
		Fscan(in, &n)
		if n == 1 {
			Fprintln(out, 2)
		} else {
			Fprintln(out, (n+2)/3)
		}
	}
}

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

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1716A(_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-- {
		Fscan(in, &n)
		if n == 1 {
			Fprintln(out, 2)
		} else {
			Fprintln(out, (n+2)/3)
		}
	}
}

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

package main

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

var _, _, _ = main, rw, do

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

func rw(r io.Reader, w io.Writer) {
	var t int
	fmt.Fscan(r, &t)
	for ti := 0; ti < t; ti++ {
		var n int
		fmt.Fscan(r, &n)
		w1 := do(n)
		fmt.Fprintln(w, w1)
	}
}

func do(n int) int {
	if n == 1 {
		return 2
	}
	return (n-1)/3 + 1
}

package main

import (
	"fmt"
)

func main() {
	var i int
	fmt.Scan(&i)
	var lawda int
	for i != 0 {
		fmt.Scan(&lawda)
		if lawda % 3 == 0 {
			fmt.Printf("%v\n",lawda / 3)
		} else if lawda  == 1 {
			fmt.Printf("%v\n",2)
		} else {
			fmt.Printf("%v\n",lawda / 3 + 1)
		}
		i--
	}
}

package main

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

func main() {
	var t, n int
	//fmt.Scanf("%d", &t)
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	t, _ = strconv.Atoi(scanner.Text())
	for i := 0; i < t; i++ {
		//fmt.Scanf("%d", &n)
		scanner.Scan()
		n, _ = strconv.Atoi(scanner.Text())
		res := task23(n)
		fmt.Println(res)
	}
}

func task23(n int) int {
	switch n {
	case 1:
		return 2
	case 2, 3:
		return 1
	}

	rest := n % 3
	switch rest {
	case 0:
		return n / 3
	case 1, 2:
		return n / 3 + 1
	}

	return -1
}

package main

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

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

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var ntests int
	fmt.Fscan(in, &ntests)
	for iii := 0; iii < ntests; iii++ {
		var el int
		fmt.Fscan(in, &el)
		switch el % 3 {
		case 0:
			fmt.Fprintln(out, el/3)
		case 1:
			if el == 1 {
				fmt.Fprintln(out, 2)
			} else {
				fmt.Fprintln(out, el/3+1)
			}
		case 2:
			fmt.Fprintln(out, el/3+1)
		}
	}
}

// Codeforces 1718 A1 C Burenka and Traditions train (not done ((( )
package main

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

var in *bufio.Reader

func readFive() (int, int, int, int, int) {
	var a [5]int
	s, err := in.ReadString('\n')
	if err != nil {
		fmt.Println("first read failure", err)
		panic(err)
	}
	ss := strings.Split(strings.Trim(s, " \n\r"), " ")
	for i := 0; i < len(ss); i++ {
		a[i], err = strconv.Atoi(ss[i])
		if err != nil {
			fmt.Println("n atoi failure", err)
			panic(err)
		}
	}
	return a[0], a[1], a[2], a[3], a[4]
}

func readLineNumbs(n int) []int {
	al := make([]int, n)
	s, err := in.ReadString('\n')
	if err != nil {
		fmt.Println("read failure", err)
		panic(err)
	}
	ss := strings.Split(strings.Trim(s, " \n\r"), " ")
	for j := 0; j < n; j++ {
		aa, err := strconv.Atoi(ss[j])
		if err != nil {
			fmt.Println("aa conv failed", err)
			panic(err)
		}
		al[j] = aa
	}
	return al
}

var n int
var minTime int

func readData() {
	// reading n, k
	n, _, _, _, _ = readFive()
}

func absInt(i int) int {
	if i < 0 {
		return -i
	}
	return i
}

func solve() {
	minTime = 1333555777
	for n2 := -10; n2 < 10; n2++ {
		n3 := (n - 2*n2) / 3
		if (3*n3 + 2*n2) == n {
			mt := absInt(n2) + absInt(n3)
			if mt < minTime {
				minTime = mt
			}
		}
	}
}

func printRes() {
	fmt.Println(minTime)
}

func main() {
	in = bufio.NewReader(os.Stdin)
	var t, _, _, _, _ = readFive()
	for tt := 0; tt < t; tt++ {
		readData()
		solve()
		printRes()
	}
}

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)

		if n == 1 {
			fmt.Fprintln(out, 2)
		} else {
			fmt.Fprintln(out, (n+2)/3)
		}
	}
}

package main

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

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

func scan(a ...interface{}) {
	fmt.Fscan(in, a...)
}
func printf(f string, a ...interface{}) {
	fmt.Fprintf(out, f, a...)
}
func solve() {
	var n int
	scan(&n)
	if n == 1 {
		printf("2\n")
	} else {
		result := n / 3
		if n%3 > 0 {
			result += 1
		}
		printf("%d\n", result)
	}
}
func main() {
	defer out.Flush()
	n := 0
	scan(&n)
	for i := 0; i < n; i++ {
		solve()
	}
}

// https://codeforces.com/problemset/problem/1716/A

// 1716A - 2-3 Moves

// You are standing at the point 0 on a coordinate line. Your goal is to reach the point n. In one minute, you can move by 2 or by 3 to the left or to the right (i. e., if your current coordinate is x, it can become x−3, x−2, x+2 or x+3). Note that the new coordinate can become negative.
// Your task is to find the minimum number of minutes required to get from the point 0 to the point n.
// You have to answer t independent test cases.

// Input
// The first line of the input contains one integer t (1≤t≤104) — the number of test cases. Then t lines describing the test cases follow.
// The i-th of these lines contains one integer n (1≤n≤109) — the goal of the i-th test case.

// Output
// For each test case, print one integer — the minimum number of minutes required to get from the point 0 to the point n for the corresponding test case.

// Example
// input
// 4
// 1
// 3
// 4
// 12
// output
// 2
// 1
// 2
// 4

package main

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

func main() {
	var reader = bufio.NewReader(os.Stdin)
	var writer = bufio.NewWriter(os.Stdout)
	var c, t, n int

	for c, _ = fmt.Fscan(reader, &t); c == 1; c, _ = fmt.Fscan(reader, &t) {
		for ; t > 0; t-- {
			fmt.Fscan(reader, &n)

			if n == 1 {
				fmt.Fprintln(writer, 2)
			} else if n <= 3 {
				fmt.Fprintln(writer, 1)
			} else {
				fmt.Fprintln(writer, (n+2)/3)
			}
		}
	}

	writer.Flush()
}

package main

import "fmt"

func main(){
    var T int
    fmt.Scan(&T)
    for t := 0; t < T; t++{
        var n int
        fmt.Scan(&n)
        if n == 1 {
            fmt.Println("2")
            continue
        }

        res := n/3
        if n % 3 != 0 {
            res++
        }
        fmt.Println(res)

    }
}

package main

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

func solve() {
	n := get()
	if n == 1 {
		putln(2)
		return
	}
	switch n % 3 {
	case 0:
		putln(n / 3)
	case 1:
		putln(n/3 + 1)
	case 2:
		putln(n/3 + 1)
	}
}

const (
	once = false
)

var (
	in  *bufio.Scanner
	out *bufio.Writer
)

func main() {
	in = bufio.NewScanner(bufio.NewReader(os.Stdin))
	in.Split(bufio.ScanWords)

	out = bufio.NewWriter(os.Stdout)
	defer out.Flush()

	if once {
		solve()
		return
	}

	for t := get(); t > 0; t-- {
		solve()
	}
}

func geta(n int) []int {
	a := make([]int, n)
	for i := range a {
		a[i] = get()
	}
	return a
}

func get() int {
	x, _ := strconv.Atoi(gets())
	return x
}

func gets() string {
	scan()
	return in.Text()
}

func scan() {
	in.Scan()
}

func putaln(a []int) {
	for _, v := range a {
		put(v)
		putc(' ')
	}
	putc('\n')
}

func put(x int) {
	out.WriteString(strconv.Itoa(x))
}

func putln(x int) {
	put(x)
	putc('\n')
}

func putc(c rune) {
	out.WriteRune(c)
}

package main

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

const cf = true

func solve() {
	var n int
	fmt.Fscan(in, &n)
	var ans int
	if n == 1 {
		ans = 2
	} else if n%3 == 1 {
		ans = n/3 + 1
	} else if n%3 == 2 {
		ans = n/3 + 1
	} else {
		ans = n / 3
	}
	fmt.Fprintln(out, ans)
}

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

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

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

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

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

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

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

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

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

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

var exists = struct{}{}

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

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

type Float interface {
	~float32 | ~float64
}

type Integer interface {
	Signed | Unsigned
}

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

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

type Ordered interface {
	Integer | Float | ~string
}

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

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

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

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

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

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

package main

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

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

func solve(n int) int {
	if n < 0 {
		return solve(-n)
	}
	if n == 1 {
		return 2
	}
	return (n + 2) / 3
}

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

package main

import "fmt"

func main() {
	var t, n int

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

	for i := 0; i < t; i++ {
		fmt.Scanf("%d\n", &n)

		if n == 1 {
			fmt.Println(2)
		} else {
			fmt.Println((n-1)/3 + 1)
		}

	}
}

// 00
package main

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

func main() {
	var T int
	reader := bufio.NewReader(os.Stdin)
	fmt.Fscan(reader, &T)
	for t := 1; t <= T; t++ {
		var n int
		fmt.Fscan(reader, &n)
		if n == 1 {
			fmt.Println(2)
		} else {
			ans := n / 3
			if n%3 != 0 {
				ans++
			}
			fmt.Println(ans)
		}
	}
}

package main

import (

	"bufio"
	"os"
	"fmt"
)

var (

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

func abs(x int) int {

	if x < 0 {

		return -x
	}
	return x
}

func main() {

	defer out.Flush()
	var T int
	fmt.Fscan(in, &T)

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

		var n int
		fmt.Fscan(in, &n)
		if n % 3 == 1 {

			if n == 1 {

				fmt.Fprintln(out, 2)
			} else {

				fmt.Fprintln(out, abs((n - 4) / 3) + 2)
			}
		} else if n % 3 == 2 {

			fmt.Fprintln(out, abs((n - 2) / 3) + 1)
		} else {

			fmt.Fprintln(out, abs(n / 3))
		}
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t, n, u, v int
	fmt.Fscan(in, &t)
	for t != 0 {
		fmt.Fscan(in, &n)
		u, v = n/3, n%3
		if v == 0 {
			fmt.Fprintln(out, u)
		} else if v == 1 && n == 1 {
			fmt.Fprintln(out, 2)
		} else {
			fmt.Fprintln(out, u+1)
		}
		t--
	}
}

package main

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

var rr = bufio.NewReader(os.Stdin)
var ww = bufio.NewWriter(os.Stdout)

func slove() {
	var n int
	fmt.Fscan(rr, &n)
	c := 0
	if n == 1 {
		fmt.Fprintln(ww, 2)
		return
	}
	if n % 3 == 1 {
		c = 1
	} else if n % 3 == 2 {
		c = 1
	}
	fmt.Fprintln(ww, c + n/3)
}

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

package main

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

func readLine() string {
	s, err := in.ReadString('\n')
	if err != nil {
		panic(err)
	}
	s = strings.ReplaceAll(s, "\n", "")
	s = strings.ReplaceAll(s, "\r", "")
	return s
}

func readLines(n int) []string {
	res := make([]string, n)
	for i := 0; i < n; i++ {
		res[i] = readLine()
	}
	return res
}

func readInt() int {
	n, err := strconv.ParseInt(readLine(), 10, 32)
	if err != nil {
		panic(err)
	}
	return int(n)
}

func readInt2() (int, int) {
	as := readInts(2)
	return as[0], as[1]
}

func readInt3() (int, int, int) {
	as := readInts(3)
	return as[0], as[1], as[2]
}

func readUint() uint64 {
	n, err := strconv.ParseUint(readLine(), 10, 64)
	if err != nil {
		panic(err)
	}
	return n
}

func readInts(n int) []int {
	s := readLine()
	as := strings.SplitN(s, " ", n)
	if len(as) != n {
		panic("invalid len")
	}
	arr := make([]int, n)
	for k, a := range as {
		x, _ := strconv.ParseInt(a, 10, 64)
		arr[k] = int(x)
	}
	return arr
}

func readStrings(n int) []string {
	s := readLine()
	as := strings.SplitN(s, " ", n)
	if len(as) != n {
		panic("invalid len")
	}
	return as
}

var in = bufio.NewReader(os.Stdin)

func main() {
	t := readInt()

	for i := 0; i < t; i++ {
		n := readInt()
		if n%3 == 0 {
			fmt.Println(n / 3)
		} else if n%3 == 2 {
			fmt.Println(n/3 + 1)
		} else if n%3 == 1 && n > 3 {
			fmt.Println((n-4)/3 + 2)
		} else {
			fmt.Println(2)
		}
	}
}

package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	var temp []int

	for scanner.Scan() {
		d, _ := strconv.Atoi(scanner.Text())
		temp = append(temp, d)
	}
	for i := 1; i < len(temp); i++ {
		if temp[i]%3 == 0 {
			fmt.Println(temp[i] / 3)
		} else if temp[i] == 1 {
			fmt.Println(1)
		} else {
			fmt.Println(temp[i]/3 + 1)
		}
	}
}

package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	var temp []int

	for scanner.Scan() {
		d, _ := strconv.Atoi(scanner.Text())
		temp = append(temp, d)
	}
	for i := 1; i < len(temp); i++ {
		if temp[i]%3 == 0 {
			fmt.Println(temp[i] / 3)
		} else {
			fmt.Println(temp[i]/3 + 1)
		}
	}
}

func getTotal(a, odd, even, n, mod int) int {
	sum := 1
	for i := 0; i < a; i++ {
		sum = (sum * (n - i) / (i + 1)) % mod
	}
	for i := 0; i < a; i++ {
		sum = (sum * odd) % mod
	}
	for i := 0; i < n-a; i++ {
		sum = (sum * even) % mod
	}
	return sum
}

package main

import (
	"fmt"
)

func main() {
	var line int
	fmt.Scanf("%d\n", &line)
	for i := 0; i < line; i++ {
		var num int
		fmt.Scanf("%d\n", &num)
		switch num % 6 {
		case 0, 3:
			fmt.Println(num / 3)
		case 1:
			fmt.Println(num/3 + 2)
		case 2, 4, 5:
			fmt.Println(num/3 + 1)
		}
	}
}

package main

import (
	"fmt"
)

func main() {
	var line int
	fmt.Scanf("%d\n", &line)
	for i := 0; i < line; i++ {
		var num int
		fmt.Scanf("%d\n", &num)
		if num == 4 {
			fmt.Println(2)
			continue
		}
		switch num % 3 {
		case 0:
			fmt.Println(num / 3)
		case 1:
			fmt.Println(num/3 + 2)
		case 2:
			fmt.Println(num/3 + 1)
		}
	}
}

package main

import "fmt"

func main() {
	var line int
	fmt.Scanf("%d\n", line)
	for i := 0; i < line; i++ {
		var num int
		fmt.Scanf("%d\n", num)
		switch num % 3 {
		case 0:
			fmt.Println(num / 3)
		case 1, 2:
			fmt.Println(num/3 + 1)
		}
	}
}

package main

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

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

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

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

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

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

/**
Run solve the problem CF1716A
Date: 5/08/22
User: pepradere
URL: https://codeforces.com/problemset/problem/1716/A
Problem: CF1716A
**/
func (in *CF1716A) Run() {
	for t := in.NextInt(); t > 0; t-- {
		n := in.NextInt64()
		ans := int64(math.Ceil(float64(n) / 3.))
		if n == 1 {
			fmt.Println(2)
		} else if n%3 == 0 {
			fmt.Println(ans)
		} else if n%2 == 0 {
			fmt.Println(ans)
		} else {
			fmt.Println(ans + 1)
		}

	}
}

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

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

package main

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

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

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

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

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

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

/**
Run solve the problem CF1716A
Date: 5/08/22
User: pepradere
URL: https://codeforces.com/problemset/problem/1716/A
Problem: CF1716A
**/
func (in *CF1716A) Run() {
	for t := in.NextInt(); t > 0; t-- {
		n := in.NextInt64()
		ans := int64(math.Ceil(float64(n) / 3.))
		if n == 1 {
			fmt.Println(2)
		} else if n%3 == 0 {
			fmt.Println(ans)
		} else if n%2 == 0 {
			fmt.Println(ans)
		} else {
			fmt.Println(ans + 2)
		}

	}
}

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

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

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	for i:=0; i < n; i++ {
		var val int
		fmt.Scan(&val)
		if val == 4 {
			fmt.Println(2)
			continue
		}
		res := val / 3
		if val % 3 == 2 {
			res += 1
		}
		fmt.Println(res)
	}
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	for i:=0; i < n; i++ {
		var val int
		fmt.Scan(&val)
		if val == 4 {
			fmt.Println(2)
			continue
		}
		res := val / 3
		if val % 3 != 0 {
			res += 1
		}
		fmt.Println(res)
	}
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	for i:=0; i < n; i++ {
		var val int
		fmt.Scan(&val)
		if val == 4 {
			fmt.Println(2)
			continue
		}
		res := val / 3
		if val % 3 == 1 {
			res += 2
		} else if val % 3 == 2 {
			res += 1
		}
		fmt.Println(res)
	}
}

package main
import(
    "fmt"
)
func main() {
	var t int
	fmt.Scan(&t)
	for i:=0;i<t;i++{
		var x int
		fmt.Scan(&x)
		if abs(x) == 2 {
			fmt.Println(1)
		} else if abs(x) == 4 || abs(x) == 1 {
			fmt.Println(2)
		} else if x%3 == 2 {
			fmt.Println(x/3+1)
		} else if x%3 == 1 {
			fmt.Println(x/3+2)
		} else if x%3 == 0 {
			fmt.Println(x/3)
		} else {
			fmt.Println(0)
		}
	}
}
func abs(x int) int {
	var result int
	if x > 0 {
		result = x
	} else {
		if x < 0 {
			result = x*-1
		}
	}
	return result
}

package main
import(
    "fmt"
)
func main() {
	var t int
	fmt.Scan(&t)
	for i:=0;i<t;i++{
		var x int
		fmt.Scan(&x)
		if abs(x) == 2 {
			fmt.Println(1)
		} else if abs(x) == 4 || abs(x) == 1 {
			fmt.Println(2)
		} else if x%3 == 2 {
			fmt.Println(x/3+2)
		} else if x%3 == 1 {
			fmt.Println(x/3+1)
		} else if x%3 == 0 {
			fmt.Println(x/3)
		} else {
			fmt.Println(0)
		}
	}
}
func abs(x int) int {
	var result int
	if x > 0 {
		result = x
	} else {
		if x < 0 {
			result = x*-1
		}
	}
	return result
}

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

func main() {
	in := bufio.NewReader(os.Stdin)
	tString, _ := in.ReadString('\n')
	t, _ := strconv.Atoi(tString)
	for i := 0; i < t; i++ {
		nString, _ := in.ReadString('\n')
		n, _ := strconv.Atoi(nString)
		if n < 0 {
			n = -n
		}
		ans := 0
		switch n {
		case 1:
			ans = 2
		case 3, 2:
			ans = 1
		default:
			if n%3 == 0 {
				ans = n / 3
			} else {
				ans = n/3 + 1
			}
		}
		fmt.Println(ans)
	}
}

/*
You are standing at the point 0 on a coordinate line. Your goal is to reach the point n. In one minute, you can move by 2 or by 3 to the left or to the right (i. e., if your current coordinate is x, it can become x−3, x−2, x+2 or x+3

). Note that the new coordinate can become negative.

Your task is to find the minimum number of minutes required to get from the point 0
to the point n

.

You have to answer t

independent test cases.
Input

The first line of the input contains one integer t
(1≤t≤104) — the number of test cases. Then t

lines describing the test cases follow.

The i
-th of these lines contains one integer n (1≤n≤109) — the goal of the i

-th test case.
Output

For each test case, print one integer — the minimum number of minutes required to get from the point 0
to the point n for the corresponding test case.
*/

package main

import "fmt"

func minMoves(n int) int {
	if n == 1 {
		return 2
	}
	if n%3 == 0 {
		return n / 3
	} else if n%2 == 0 {
		return n / 3
	} else {
		return n/3 + 1
	}
}

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

/*
You are standing at the point 0 on a coordinate line. Your goal is to reach the point n. In one minute, you can move by 2 or by 3 to the left or to the right (i. e., if your current coordinate is x, it can become x−3, x−2, x+2 or x+3

). Note that the new coordinate can become negative.

Your task is to find the minimum number of minutes required to get from the point 0
to the point n

.

You have to answer t

independent test cases.
Input

The first line of the input contains one integer t
(1≤t≤104) — the number of test cases. Then t

lines describing the test cases follow.

The i
-th of these lines contains one integer n (1≤n≤109) — the goal of the i

-th test case.
Output

For each test case, print one integer — the minimum number of minutes required to get from the point 0
to the point n for the corresponding test case.
*/

package main

import "fmt"

func minMoves(n int) int {
	if n%3 == 0 {
		return n / 3
	} else if n%2 == 0 {
		return n/3 + 1
	} else {
		return n/3 + 2
	}
}

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

package main

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

var _, _, _ = main, rw, do

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

func rw(r io.Reader, w io.Writer) {
	var t int
	fmt.Fscan(r, &t)
	for ti := 0; ti < t; ti++ {
		var n int
		fmt.Fscan(r, &n)
		w1 := do(n)
		fmt.Fprintln(w, w1)
	}
}

func do(n int) int {
	if n < 0 {
		n = -n
	}
	if n == 0 {
		return 0
	}
	if n == 4 {
		return 2
	}
	x := n / 3
	y := n % 3
	if y == 0 {
		return x
	}
	if y == 2 {
		return x + 1
	}
	return x + 2
}

package main

import (
	"fmt"
)

func main() {
	var t, n int
	fmt.Scanf("%d", &t)
	for i := 0; i < t; i++ {
		fmt.Scanf("%d", &n)
		res := task23(n)
		fmt.Println(res)
	}
}

func task23(n int) int {
	switch n {
	case 1:
		return 2
	case 2, 3:
		return 1
	}

	rest := n % 3
	switch rest {
	case 0:
		return n / 3
	case 1, 2:
		return n / 3 + 1
	}

	return -1
}

package main

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

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

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var ntests int
	fmt.Fscan(in, &ntests)
	for iii := 0; iii < ntests; iii++ {
		var el int
		fmt.Fscan(in, &el)
		switch el % 3 {
		case 0:
			fmt.Fprintln(out, el/3)
		case 1:
			if el == 1 {
				fmt.Fprintln(out, 2)
			} else {
				fmt.Fprintln(out, el/3+1)
			}
		case 2:
			fmt.Println(el/3 + 1)
		}
	}
}