You are given two positive integers $$$n$$$ ($$$1 \le n \le 10^9$$$) and $$$k$$$ ($$$1 \le k \le 100$$$). Represent the number $$$n$$$ as the sum of $$$k$$$ positive integers of the same parity (have the same remainder when divided by $$$2$$$).In other words, find $$$a_1, a_2, \ldots, a_k$$$ such that all $$$a_i>0$$$, $$$n = a_1 + a_2 + \ldots + a_k$$$ and either all $$$a_i$$$ are even or all $$$a_i$$$ are odd at the same time.If such a representation does not exist, then report it.

The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the input. Next, $$$t$$$ test cases are given, one per line. Each test case is two positive integers $$$n$$$ ($$$1 \le n \le 10^9$$$) and $$$k$$$ ($$$1 \le k \le 100$$$).

For each test case print:   YES and the required values $$$a_i$$$, if the answer exists (if there are several answers, print any of them);  NO if the answer does not exist.  The letters in the words YES and NO can be printed in any case.

package main

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

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

func Assert(b bool) {
	if !b {
		panic("Assertion error")
	}
}

func main() {
	input := os.Stdin
	// 	input := strings.NewReader(`8
	// 10 3
	// 100 4
	// 8 7
	// 97 2
	// 8 8
	// 3 10
	// 5 3
	// 1000000000 9
	// `)
	scanner := bufio.NewScanner(input)

	getLine := func() string {
		if !scanner.Scan() {
			panic("expected line")
		}
		return scanner.Text()
	}

	parseNumber := func(s string) int {
		t, err := strconv.ParseInt(s, 10, 64)
		CheckError(err)
		return int(t)
	}

	getNumber := func() int {
		return parseNumber(getLine())
	}

	t := getNumber()
	for i := 0; i < t; i++ {
		lst := strings.Split(getLine(), " ")
		n := parseNumber(lst[0])
		k := parseNumber(lst[1])

		//fmt.Println(n, k)
		processPair(n, k)
	}
}

func processPair(n, k int) {
	if k%2 == 0 {
		if n%2 != 0 {
			fmt.Println("NO")
			return
		}

		if n < k {
			fmt.Println("NO")
			return
		}

		lst := []string{strconv.Itoa(n - k + 1)}
		for i := 0; i < k-1; i++ {
			lst = append(lst, "1")
		}
		fmt.Printf("YES\n%s\n", strings.Join(lst, " "))
		return
	}

	// k%2 == 1
	if n%2 == 0 {
		if n < k*2 {
			fmt.Println("NO")
			return
		}

		lst := []string{strconv.Itoa(n - 2*(k-1))}
		for i := 0; i < k-1; i++ {
			lst = append(lst, "2")
		}
		fmt.Printf("YES\n%s\n", strings.Join(lst, " "))
		return
	}

	// n%2 == 1
	if n < k {
		fmt.Println("NO")
		return
	}

	lst := []string{strconv.Itoa(n - k + 1)}
	for i := 0; i < k-1; i++ {
		lst = append(lst, "1")
	}
	fmt.Printf("YES\n%s\n", strings.Join(lst, " "))
	return
}

package main

import "fmt"

func main() {
	var t int
	fmt.Scanf("%d\n", &t)
	for i := 0; i < t; i++ {
		var n, k int
		fmt.Scanf("%d %d\n", &n, &k)
		if n%2 == 1 {
			val := n
			val -= (k - 1)
			if val <= 0 || val%2 != 1 {
				fmt.Println("NO")
			} else {
				fmt.Println("YES")
				for j := 0; j < (k - 1); j++ {
					fmt.Printf("1 ")
				}
				fmt.Println(val)
			}
		} else {
			if k%2 == 1 {
				n -= (k - 1) * 2
				if n <= 0 || n%2 != 0 {
					fmt.Println("NO")
				} else {
					fmt.Println("YES")
					for j := 0; j < (k - 1); j++ {
						fmt.Printf("2 ")
					}
					fmt.Println(n)
				}
			} else {
				n -= (k - 1)
				if n <= 0 || n%2 != 1 {
					fmt.Println("NO")
				} else {
					fmt.Println("YES")
					for j := 0; j < (k - 1); j++ {
						fmt.Printf("1 ")
					}
					fmt.Println(n)
				}
			}
		}
	}
}

package main

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

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

	scanner.Scan()
	cases, _ := strconv.Atoi(scanner.Text())
	for t := 0; t < cases; t++ {
		scanner.Scan()
		data := strings.Split(scanner.Text(), " ")
		n, _ := strconv.Atoi(data[0])
		k, _ := strconv.Atoi(data[1])
		res := n / k

		res = res - 2

		ans := false
		ws := ""
		for i := res; i <= res+2; i++ {
			if i*(k-1) < n && i > 0 {
				f := n - (i * (k - 1))
				if f%2 == i%2 {
					for j := 0; j < k-1; j++ {
						if j == 0 {
							ws = fmt.Sprint(ws, i)
						} else {
							ws = fmt.Sprint(ws, " ", i)
						}
					}
					if f > 0 {
						ws = fmt.Sprint(ws, " ", f)
					}
					ans = true
					break
				}
			}
		}

		if !ans {
			fmt.Println("NO")
		} else {
			fmt.Println("YES")
			fmt.Println(ws)
		}

	}
}

package main

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

func main() {
	s := NewScanner()
	t := s.NextInt()

	for i := 0; i < t; i++ {
		n, k := s.NextInt(), s.NextInt()

		if k > n {
			fmt.Println("NO")
			continue
		}

		if n%2 == k%2 {
			fmt.Println("YES")
			for i := 0; i < k-1; i++ {
				fmt.Printf("%d ", 1)
			}
			fmt.Println(n - k + 1)
		} else {
			if (n-(k-1)*2)%2 == 0 && 2*(k-1) < n {
				fmt.Println("YES")
				for i := 0; i < k-1; i++ {
					fmt.Printf("%d ", 2)
				}
				fmt.Println(n - 2*k + 2)
			} else {
				fmt.Println("NO")
			}
		}
	}
}

type scanner struct {
	*bufio.Scanner
}

func NewScanner() *scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	return &scanner{s}
}

func (s *scanner) NextInt() int {
	s.Scan()
	i, _ := strconv.Atoi(s.Text())
	return i
}

func (s *scanner) NextInt64() int64 {
	s.Scan()
	i, _ := strconv.ParseInt(s.Text(), 10, 64)
	return i
}

func (s *scanner) NextString() string {
	s.Scan()
	return s.Text()
}

// https://codeforces.com/contest/1352/problem/0
package main

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

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)
var input io.Reader

func main() {
	var (
		T int
	)

	//f, _ := os.Open("input.txt")
	//input := bufio.NewReader(f)
	input = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &T)
	for i := 0; i < T; i++ {
		solver()
	}
}

func solver() {
	var n, k int
	fmt.Fscan(input, &n, &k)

	if checkEven(n, k) {
		fmt.Println("Yes")
		for i := 0; i < k - 1; i++ {
			fmt.Print(2, " ")
		}
		fmt.Println(n - 2*(k - 1))
		return
	}

	if checkOdd(n, k) {
		fmt.Println("Yes")
		for i := 0; i < k - 1; i++ {
			fmt.Print(1, " ")
		}
		fmt.Println(n - (k - 1))
		return
	}

	fmt.Println("No")
}

func checkEven(n, k int) bool {
	return n % 2 == 0 && n / 2 >= k
}

func checkOdd(n, k int) bool {
	return (n - (k - 1)) % 2 == 1
}

package main

import (
	"fmt"
)

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

	for i := 0; i < t; i++ {
		var n, k int
		fmt.Scan(&n, &k)
		// represent n as the sum of k positive integers
		// of the same parity

		// n even =>
		//   k odd => even parity
		//   k even => even or odd parity
		// n odd =>
		//   k odd => odd parity
		//   k even => not possible
		if n % 2 == 1 && k % 2 == 0 {
			fmt.Println("NO")
			continue
		}

		var min int
		if n % 2 == k % 2 {
			// same parity => construct with odd
			min = 1
		} else {
			min = 2
		}

		if k * min > n {
			// can't construct even using the minimum element
			fmt.Println("NO")
			continue
		}

		fmt.Println("YES")
		for j := 1; j < k; j++ {
			fmt.Printf("%d ", min)
		}
		fmt.Println(n - (k - 1) * min)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"

)
func max(a,b int) int{
	if(a>b){
		return a
	}
	return b;
}
func main(){
	reader := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	var T int;
	fmt.Fscanln(reader, &T)
	for t:=0;t<T;t++ {
		var n,k int;
		fmt.Fscanln(reader,&n,&k)
		if(n%2==1&&k%2==0){
			fmt.Fprintln(writer,"NO");
			continue
		}
		if(n%2==0 &&k%2==1){
			if(n<2*k){
			fmt.Fprintln(writer,"NO");
			continue
			}
			fmt.Fprintln(writer,"YES");

			for i:=1;i<k;i++{
				fmt.Fprint(writer,"2 ")
			}
			fmt.Fprintln(writer,n-2*(k-1))
		}else{
			if(n<k){
				fmt.Fprintln(writer,"NO");
				continue
			}
			fmt.Fprintln(writer,"YES");
			for i:=1;i<k;i++{
				fmt.Fprint(writer,"1 ")
			}
			fmt.Fprintln(writer,n-k+1)
		}
	}
}

package main

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

func main()  {

	scanner := bufio.NewScanner(os.Stdin)

	scanner.Scan()

	t := scanner.Text()

	testCases, err := strconv.Atoi(t)

	if err != nil {
		panic(err)
	}

	for j := 0; j < int(testCases); j ++ {

		scanner.Scan()

		nk := scanner.Text()

		parts := strings.Fields(nk)

		nn := parts[0]
		kk := parts[1]

		n, _  := strconv.Atoi(nn)

		k, _  := strconv.Atoi(kk)

		res := solve1(n, k)

		if res == nil {
			fmt.Println("NO")
		} else {
			fmt.Println("YES")

			var buff bytes.Buffer

			for i:=0 ; i < len(res); i ++ {
				s := strconv.Itoa(res[i])
				buff.WriteString(s)
				buff.WriteString(" ")
			}

			fmt.Println(buff.String())
		}
	}
}

func solve1(n, k int) []int  {

	if n % 2 == 1 && k % 2 == 0 {
		return nil

	} else if n % 2 == 1 && k % 2 == 1 {

		var ans []int
		sum := 0
		start := 1

		for i := 0 ; i < k - 1 ; i ++ {
			sum += start

			ans = append(ans, start)

			if sum > n {
				return nil
			}
		}

		if sum == n {
			return nil
		}

		return append(ans, n - sum)

	} else if n % 2 == 0 && k % 2 == 1 {

		sum := 0
		start := 2
		var ans []int

		for i := 0 ; i < k - 1 ; i ++ {
			sum += start

			ans = append(ans, start)

			if sum > n {
				return nil
			}
		}

		if sum == n {
			return nil
		}

		return append(ans, n - sum)

	} else {
		res := true

		sum := 0
		start := 2
		var ans []int

		for i := 0 ; i < k - 1 ; i ++ {
			sum += start

			ans = append(ans, start)

			if sum > n {
				res = false
				break
			}
		}

		if res {

			if sum != n {
				return append(ans, n - sum)
			}
		}

		var a []int

		sum = 0
		start = 1

		for i := 0 ; i < k - 1 ; i ++ {
			sum += start

			a = append(a, start)

			if sum > n {
				return nil
			}
		}

		if sum == n {
			return nil
		}

		return append(a, n - sum)
	}

	return nil
}

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

package main

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

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

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

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

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

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

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

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

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

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

var (
	t    int
	n, k int
)

func main() {
	t = ReadInt()
	for i := 0; i < t; i++ {
		n, k = ReadInt2()
		solve(n, k)
	}
}

func solve(n, k int) {
	if n%2 == 1 && k%2 == 0 {
		fmt.Println("NO")
		return
	}

	answers := []int{}
	if n%2 == 1 || (n%2 == 0 && k%2 == 0) {
		tmp := n - (k - 1)
		if tmp > 0 {
			for i := 0; i < k-1; i++ {
				answers = append(answers, 1)
			}
			answers = append(answers, tmp)
			fmt.Println("YES")
			fmt.Println(PrintIntsLine(answers...))
		} else {
			fmt.Println("NO")
		}
	} else {
		tmp := n - 2*(k-1)
		if tmp > 0 {
			for i := 0; i < k-1; i++ {
				answers = append(answers, 2)
			}
			answers = append(answers, tmp)
			fmt.Println("YES")
			fmt.Println(PrintIntsLine(answers...))
		} else {
			fmt.Println("NO")
		}
	}
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	return res
}

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

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

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

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

	return string(res)
}

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

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

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

	return string(res)
}

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

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

package main

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

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

func run(in io.Reader, out io.Writer) {
	s := bufio.NewScanner(in)
	s.Scan()

	t, _ := strconv.ParseInt(s.Text(), 10, 64)

	for i := 0; i < int(t); i++ {
		if !s.Scan() {
			break
		}

		var n, k int
		_, err := fmt.Sscanf(s.Text(), "%d %d", &n, &k)
		if err != nil {
			log.Fatal(err)
		}
		fmt.Fprintln(out, process(n, k))
	}
}

func process(n, k int) R {
	switch {
	case k > n:
		return R{text: "NO"}
	case k == n:
		return R{text: "YES", r: dup(1, k)}
	}

	// case k < n:
	switch {
	case !IsEven(n) && IsEven(k):
		return R{text: "NO"}
	case IsEven(n) && IsEven(k), !IsEven(n) && !IsEven(k):
		return R{text: "YES", r: append(dup(1, k-1), n-(k-1))}
	}

	// case IsEven(n) && !IsEven(k)
	if k*2 > n {
		return R{text: "NO"}
	}

	return R{text: "YES", r: append(dup(2, k-1), n-(k-1)*2)}
}

func IsEven(x int) bool {
	return x%2 == 0
}

func dup(n, k int) []int {
	r := make([]int, 0, k)
	for i := 0; i < k; i++ {
		r = append(r, n)
	}
	return r
}

type R struct {
	text string
	r    []int
}

func (o R) String() string {
	var buf bytes.Buffer

	fmt.Fprintf(&buf, "%s\n", o.text)
	for _, n := range o.r {
		fmt.Fprintf(&buf, "%d ", n)
	}

	b := buf.Bytes()
	return string(b[:len(b)-1])
}

package main

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

func solve() {
	t := readInt()
	for i := 0; i < t; i++ {
		n := readInt()
		k := readInt()
		nOrig := n
		kOrig := k
		if n%2 == 0 {
			res := make([]string, 0)
			for i := 1; i < k; i++ {
				res = append(res, "2")
				n -= 2
			}
			if n > 0 {
				res = append(res, strconv.Itoa(n))
				fmt.Println("YES")
				fmt.Println(strings.Join(res, " "))
			} else {
				solveCase2(kOrig, nOrig)
			}
		} else {
			if k % 2 == 0 {
				fmt.Println("NO")
			} else {
				solveCase2(k, n)
			}
		}
	}
}

func solveCase2(k int, n int) {
	res := make([]string, 0)
	for i := 1; i < k; i++ {
		res = append(res, "1")
		n -= 1
	}
	if n > 0 && n%2 != 0 {
		res = append(res, strconv.Itoa(n))
		fmt.Println("YES")
		fmt.Println(strings.Join(res, " "))
	} else {
		fmt.Println("NO")
	}
}

var scanner *bufio.Scanner

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

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

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

// IO

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

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

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

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

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

package main

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

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

	var t, n, k int
	for Fscan(in, &t); t > 0; t-- {
		Fscan(in, &n, &k)
		if k > n {
			Fprintln(out, "NO")
			continue
		}
		ans := []interface{}{}
		left := n - k
		if left&1 == 0 {
			ans = append(ans, left+1)
			for k--; k > 0; k-- {
				ans = append(ans, 1)
			}
		} else {
			if 2*k>n {
				Fprintln(out, "NO")
				continue
			}
			left = n - 2*k
			if left&1 == 0 {
				ans = append(ans, left+2)
				for k--; k > 0; k-- {
					ans = append(ans, 2)
				}
			} else {
				Fprintln(out, "NO")
				continue
			}
		}
		Fprintln(out, "YES")
		Fprintln(out, ans...)
	}
}

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

package main

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

var DEBUG = true

func main() {
	defer Flush()
	T := readi()
	for t := 0; t < T; t++ {
		n := readi()
		k := readi()
		a, ok := solve(n, k)
		if !ok {
			println("NO")
			continue
		}
		println("YES")
		sp := ""
		for _, v := range a {
			printf("%s%d", sp, v)
			sp = " "
		}
		println()
	}

}

func solve(n, k int) ([]int, bool) {
	for _, d := range []int{1, 2} {
		var a []int
		m := n
		for len(a) < k-1 && 0 < m {
			a = append(a, d)
			m -= d
		}
		if m <= 0 {
			continue
		}
		if m%2 != d%2 {
			continue
		}
		a = append(a, m)
		return a, true
	}
	return nil, false
}

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

// IO helper functions

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// IO functions

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

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

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

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

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

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

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

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

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

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

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

func dbgf(f string, args ...interface{}) {
	if !DEBUG {
		return
	}
	fmt.Fprintf(os.Stderr, f, args...)
}

func dbg(args ...interface{}) {
	if !DEBUG {
		return
	}
	fmt.Fprintln(os.Stderr, args...)
}

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

// Utilities

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

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

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

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

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

// Simple math functions

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

package main

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

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

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

func solve() {
	var n, k int
	scanf("%d %d\n", &n, &k)

	if n < k {
		printf("NO\n")
	} else {
		if n & 1 == 0 {
			if n >= 2*k {
				printf("YES\n")
				for i := 1; i < k; i++ {
					printf("2 ")
					n -= 2
				}
				printf("%d\n", n)
			} else {
				if k & 1 == 1 {
					printf("NO\n")
				} else {
					printf("YES\n")
					for i := 1; i < k; i++ {
						printf("1 ")
						n--
					}
					printf("%d\n", n)
				}
			}
		} else {
			if k & 1 == 1 {
				printf("YES\n")
				for i := 1; i < k; i++ {
					printf("1 ")
					n--
				}
				printf("%d\n", n)
			} else {
				printf("NO\n")
			}
		}
	}
}

func main() {
	var t int
	scanf("%d\n", &t)
	for t > 0 {
		t--
		solve()
	}
	writer.Flush()
}

package main

import (
	"fmt"
)

func even(n int) bool {
	if n%2 == 0 {
		return true
	}
	return false
}

func odd(n int) bool {
	if n%2 == 1 {
		return true
	}
	return false
}

func printNumbers(n, k, x int) {
	fmt.Println("YES")
	for i := 0; i < k-1; i++ {
		fmt.Print(x, " ")
	}
	fmt.Println(n - x*(k-1))
}

func main() {
	var t int
	fmt.Scanln(&t)
	for ; t > 0; t-- {
		var n int
		var k int
		fmt.Scanln(&n, &k)
		if odd(n) && even(k) {
			fmt.Println("NO")
		} else if even(n) && odd(k) {
			if n < 2*k {
				fmt.Println("NO")
			} else {
				printNumbers(n, k, 2)
			}
		} else {
			if n < k {
				fmt.Println("NO")
			} else {
				printNumbers(n, k, 1)
			}
		}
	}
}

package main

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

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 {
	NextInt64() int64
	NextUInt64() uint64
	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) 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) NextUInt64() uint64 {
	impl.Scan()
	bb := impl.Bytes()
	i := uint64(0)
	for _, b := range bb {
		i *= 10
		i += uint64(b - '0')
	}
	return i
}

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

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

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

func min(a int64, rest ...int64) int64 {
	for _, r := range rest {
		if r < a {
			a = r
		}
	}
	return a
}

func max(a int64, rest ...int64) int64 {
	for _, r := range rest {
		if r > a {
			a = r
		}
	}
	return a
}

const (
	INF = math.MaxInt64
	MOD = 1e9 + 7
)

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

func main() {
	defer writer.Flush()
	t := reader.NextInt64()
	for ; t > 0; t-- {
		res := sol(reader.NextInt64(), reader.NextInt64())
		if res == nil {
			writer.Printf("NO\n")
			continue
		}
		writer.Printf("YES\n")
		for _, r := range res {
			writer.Printf("%d ", r)
		}
		writer.Printf("\n")
	}
}

// 10 3
// 2 2 6
//
// 3 3
// 1 1 1
func sol(n, k int64) []int64 {
	// try all ones except last
	allSum := k-1
	remain := n - allSum
	if remain > 0 && remain & 1 == 1 {
		ret := []int64{}
		for i := int64(0); i < k-1; i++ {
			ret = append(ret, 1)
		}
		ret = append(ret, remain)
		return ret
	}

	// try all twos except last
	allSum = (k-1)*2
	remain = n - allSum
	if remain > 0 && remain & 1 == 0 {
		ret := []int64{}
		for i := int64(0); i < k-1; i++ {
			ret = append(ret, 2)
		}
		ret = append(ret, remain)
		return ret
	}

	return nil
}

package main

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

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

	scanner.Scan()
	cases,_ := strconv.Atoi(scanner.Text())
	fmt.Println("cases " , cases)
	for t := 0;t < cases;t++ {
		scanner.Scan()
		data := strings.Split(scanner.Text(), " ")
		n,_ := strconv.Atoi(data[0])
		k,_ := strconv.Atoi(data[1])
		res := n / k
		if res - 2 > 0 {
			res = res - 2
		}
		ans := false
		ws := ""
		for i := res ; i <= res + 2; i++ {
			if i * (k - 1) < n {
				f := n - ( i * (k - 1))
				if f % 2 == i % 2 {
					for j := 0 ; j < k -1 ; j++ {
						if j == 0 {
							ws = fmt.Sprint(ws, i)
						} else {
							ws = fmt.Sprint(ws, " ", i)
						}
					}
					if f > 0 {
						ws = fmt.Sprint( ws, " " , f)
					}
					ans = true
					break
				}
			}
		}

		if !ans {
			fmt.Println("NO")
		} else {
			fmt.Println("YES")
			fmt.Println(ws)
		}

	}
}

package main

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

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

	scanner.Scan()
	cases,_ := strconv.Atoi(scanner.Text())
	for t := 0;t < cases;t++ {
		scanner.Scan()
		data := strings.Split(scanner.Text(), " ")
		n,_ := strconv.Atoi(data[0])
		k,_ := strconv.Atoi(data[1])
		res := n / k
		if res - 2 > 0 {
			res = res - 2
		}
		ans := false
		ws := ""
		for i := res ; i <= res + 2; i++ {
			if i * (k - 1) < n {
				f := n - ( i * (k - 1))
				if f % 2 == i % 2 {
					for j := 0 ; j < k -1 ; j++ {
						if j == 0 {
							ws = fmt.Sprint(ws, i)
						} else {
							ws = fmt.Sprint(ws, " ", i)
						}
					}
					if f > 0 {
						ws = fmt.Sprint( ws, " " , f)
					}
					ans = true
					break
				}
			}
		}

		if !ans {
			fmt.Println("NO")
		} else {
			fmt.Println("YES")
			fmt.Println(ws)
		}

	}
}

// https://codeforces.com/contest/1352/problem/0
package main

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

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)
var input io.Reader

func main() {
	var (
		T int
	)

	//f, _ := os.Open("input.txt")
	//input := bufio.NewReader(f)
	input = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &T)
	for i := 0; i < T; i++ {
		solver()
	}
}

func solver() {
	var n, k int
	fmt.Fscan(input, &n, &k)

	if checkEven(n, k) {
		fmt.Println("Yes")
		for i := 0; i < k - 1; i++ {
			if i > 0 {
				fmt.Print(" ")
			}
			fmt.Print(2)
		}
		fmt.Println(n - 2*(k - 1))
		return
	}

	if checkOdd(n, k) {
		fmt.Println("Yes")
		for i := 0; i < k - 1; i++ {
			if i > 0 {
				fmt.Print(" ")
			}
			fmt.Print(1)
		}
		fmt.Println(n - (k - 1))
		return
	}

	fmt.Println("No")
}

func checkEven(n, k int) bool {
	return n % 2 == 0 && n / 2 >= k
}

func checkOdd(n, k int) bool {
	return (n - (k - 1)) % 2 == 1
}

package main

import (
	"bufio"
	"fmt"
	"os"

)
func max(a,b int) int{
	if(a>b){
		return a
	}
	return b;
}
func main(){
	reader := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	var T int;
	fmt.Fscanln(reader, &T)
	for t:=0;t<T;t++ {
		var n,k int;
		fmt.Fscanln(reader,&n,&k)
		if(n==k){
			fmt.Fprintln(writer,"YES")
			for i:=0;i<k;i++{
				fmt.Fprint(writer,"1 ")
			}
		}else if(k>n|| (n%2==1 &&k%2==0)){
			fmt.Fprintln(writer,"NO")
			continue
		}else if(n%2==0 && k%2==0 || n%2==0 && k%2==1){
			if(n>=2*k){
			 fmt.Fprintln(writer,"YES")
			 for i:=1;i<k;i++{
			 	fmt.Fprint(writer,"2 ")
			 }
			 	fmt.Fprint(writer,n-(k-1)*2)
			}else{
			 fmt.Fprintln(writer,"NO")
			 continue
			}
		}else if (n%2==1 && k%2==1){
				if (n>k){
			 		fmt.Fprintln(writer,"YES")
					for i:=1;i<k;i++{
						fmt.Fprint(writer,"1 ")
					}
					fmt.Fprint(writer,n-k+1)
				}else{
					fmt.Fprintln(writer,"NO")
				}
		}
		fmt.Fprintln(writer,"")
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"

)
func max(a,b int) int{
	if(a>b){
		return a
	}
	return b;
}
func main(){
	reader := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	var T int;
	fmt.Fscanln(reader, &T)
	for t:=0;t<T;t++ {
		var n,k int;
		fmt.Fscanln(reader,&n,&k)
		if(n%2==1&&k%2==0){
			fmt.Fprintln(writer,"NO");
			continue
		}
		if(n%2==0 &&k%2==1){
			if(n<2*k){
			fmt.Fprintln(writer,"NO");
			continue
			}
			for i:=1;i<k;i++{
				fmt.Fprint(writer,"2 ")
			}
			fmt.Fprintln(writer,n-2*(k-1))
		}else{
			if(n<k){
				fmt.Fprintln(writer,"NO");
				continue
			}
			for i:=1;i<k;i++{
				fmt.Fprint(writer,"1 ")
			}
			fmt.Fprintln(writer,n-k+1)
		}
	}
}

package main

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

func main()  {

	scanner := bufio.NewScanner(os.Stdin)

	scanner.Scan()

	t := scanner.Text()

	testCases, err := strconv.Atoi(t)

	if err != nil {
		panic(err)
	}

	for j := 0; j < int(testCases); j ++ {

		scanner.Scan()

		nk := scanner.Text()

		parts := strings.Fields(nk)

		nn := parts[0]
		kk := parts[1]

		n, _  := strconv.Atoi(nn)

		k, _  := strconv.Atoi(kk)

		res := solve1(n, k)

		if res == nil {
			fmt.Println("NO")
		} else {
			fmt.Println("YES")

			var buff bytes.Buffer

			for i:=0 ; i < len(res); i ++ {
				s := strconv.Itoa(res[i])
				buff.WriteString(s)
				buff.WriteString(" ")
			}

			fmt.Println(buff.String())
		}
	}
}

func solve1(n, k int) []int  {

	if n % 2 == 1 && k % 2 == 0 {
		return nil

	} else if n % 2 == 1 && k % 2 == 1 {

		var ans []int
		sum := 0
		start := 1

		for i := 0 ; i < k - 1 ; i ++ {
			sum += start

			ans = append(ans, start)

			if sum > n {
				return nil
			}
		}

		return append(ans, n - sum)

	} else if n % 2 == 0 && k % 2 == 1 {

		sum := 0
		start := 2
		var ans []int

		for i := 0 ; i < k - 1 ; i ++ {
			sum += start

			ans = append(ans, start)

			if sum > n {
				return nil
			}
		}

		return append(ans, n - sum)

	} else {
		res := true

		sum := 0
		start := 2
		var ans []int

		for i := 0 ; i < k - 1 ; i ++ {
			sum += start

			ans = append(ans, start)

			if sum > n {
				res = false
				break
			}
		}

		if res {
			return append(ans, n - sum)
		}

		var a []int

		sum = 0
		start = 1

		for i := 0 ; i < k - 1 ; i ++ {
			sum += start

			a = append(a, start)

			if sum > n {
				return nil
			}
		}

		return append(a, n - sum)
	}

	return nil
}

package main

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

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

func run(in io.Reader, out io.Writer) {
	s := bufio.NewScanner(in)
	s.Scan()

	t, _ := strconv.ParseInt(s.Text(), 10, 64)

	for i := 0; i < int(t); i++ {
		if !s.Scan() {
			break
		}

		var n, k int
		_, _ = fmt.Scanf("%d %d", &n, &k)
		fmt.Fprintln(out, process(n, k))
	}
}

func process(n, k int) R {
	switch {
	case k > n:
		return R{text: "NO"}
	case k == n:
		return R{text: "YES", r: dup(1, k)}
	}

	// case k < n:
	switch {
	case !IsEven(n) && IsEven(k):
		return R{text: "NO"}
	case IsEven(n) && IsEven(k), !IsEven(n) && !IsEven(k):
		return R{text: "YES", r: append(dup(1, k-1), n-(k-1))}
	}

	// case IsEven(n) && !IsEven(k)
	if k*2 > n {
		return R{text: "NO"}
	}

	return R{text: "YES", r: append(dup(2, k-1), n-(k-1)*2)}
}

func IsEven(x int) bool {
	return x%2 == 0
}

func dup(n, k int) []int {
	r := make([]int, 0, k)
	for i := 0; i < k; i++ {
		r = append(r, n)
	}
	return r
}

type R struct {
	text string
	r    []int
}

func (o *R) String() string {
	var buf bytes.Buffer

	fmt.Fprintf(&buf, "%s\n", o.text)
	for _, n := range o.r {
		fmt.Fprintf(&buf, "%d ", n)
	}

	b := buf.Bytes()
	return string(b[:len(b)-1])
}

package main

import (
	"fmt"
)

func even(n int) bool {
	if n%2 == 0 {
		return true
	}
	return false
}

func odd(n int) bool {
	if n%2 == 1 {
		return true
	}
	return false
}

func printNumbers(n, k, x int) {
	fmt.Println("YES")
	for i := 0; i < k-1; i++ {
		fmt.Print(x, " ")
	}
	fmt.Println(n - x*(k-1))
}

func main() {
	var t int
	fmt.Scan(&t)
	for ; t > 0; t-- {
		var n int
		var k int
		fmt.Scanln(&n, &k)
		if odd(n) && even(k) {
			fmt.Println("NO")
		} else if even(n) && odd(k) {
			if n < 2*k {
				fmt.Println("NO")
			} else {
				printNumbers(n, k, 2)
			}
		} else {
			if n < k {
				fmt.Println("NO")
			} else {
				printNumbers(n, k, 1)
			}
		}
	}
}


Polycarp doesn't like integers that are divisible by $$$3$$$ or end with the digit $$$3$$$ in their decimal representation. Integers that meet both conditions are disliked by Polycarp, too.Polycarp starts to write out the positive (greater than $$$0$$$) integers which he likes: $$$1, 2, 4, 5, 7, 8, 10, 11, 14, 16, \dots$$$. Output the $$$k$$$-th element of this sequence (the elements are numbered from $$$1$$$).

The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. Each test case consists of one line containing one integer $$$k$$$ ($$$1 \le k \le 1000$$$).

For each test case, output in a separate line one integer $$$x$$$ — the $$$k$$$-th element of the sequence that was written out by Polycarp.

package main

import (
	"fmt"
)

func main() {
	var t uint8

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

	input := make([]uint16, 0)
	var k uint16

	for len(input) != int(t) {
		n, _ := fmt.Scanf("%d", &k)
		if n == 1 {
			input = append(input, k)
		}
	}

	for _, in := range input {
		i := uint16(1)
		output := uint16(0)
		maxK := uint16(0)
		if in == 0 {
			continue
		}
		for output < uint16(in) {
			if (i%3 == 0) || (i%10 == 3) {
				i++
				continue
			}

			if (i%3 == 0) && (i%10 == 3) {
				i++
				continue
			}

			if i > maxK {
				maxK = i
			}

			i++
			output++
		}

		fmt.Printf("%d\n", maxK)
	}

}

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		var a int
		fmt.Scan(&a)
		for i := 0; i < 100000; i++ {
			if i%3 != 0 && i%10 != 3 {
				a--
			}
			if a == 0 {
				fmt.Println(i)
				break
			}
		}
	}
}

package main

import "fmt"

var arr = [10005]int{}

func main() {
	t := 0
	now := 1
	for i := 1; i >= 1; i++ {
		if now > 1000 {
			break
		}
		if i%3 == 0 || i%10 == 3 {
			continue
		}
		arr[now] = i
		now++

	}

	fmt.Scanln( &t)
	for {
		if t == 0 {
			break
		}
		t--
		n := 0
		fmt.Scanln( &n)
		fmt.Println(arr[n])
	}
}

package main

import (
	"fmt"
)

func main() {

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

	arr := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d\n", &arr[i])
	}
	n = 0
	for _, value := range arr {
		if n < value {
			n = value
		}
	}
	m := make(map[int]int)

	defer func() {
		for _, value := range arr {
			fmt.Printf("%d\n", m[value])
		}
	}()

	cnt := 0
	for i := 1; cnt < n; i++ {
		if i%3 != 0 && i%10 != 3 {
			cnt++
			m[cnt] = i
		}
	}
}

package main

import (
	"fmt"
)

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

	arr := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d\n", &arr[i])
	}
	n = 0
	for _, value := range arr {
		if n < value {
			n = value
		}
	}
	m := make(map[int]int)
	cnt := 0
	for i := 1; cnt < n; i++ {
		if i%3 != 0 && i%10 != 3 {
			cnt++
			m[cnt] = i
		}
	}
	for _, value := range arr {
		fmt.Printf("%d\n", m[value])
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := os.Stdout
	var t int
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		var cnt int
		fmt.Fscan(in, &cnt)
		var ans int
		for ans = 1; cnt >= 1;  ans++ {
			if !(ans % 3 == 0 || ans % 10 == 3) {
			    cnt--
			}
		}
		ans--
		fmt.Fprintln(out, ans)
	}
}

package main

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

var (
	reader = bufio.NewReader(os.Stdin)
	y      = []int{1, 2, 4, 5, 7, 8, 10, 11, 14, 16, 17, 19, 20, 22, 25, 26, 28, 29}
	t, n   int
)

func solve(n int) int {
	return (n-1)/18*30 + y[(n-1)%18]
}

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

package main

import "fmt"

func main() {

	ans := make([]int, 0)
	for  i:=1;i<10000;i++ {
		if i%3==0 || i%10==3{
			continue
		}
		ans = append(ans, i)
	}
	var T int
	fmt.Scan(&T)
	for i:=0;i<T;i++ {
		var n int
		fmt.Scan(&n)
		fmt.Printf("%d\n", ans[n-1])
	}

}

// Demo
package main

import (
	"fmt"
)

func main() {
	var a [1001]int
	var j int = 1
	for i := 1; i <= 1666; i++ {
		if (i%10) != 3 && (i%3) != 0 {
			a[j] = i
			j++
		}
	}
	var t int
	fmt.Scanln(&t)
	for i := 0; i < t; i++ {
		var k int
		fmt.Scanln(&k)
		fmt.Println(a[k], "\n")
	}
}

package main

import (
	"fmt"
	"strconv"
	"strings"
)

func main() {
	var seq []int64
	start := int64(1)
	for i := 0; i < 1000; {
		startStr := strconv.FormatInt(start, 10)
		if (start%3 != 0) && !strings.HasSuffix(startStr, "3") {
			seq = append(seq, start)
			i++
		}
		start++
	}

	var t int64
	_, err := fmt.Scan(&t)
	if err != nil {
		return
	}
	for i := int64(0); i < t; i++ {
		var k int64
		_, err := fmt.Scan(&k)
		if err != nil {
			return
		}
		fmt.Println(seq[k-1])
	}
}

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1560A(_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)
		for i := 1; ; i++ {
			if i%3 > 0 && i%10 != 3 {
				if n--; n == 0 {
					Fprintln(out, i)
					break
				}
			}
		}
	}
}
func main() { CF1560A(os.Stdin, os.Stdout) }

package main

import (
	"fmt"
)

func main() {
	// generating the table of K's
	archive := []int{}
	for i := 1; len(archive) <= 1000 ; i++ {
		if i%3 == 0 || i%10 == 3 {
			continue
		}

		archive = append(archive, i)
	}

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

	for ; testcases > 0; testcases-- {
		var k int
		fmt.Scanf("%d\n", &k)
        fmt.Println(archive[k - 1])

	}
}

package main

import "fmt"

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

	for i := 0; i < t; i++ {
		var n int
		fmt.Scan(&n)
		curr := 0
		cnt := 0
		for ; cnt < n; {
			curr++
			if !(curr % 3 == 0 || curr % 10 == 3) {
				cnt++
			}
		}
		fmt.Println(curr)
	}
}

package main

import (
	"fmt"
)

func main() {
	var (
		t int
		k int
	)
	fmt.Scanf("%d\n", &t)
	for i := 0; i < t; i++ {
		fmt.Scanf("%d\n", &k)
		var (
			t int
			n int
		)
		t = 1
		for j := 1; n != k; j++ {
			if j%3 == 0 || j%10 == 3 {
				j++
			}
			if j%3 == 0 || j%10 == 3 {
				j++
			}
			t = j
			n++
		}
		fmt.Println(t)
	}
}

package main

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

var n int
var list []int

func main() {

	fmt.Scan(&n)

	for i:=0;i<n;i++{
		var holder int
		fmt.Scan(&holder)
		list = append(list, holder)
	}

	for i:=0;i<len(list);i++{

		m := make(map[int]int)

		tally:=1
		for j:=1;tally<=list[i];j++{
			if j%3 != 0 && last_digit(j) != 3 && j%10!=3 {
				m[tally] = j
				tally++
			}
		}
		fmt.Println(m[list[i]])
	}

}

func x_power_y(x,y int) int {
	//dependencies math
	return int(math.Pow(float64(x),float64(y)))
}

func last_digit(x int ) int {
	// dependencies: strconv,math
	x_len := len(strconv.Itoa(x))
	if x_len <= 1 {
		return x
	}
	var x_first_digit int = x/x_power_y(10,x_len-1)
	return x % (x_first_digit * x_power_y(10,x_len-1))
}

func largest_int(list []int) int {
    for i:=0;i<len(list);i++{
        if list[0] < list[i] {
            list[0] = list[i]
        }
    }
    return list[0]
}

package main

import "fmt"

// https://codeforces.com/problemset/problem/1560/A
func main() {
	var t int
	_, _ = fmt.Scan(&t)

	arr := make([]int, 1001)

	j := 1

	for i := 1; i <= 1666; i++ {
		if i%3 != 0 && i%10 != 3 {
			arr[j] = i
			j++
		}
	}

	for i := 0; i < t; i++ {
		var n int
		_, _ = fmt.Scan(&n)
		fmt.Println(arr[n])
	}
}

package main

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

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

type Readable interface {
	bool | int | uint64 | int64 | double | float | byte
}

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

func print(arg ...interface{})            { fmt.Fprint(out, arg...) }
func println(arg ...interface{})          { fmt.Fprintln(out, arg...) }
func printf(f string, arg ...interface{}) { fmt.Fprintf(out, f, arg...) }
func scanf(f string, arg ...interface{})  { fmt.Fscanf(in, f, arg...) }

func readLn() string {
	ln, err := in.ReadString('\n')
	if err != nil {
		panic(err)
	}

	return strings.Trim(ln, " \n\r")
}

func readString() string {
	return readLn()
}

func readStrings() []string {
	return strings.Split(readLn(), " ")
}

func read[T Readable](f func(string) (T, error), input ...string) T {
	if len(input) == 0 {
		input = []string{readLn()}
	}

	res, err := f(input[0])
	if err != nil {
		panic(err)
	}

	return res
}

func readMany[T Readable](f func(...string) T) []T {
	input := readStrings()
	arr := make([]T, len(input))
	for i := 0; i < len(arr); i++ {
		arr[i] = f(input[i])
	}

	return arr
}

func readBool(input ...string) bool {
	return read(strconv.ParseBool, input...)
}

func readInt(input ...string) int {
	return read(strconv.Atoi, input...)
}

func readByte(input ...string) byte {
	return byte(read(func(s string) (uint64, error) {
		return strconv.ParseUint(s, 10, 8)
	}, input...))
}

func readDouble(input ...string) double {
	return read(func(s string) (float64, error) {
		return strconv.ParseFloat(s, 64)
	}, input...)
}

func readFloat(input ...string) float {
	return float32(read(func(s string) (float64, error) {
		return strconv.ParseFloat(s, 32)
	}, input...))
}

func readLong(input ...string) long {
	return read(func(s string) (int64, error) {
		return strconv.ParseInt(s, 10, 64)
	}, input...)
}

func readULong(input ...string) ulong {
	return read(func(s string) (uint64, error) {
		return strconv.ParseUint(s, 10, 64)
	}, input...)
}

func readBinary(input ...string) long {
	return read(func(s string) (int64, error) {
		return strconv.ParseInt(s, 2, 64)
	}, input...)
}

func readBools() []bool {
	return readMany(readBool)
}

func readInts() []int {
	return readMany(readInt)
}

func readBytes() []byte {
	return readMany(readByte)
}

func readDoubles() []double {
	return readMany(readDouble)
}

func readFloats() []float {
	return readMany(readFloat)
}

func readLongs() []long {
	return readMany(readLong)
}

func readULongs() []ulong {
	return readMany(readULong)
}

func main() {
	defer out.Flush()

	// solution
	t := readInt()
	ans := make([]int, t)

	m := make([]int, 1000)
	j := 1
	for i := 0; i < 1000; i++ {
		for j%3 == 0 || j%10 == 3 {
			j++
		}
		m[i] = j
		j++
	}

	for i := 0; i < t; i++ {
		n := readInt()
		ans[i] = m[n-1]
	}
	for i := 0; i < t; i++ {
		println(ans[i])
	}
}

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

	return x
}

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

	return y
}

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

	return x
}

package main

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

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

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

func Fscanf(format string, x ...interface{}) {
	fmt.Fscanf(reader, format, x...)
}

func Solution() {
	nums := make([]int, 0)
	numIndex := 0
	for num := 1; num <= 1666; num++ {
		if num%10 != 3 && num%3 != 0 {
			nums = append(nums, num)
			numIndex++
		}
	}

	var caseCount int
	Fscanf("%d\n", &caseCount)

	for caseIndex := 0; caseIndex < caseCount; caseIndex++ {
		Fscanf("%d\n", &numIndex)
		Fprintf("%d\n", nums[numIndex-1])
	}
}

func main() {
	Solution()
	writer.Flush()
}

/*
Polycarp doesn't like integers that are divisible by 3 or end with the digit 3

in their decimal representation. Integers that meet both conditions are disliked by Polycarp, too.

Polycarp starts to write out the positive (greater than 0
) integers which he likes: 1,2,4,5,7,8,10,11,14,16,…. Output the k-th element of this sequence (the elements are numbered from 1

).
Input

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

test cases follow.

Each test case consists of one line containing one integer k
(1≤k≤1000

).
Output

For each test case, output in a separate line one integer x
— the k-th element of the sequence that was written out by Polycarp.
*/

package main

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

func f(k int) int {
	if k == 1 {
		return 1
	}
	fk := f(k - 1)
	for i := fk + 1; i < fk+4; i++ {
		if i%3 != 0 && i%10 != 3 {
			return i
		}
	}
	return -1
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	scanner.Split(bufio.ScanWords)
	var t int
	scanner.Scan()
	t, _ = strconv.Atoi(scanner.Text())
	for i := 0; i < t; i++ {
		scanner.Scan()
		k, _ := strconv.Atoi(scanner.Text())
		writer.WriteString(strconv.Itoa(f(k)) + "\n")
	}
	writer.Flush()
}

package main

import "fmt"

func main() {
	var n, x int
	var array, ans []int
	_, _ = fmt.Scan(&n)

	for i := 1; i < 4096; i++ {
		if i%3 != 0 && i%10 != 3 {
			array = append(array, i)
		}
	}

	for i := 0; i < n; i++ {
		_, _ = fmt.Scan(&x)
		ans = append(ans, array[x-1])
	}

	for _, value := range ans {
		fmt.Println(value)
	}
}

// 1560A. Dislike of Threes
package main

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

func main() {
	var T, k int
	l := []interface{}{}
	for i := 1; len(l) < 1000; i++ {
		if i%3 == 0 || i%10 == 3 {
			continue
		} else {
			l = append(l, i)
		}
	}
	reader := bufio.NewReader(os.Stdin)
	fmt.Fscan(reader, &T)
	for t := 1; t <= T; t++ {
		fmt.Fscan(reader, &k)
		fmt.Println(l[k-1])
	}

}

package main

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

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

	var n, t int
	for fmt.Fscan(r, &t); t > 0; t-- {
		fmt.Fscan(r, &n)
		step := 0
		count := 0
		for step < n {
			count++
			if count%3 != 0 && count%10 != 3 {
				step++
			}
		}
		fmt.Fprintln(w, count)
	}

}

package main

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

func solve() {
	f := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	N, n, o, j := 0, 0, []int{}, 1
	for {
		if len(o) == 1005 {
			break
		}
		if j%3 != 0 && j%10 != 3 {
			o = append(o, j)
		}
		j++
	}
	fmt.Fscan(f, &N)
	for i := 0; i < N; i++ {
		fmt.Fscan(f, &n)
		fmt.Fprintln(w, o[n-1])
	}
	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 < T; t++ {
		var n int
		fmt.Fscan(in, &n)

		var x int
		for i := 0; i < n; i++ {
			x++
			for x%3 == 0 || x%10 == 3 {
				x++
			}
		}
		fmt.Fprintln(out, x)
	}
}

package main

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

func main() {
	likedIntegers := make([]int, 0, 1000)

	for i := 0; len(likedIntegers) <= 1000; i++ {
		a, b := 3*i+1, 3*i+2

		if a%10 != 3 {
			likedIntegers = append(likedIntegers, a)
		}
		if b%10 != 3 {
			likedIntegers = append(likedIntegers, b)
		}
	}

	var test int
	fmt.Scanln(&test)

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

	for ; test > 0; test-- {
		x := parseInt(getString(reader))
		writer.WriteString(fmt.Sprintln(likedIntegers[x-1]))
	}
	writer.Flush()
}

func parseInt(str string) int {
	var res int
	size := len(str)
	for i := 0; i < size; i++ {
		digit := int(str[i] - '0')
		for j := (i + 1); j < size; j++ {
			digit = digit<<3 + digit<<1
		}
		res += digit
	}
	return res
}

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

package main

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

var sc = bufio.NewScanner(os.Stdin)

func scan() string {
	for sc.Scan() {
		break
	}
	return sc.Text()
}

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

func scanInt8() int8 {
	i, err := strconv.ParseInt(scan(), 10, 8)
	if err != nil {
		panic(err)
	}
	return int8(i)
}

func scanInt64() int64 {
	i, err := strconv.ParseInt(scan(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

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

func min(ints ...int) int {
	a := ints[0]
	n := len(ints)
	for i := 1; i < n; i++ {
		if ints[i] < a {
			a = ints[i]
		}
	}
	return a
}

func max(ints ...int) int {
	a := ints[0]
	n := len(ints)
	for i := 1; i < n; i++ {
		if ints[i] > a {
			a = ints[i]
		}
	}
	return a
}

type Noop struct{}

var noop = Noop{}

func proc() {
	k := scanInt()
	i := 0
	for k > 0 {
		k--
		i++
		for i%10 == 3 || i%3 == 0 {
			i++
		}
	}
	fmt.Println(i)
}

/*
	2 3
	4 5
	6 7
	8 9
*/

func main() {
	sc.Split(bufio.ScanWords)
	t := scanInt()
	for i := 0; i < t; i++ {
		proc()
	}
}

package main

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

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

	beloved := []int{1, 2, 4, 5, 7, 8, 10, 11, 14}
	for i := 0; i < n; i++ {
		v := int(mustReadInt(r))
		if v <= len(beloved) {
			fmt.Println(beloved[v-1])
		} else {
			starter := beloved[len(beloved)-1]
			for len(beloved) < v {
				starter++
				for ; starter%3 == 0 || starter%10 == 3; starter++ {
				}
				beloved = append(beloved, starter)
			}
			fmt.Println(beloved[len(beloved)-1])
		}
	}
}

func mustReadNNumbs(r *bufio.Reader, n int64) []int64 {
	nums := make([]int64, n)
	var err error
	for i, s := range strings.Split(mustReadLine(r), " ") {
		nums[i], err = strconv.ParseInt(s, 10, 64)
		checkError(err)
	}
	return nums
}
func mustReadInt(r *bufio.Reader) int64 {
	numb, err := strconv.ParseInt(mustReadLine(r), 10, 64)
	checkError(err)
	return numb
}

func mustReadLine(r *bufio.Reader) string {
	s, _, err := r.ReadLine()
	checkError(err)
	return string(s)
}

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

package main

import "fmt"

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

	var arr [1000]int
	for i, n := 0, 1; i < 1000; n++ {
		if n%3 != 0 && n%10 != 3 {
			arr[i] = n
			i++
		}
	}

	for ; test > 0; test-- {
		fmt.Scanf("%d\n", &k)
		fmt.Println(arr[k-1])
	}
}

package main

import "fmt"

var a [1000]int

func main() {
	for i, j := 0, 1; i < 1000; j++ {
		if j % 3 == 0 || j % 10 == 3 {
			continue
		}
		a[i] = j
		i++
	}
	var T int
	fmt.Scan(&T)
	var t int
	for i := 0; i < T; i++ {
		fmt.Scan(&t)
		work(t-1)
	}
}

func work(idx int) {
	fmt.Println(a[idx])
}

package main

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

const N = 20010

var (
	n int
)

func main() {
	r := bufio.NewReader(os.Stdin)
	fmt.Fscan(r, &n)
	res := make([]int, 1)
	for i := 1; i <= N && len(res) < 1010; i++ {
		if i%10 != 3 && i%3 != 0 {
			res = append(res, i)
		}
	}

	num := 0
	for ; n != 0; n-- {
		fmt.Fscan(r, &num)
		fmt.Println(res[num])
	}
}

package main

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

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

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

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

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

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

/**
Run solve the problem CF1560A
Date: 16/09/21
User: pepradere
URL: https://codeforces.com/problemset/problem/1560/A
Problem: CF1560A
**/
func (in *CF1560A) Run() {

	arr := []int{}

	for i := 1; len(arr) < 1001; i++ {
		num := fmt.Sprintf("%d", i)
		if i%3 != 0 && num[len(num)-1] != '3' {
			arr = append(arr, i)
		}
	}

	t := in.NextInt()
	for ; t > 0; t-- {
		k := in.NextInt()
		fmt.Println(arr[k-1])
	}
}

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

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

package main

import "fmt"

func fun(k int32) int32 {
	var cnt = int32(0)

	for i := int32(1); i <= 10000; i++ {
		cnt++

		if i%3 == 0 || (i > 10 && i%10 == 3) {
			cnt -= 1
		}

		if cnt == k {
			return i
		}
	}
	return 0
}

func main() {
	var t int32
	fmt.Scanf("%v\n", &t)
	var x int32
	for i := int32(0); i < t; i++ {
		fmt.Scanf("%v\n", &x)
		fmt.Println(fun(x))
	}
}

package main

import "fmt"

func main() {
	i:= 1
	count := 0

	a := make([]int, 1000)
	for count < 1000 {
		if i % 3 != 0 && i % 10 != 3 {
			a[count] = i
			count++
		}
		i++
	}

	var n int
	fmt.Scan(&n)

	for j := 0; j < n; j++ {
		var t int
		fmt.Scan(&t)
		fmt.Println(a[ t - 1])
	}
}

package main

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

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

	var t int
	for Fscan(in, &t); t > 0; t-- {
		var k int
		Fscan(in, &k)

		for i, cnt := 1, 0; i <= 3000; i++ {
			val := i
			if val % 3 == 0 || val % 10 == 3 {
				continue
			}
			cnt++
			if cnt == k {
				Fprintln(out, i)
				break
			}
		}
	}
}

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

package main

import "C"
import (
	"fmt"
)

//// IntSlice Sorted
//type IntSlice []int
//func (x IntSlice) Sort() {
//	sort.Sort(x)
//}
//func (x IntSlice) Len() int           { return len(x) }
//func (x IntSlice) Less(i, j int) bool { return x[i] < x[j] }
//func (x IntSlice) Swap(i, j int)      { x[i], x[j] = x[j], x[i] }

var likedArr []int
func main() {
	for idx := 1; idx <= 2000; idx++ {
		if !(idx%3 == 0 || idx%10 == 3) {
			likedArr=append(likedArr,idx)
		}
	}
	Cases()
	//TestCase()
}

// Main Implementation

func Cases() {
	var n int
	_, _ = fmt.Scan(&n)
	for idx := 0; idx < n; idx++ {
		TestCase()
	}
}

func TestCase() {
	var (
		num int
	)
	fmt.Scan(&num)
	fmt.Println(likedArr[num-1])
}

package main

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

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

func main() {
	var test int
	fmt.Fscan(in, &test)
	for i := 0; i < test; i++ {
		solve()
	}

}

func solve() {
	var k int
	fmt.Fscan(in, &k)
	currentCount := 0
	currentNumber := 1
	for {
		if currentNumber%10 != 3 && currentNumber%3 != 0 {
			currentCount++
		}
		if currentCount == k {
			break
		}
		currentNumber++
	}
	fmt.Println(currentNumber)
}

func printArray(arr []int) {
	for i := 1; i < len(arr); i++ {
		fmt.Print(arr[i], " ")
	}
	fmt.Println()
}

type runeSort []rune

func (r runeSort) Len() int           { return len(r) }
func (r runeSort) Swap(i, j int)      { r[i], r[j] = r[j], r[i] }
func (r runeSort) Less(i, j int) bool { return r[i] < r[j] }

package main

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

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

	i, j, arr := 1, 1, []int{}

	for j <= 1000 {
		if i%3 == 0 || i%10 == 3 {
			i += 1
			continue
		}
		arr = append(arr, i)
		i += 1
		j += 1
	}
	var t int16
	fmt.Fscan(in, &t)

	for ; t > 0; t-- {
		var k int16
		fmt.Fscan(in, &k)
		fmt.Fprintln(out, arr[k-1])
	}
}

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

package main

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

var iost *Iost

type Iost struct {
	Scanner *bufio.Scanner
	Writer  *bufio.Writer
}

func NewIost(fp io.Reader, wfp io.Writer) *Iost {
	const BufSize = 1000000
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, BufSize), BufSize)
	return &Iost{Scanner: scanner, Writer: bufio.NewWriter(wfp)}
}

func (i *Iost) Text() string {
	if !i.Scanner.Scan() {
		panic("scan failed")
	}
	return i.Scanner.Text()
}

func (i *Iost) Atoi(s string) int                 { x, _ := strconv.Atoi(s); return x }
func (i *Iost) GetNextInt() int                   { return i.Atoi(i.Text()) }
func (i *Iost) Atoi64(s string) int64             { x, _ := strconv.ParseInt(s, 10, 64); return x }
func (i *Iost) GetNextInt64() int64               { return i.Atoi64(i.Text()) }
func (i *Iost) Atof64(s string) float64           { x, _ := strconv.ParseFloat(s, 64); return x }
func (i *Iost) GetNextFloat64() float64           { return i.Atof64(i.Text()) }
func (i *Iost) Print(x ...interface{})            { fmt.Fprint(i.Writer, x...) }
func (i *Iost) Printf(s string, x ...interface{}) { fmt.Fprintf(i.Writer, s, x...) }
func (i *Iost) Println(x ...interface{})          { fmt.Fprintln(i.Writer, x...) }
func isLocal() bool                               { return os.Getenv("I") == "IronMan" }

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	if isLocal() {
		fp, _ = os.Open(os.Getenv("END_GAME"))
	}
	iost = NewIost(fp, wfp)
	defer func() {
		if isLocal() {
			iost.Println(recover())
		}
		iost.Writer.Flush()
	}()
	solve()
	for i := 0; isLocal() && i < 100; i++ {
		iost.Println("-----------------------------------")
		solve()
	}
}

func solve() {
	t := iost.GetNextInt()
	num := make([]int, 1010)
	k := 1
	for i := 1; k <= 1000; i++ {
		if i%3 != 0 && i%10 != 3 {
			num[k] = i
			k++
		}
	}
	for t > 0 {
		t--
		func() {
			k := iost.GetNextInt()
			iost.Println(num[k])
		}()
	}
}

package main

import (
	"fmt"
)

func main() {
	arr := make([]int, 0)
	{
		i := 1
		for len(arr) <= 1000 {
			if !(i%3 == 0) && !(i%10 == 3) {
				arr = append(arr, i)
			}
			i++
		}
	}
	var t int
	fmt.Scan(&t)
	for i := 0; i < t; i++ {
		var k int
		fmt.Scan(&k)
		fmt.Println(arr[k-1])
	}
}

package main

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

func main() {
	ps := [1000]int{}
	n, i := 1, 0
	for i < 1000 {
		if n%3 == 0 || n%10 == 3 {
			n++
			continue
		}
		ps[i] = n
		i++
		n++
	}

	var T, K int
	in := bufio.NewReader(os.Stdin)
	Fscan(in, &T)
	for t := 0; t < T; t++ {
		Fscan(in, &K)
		fmt.Println(ps[K-1])
	}
}

package main

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

// var m []int
// err = json.Unmarshal([]byte(r.FormValue("example")), &m)

// for i := 0; i < len(m); i++ {
// 	fmt.Println(m[i])
// }

// sort.Slice(arr, func(i, j int) bool {
// 	return arr[i] > arr[j]
// })

func MIN(x, y int64) int64 {
	if x > y {
		return y
	} else {
		return x
	}
}

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

func MKO(x, y int64) int64 {
	if x < y {
		return 0
	} else {
		return x - y + 1
	}
}

func MAX(x, y int64) int64 {
	if x > y {
		return x
	} else {
		return y
	}
}

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

func LCM(x, y int) int {
	if x >= y {
		initial := x
		for i := 1; i < y+2; i++ {
			if initial%y == 0 {
				break
			} else {
				initial = initial + x
			}

		}
		return initial
	} else {
		initial := y
		for i := 1; i < x+2; i++ {
			if initial%x == 0 {
				break
			} else {
				initial = initial + y
			}

		}
		return initial
	}
}

func GCD(x, y int64) int64 {
	if x*y == 0 {
		return MAX(x, y)
	} else {
		var l, q int64
		l = MAX(x, y)
		q = MIN(x, y)
		var m int64
		for l*q > 0 {
			a := l % q
			b := l - a
			cc := int64(b / q)
			remain := l - cc*q
			l = MAX(remain, q)
			q = MIN(remain, q)
			if l*q == 0 {
				m = l + q
				break
			}

		}
		return m
	}
}

func IsItPrime(x int) bool {
	if x < 10 {
		if x == 2 || x == 3 || x == 5 || x == 7 {
			return true
		} else {
			return false
		}
	} else {
		j := 0
		k := math.Sqrt(float64(x))
		for m := 3; m <= int(k); {
			if x%m == 0 {
				j = 1
				break
			}
			m = m + 2
		}
		if j == 1 {
			return false
		} else {
			return true
		}
	}
}

func PrimeFactorization(n int) (pfs map[int]int) {
	pfs = make(map[int]int)

	// Get the number of 2s that divide n
	for n%2 == 0 {
		if _, ok := pfs[2]; ok {
			pfs[2] += 1
		} else {
			pfs[2] = 1
		}
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			if _, ok := pfs[i]; ok {
				pfs[i] += 1
			} else {
				pfs[i] = 1
			}
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs[n] = 1
	}

	return
}

func NumberOfDivisors(n int) int {
	pfs := PrimeFactorization(n)

	num := 1
	for _, exponents := range pfs {
		num *= (exponents + 1)
	}

	return num
}

func KthPrime(x int) (y int) {
	if x == 1 {
		y = 2
	}
	if x == 2 {
		y = 3
	}
	if x > 2 {
		var sum int = 2
		begin := 5
		for sum < x+1 {
			if IsItPrime(begin) == true {
				sum++
			}
			if sum == x {
				y = begin
				break
			} else {
				if begin%6 == 1 {
					begin = begin + 4
				} else {
					begin = begin + 2
				}
			}
		}
	}
	return
}

func MODULE(x, y int) int {
	if x > y {
		return x - y
	} else {
		return y - x
	}
}

func BITAND(x, y int64) int64 {
	var ans int64
	begin := x
	sec := y
	var count int64 = 1
	for 1 == 1 {
		if (begin%2)*(sec%2) == 1 {
			ans = ans + count
			count = count * 2
			begin = int64(begin / 2)
			sec = int64(sec / 2)
			if begin*sec == 0 {
				break
			}

		} else {
			count = count * 2
			begin = int64(begin / 2)
			sec = int64(sec / 2)
			if begin*sec == 0 {
				break
			}
		}
	}
	return ans
}

var t int

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &t)

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

		// ARR := make([]int, n)
		// for i := 0; i < n; i++ {
		// 	fmt.Fscan(input, &ARR[i])

		// }
		ans := 1
		for i := 1; i <= n-1; i++ {
			q := ans % 30
			if q == 11 || q == 22 {
				ans = ans + 3
			} else {
				if q%3 == 2 {
					ans = ans + 2
				} else {
					ans = ans + 1
				}
			}

		}
		fmt.Println(ans)

	}

}

package main

import (
	"fmt"
	"strconv"
)

func main() {
	var values []int
	var t int
	fmt.Scanln(&t)
	i := 1
	for {
		if len(values) < 1000 {
			g := strconv.Itoa(i)
			if i % 3 != 0 && g[len(g) - 1] != '3'{
				values = append(values, i)
			}
			i++
		}else{
			break
		}

	}
	a := 0
	for i:=0;i<t;i++{
		fmt.Scanln(&a)
		fmt.Println(values[a - 1])
	}

}

package main

import "fmt"

func main() {
	var T, K, temp int
	temp = 0
	fmt.Scan(&T)
	for i := 0; i < T; i++ {
		fmt.Scan(&K)
		for K != 0 {
			temp = temp + 1
			if temp%3 != 0 && temp%10 != 3 {
				// Not Discarded
				K = K - 1
			}
		}

		fmt.Println(temp)
		temp = 0
	}

}

package main

import (
    "fmt"
)

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

    for i := 0; i < testCases; i++ {
        var k int
        fmt.Scanln(&k)

        count := 0
        j := 1
        for count != k {
            if j % 3 != 0 && j % 10 != 3 {
                count++
            }
            j++
        }
        fmt.Println(j-1)
    }
}

package main

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

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

	scan := func(a ...interface{}) (int, error) { return fmt.Fscan(ins, a...) }
	printf := func(s string, a ...interface{}) (int, error) { return fmt.Fprintf(out, s, a...) }
	var n int
	scan(&n)
	for i := 0; i < n; i++ {
		var k int
		scan(&k)
		j := 1
		for ; k > 0; {
			if j%3 != 0 && j%10 != 3 {
				k--
			}
			j++
		}
		printf("%d\n", j-1)
	}
}

package main

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

var in = NewIn()
var out = NewOut()

func main() {
	defer out.flush()

	tests()
	// solve()
}

/* --- Solution A --- */
func solve() {
	k := in.nextInt()

	answer := 0
	for i := 1; i <= k; {
		answer++
		ok := true
		if answer%10 == 3 {
			ok = false
		}
		sum := 0
		t := answer
		for t > 0 {
			sum += t % 10
			t /= 10
		}
		if sum%3 == 0 {
			ok = false
		}
		if ok {
			i++
		}
	}

	out.println(answer)
}

func tests() {
	tt := in.nextInt()
	for ; tt > 0; tt-- {
		solve()
	}
}

/* --- I/O --- */
type In struct {
	scanner *bufio.Scanner
}

func NewIn() *In {
	in := In{bufio.NewScanner(os.Stdin)}
	in.scanner.Split(bufio.ScanWords)
	return &in
}

func (in *In) nextInt() int {
	in.scanner.Scan()
	i, _ := strconv.Atoi(in.scanner.Text())
	return i
}

func (in *In) nextLong() int64 {
	in.scanner.Scan()
	i, _ := strconv.ParseInt(in.scanner.Text(), 10, 64)
	return i
}

func (in *In) next() string {
	in.scanner.Scan()
	return in.scanner.Text()
}

type Out struct {
	writer *bufio.Writer
}

func NewOut() *Out {
	out := Out{bufio.NewWriter(os.Stdout)}
	return &out
}

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

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

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

func (out *Out) flush() {
	out.writer.Flush()
}

package main

import "fmt"

func main() {
	var n int
	var input []int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		var number int
		fmt.Scan(&number)
		input = append(input, number)
	}
	count := 0
	tmp := 1
	arr := []int{}
	for count <= 1000 {
		if isValid(tmp) {
			count++
			arr = append(arr, tmp)
		}
		tmp++
	}
	for i := 0; i < n; i++ {
		fmt.Println(arr[input[i]-1])
	}
}

func isValid(n int) bool {
	if n%10 == 3 || n%3 == 0 {
		return false
	}
	return true
}

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, n int
	fmt.Fscan(r, &t)
	for ti := 0; ti < t; ti++ {
		fmt.Fscan(r, &n)
		w1 := do(n)
		fmt.Fprint(w, w1)
		fmt.Fprintln(w)
	}
}

func do(n int) int {
	return a[n]
}

var a = make([]int, 1e3+5)

func init() {
	i := 1
	k := 0
	for i <= 1000 {
		k++
		if k%3 == 0 || k%10 == 3 {
			continue
		}
		a[i] = k
		i++
	}
}

package main
//this code is written by likely
//do not distribute it freely

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

func main(){
	in := bufio.NewReader(os.Stdin)
	out := os.Stdout
	var s [1005]int64
	var i,t,n,sl int64
	sl=0
	for i=1;i<=5000;i++{
		if i%10==3{
			continue
		}
		if i%3==0{
			continue
		}
		sl++
		s[sl]=i
		if sl==1000{
			break
		}
	}
	fmt.Fscan(in,&t)
	for i=1;i<=t;i++{
		fmt.Fscan(in,&n)
		fmt.Fprintln(out,s[n])
	}
}

package main

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

func toInt(buf []byte) (n int) {
    for _, v := range buf {
        n = n*10 + int(v-'0')
    }
    return
}

func main() {
	var n int
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Scan()
  n = toInt(scanner.Bytes())
  var arr []int;
  var c int = 1
  for len(arr) < 1000{
    if(c % 3 != 0) && (c % 10 != 3){
      arr = append(arr, c)
    }
    c++
  }
  for i := 0; i < n; i++{
    var b int;
    scanner.Scan()
    b = toInt(scanner.Bytes())
    fmt.Println(arr[b - 1])
  }
}

package main

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

func main() {
	r := bufio.NewReaderSize(os.Stdin, 1024*1024)

	var T, n int
	fmt.Fscanf(r, "%d\n", &T)
	for t := 0; t < T; t++ {
		fmt.Fscanf(r, "%d\n", &n)

		j := 0
		for i := 1; ; i++ {
			if i%3 == 0 || i%10 == 3 {
				continue
			}
			j++
			if j == n {
				fmt.Println(i)
				break
			}
		}
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := os.Stdout
	var t int
	cnt:=0
	now:=0
	lol := [30005]int{}
	for cnt!= 1000{
		now++
		if now%10==3||now%3==0{
			continue
		}else{
			cnt++
			lol[cnt]=now
		}
	}
	fmt.Fscan(in,&t)
	for c:=1;c<=t;c++{
		var k int
		fmt.Fscan(in,&k)
		fmt.Fprintln(out,lol[k])
	}
}

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

                            Online Go Lang Compiler.
                Code, Compile, Run and Debug Go Lang program online.
Write your code in this editor and press "Run" button to execute it.

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

package main

import "fmt"
import "bufio"
import "os"
//import "sort"

func main() {
    in := bufio.NewReader(os.Stdin)
    var n int
    fmt.Fscan(in, &n)
    for ; n > 0; n--{
        var k int
        fmt.Fscan(in, &k)
        var i int = 1
        for ; k > 0; i++ {
            if (i % 3 != 0 && i % 10 != 3) {
                k--
            }
        }
        fmt.Println(i - 1)

    }

}

package main

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

func main() {

	r := bufio.NewReader(os.Stdin)

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

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

		solve(k)
	}
}

func solve(k int) {
	count := 0
	for i := 1; i < 100000; i++ {
		if i % 3 == 0 || i % 10 == 3 {
			continue
		}
		count++
		if count >= k {
			fmt.Println(i)
			return
		}
	}
}

package main

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

func main() {
	defer wr.Flush()

	x := 1
	dp := make([]int, 0, 1000)
	for len(dp) <= 1000 {
		if x%3 != 0 && x%10 != 3 {
			dp = append(dp, x)
		}
		x++
	}

	t := scanInt()
	for i := 0; i < t; i++ {
		fmt.Fprintln(wr, dp[scanInt()-1])
	}
}

var (
	sc *bufio.Scanner
	wr *bufio.Writer
)

func init() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	wr = bufio.NewWriter(os.Stdout)
}

func scanInt() int {
	sc.Scan()
	ret, _ := strconv.Atoi(sc.Text())
	return ret
}

package main

import (
	"fmt"
)

func main() {
	var t uint8

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

	input := make([]uint16, 0, t)

	for i := uint8(0); i < t; i++ {
		var k uint16
		fmt.Scanf("%d", &k)
		input = append(input, k)
	}

	for _, in := range input {
		i := uint16(1)
		output := uint16(0)
		maxK := uint16(0)
		if in == 0 {
			continue
		}
		for output < uint16(in) {
			if (i%3 == 0) || (i%10 == 3) {
				i++
				continue
			}

			if (i%3 == 0) && (i%10 == 3) {
				i++
				continue
			}

			if i > maxK {
				maxK = i
			}

			i++
			output++
		}

		fmt.Printf("%d\n", maxK)
	}

}

package main

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

func main() {
	file, err := os.Open("test.txt")
	if err != nil {
		return
	}
	defer func() {
		if err = file.Close(); err != nil {
			return
		}
	}()

	scanner := bufio.NewScanner(file)

	var t int
	var input []int
	for scanner.Scan() {
		if t == 0 {
			t, _ = strconv.Atoi(scanner.Text())
			input = make([]int, 0, t)
			continue
		}

		if t > 100 {
			return
		}

		x, _ := strconv.Atoi(scanner.Text())
		input = append(input, x)
	}

	if len(input) != t {
		return
	}

	for _, in := range input {
		i := int(1)
		output := int(0)
		maxK := int(0)
		if in == 0 {
			continue
		}
		for output < int(in) {
			if (i%3 == 0) || (i%10 == 3) {
				i++
				continue
			}

			if (i%3 == 0) && (i%10 == 3) {
				i++
				continue
			}

			if i > maxK {
				maxK = i
			}

			i++
			output++
		}

		fmt.Printf("%d\n", maxK)
	}

}

package main

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

func main() {
	file, err := os.Open("test.txt")
	if err != nil {
		return
	}
	defer func() {
		if err = file.Close(); err != nil {
			return
		}
	}()

	scanner := bufio.NewScanner(file)

	var t int
	var input []int
	for scanner.Scan() {
		if t == 0 {
			t, _ = strconv.Atoi(scanner.Text())
			input = make([]int, 0, t)
			continue
		}

		x, _ := strconv.Atoi(scanner.Text())
		input = append(input, x)
	}

	for _, in := range input {
		i := int(1)
		output := int(0)
		maxK := int(0)
		if in == 0 {
			continue
		}
		for output < int(in) {
			if (i%3 == 0) || (i%10 == 3) {
				i++
				continue
			}

			if (i%3 == 0) && (i%10 == 3) {
				i++
				continue
			}

			if i > maxK {
				maxK = i
			}

			i++
			output++
		}

		fmt.Printf("%d\n", maxK)
	}

}

package main

import (
	"fmt"
)

func main() {
	var t uint8

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

	input := make([]uint16, 0, t)

	for i := uint8(0); i < t; i++ {
		var k uint16
		fmt.Scanf("%d", &k)
		input = append(input, k)
	}

	for _, in := range input {
		i := uint16(1)
		output := uint16(0)
		maxK := uint16(0)
		for output < uint16(in) {
			if (i%3 == 0) || (i%10 == 3) {
				i++
				continue
			}

			if (i%3 == 0) && (i%10 == 3) {
				i++
				continue
			}

			if i > maxK {
				maxK = i
			}

			i++
			output++
		}

		fmt.Printf("%d\n", maxK)
	}

}

package main

import (
	"fmt"
)

func main() {
	var t uint8

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

	input := make([]uint16, 0, t)

	for i := uint8(0); i < t; i++ {
		var k uint16
		fmt.Scanf("%d", &k)
		input = append(input, k)
	}

	for _, in := range input {
		i := uint16(1)
		output := uint16(0)
		maxK := uint16(0)
		for output < uint16(in) {
			if (i%3 == 0) || (i%10 == 3) {
				i++
				continue
			}

			if (i%3 == 0) && (i%10 == 3) {
				i++
				continue
			}

			if i > maxK {
				maxK = i
			}

			i++
			output++
		}

		fmt.Printf("%d\n", maxK)
	}

}

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		var a int
		for i := 0; i < 100000; i++ {
			if i%3 != 0 && i%10 != 3 {
				a--
			}
			if a == 0 {
				fmt.Println(i)
				break
			}
		}
	}
}

package main

import "fmt"

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

func dd(a int) {
	n := 0
	for i := 1; ; i++ {
		if i%3 != 0 || i%10 != 3 {
			n++
		}
		if n == a {
			fmt.Println(i)
			return
		}
	}
}

package main

import "fmt"

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

func dd(a int) {
	n := 0
	for i := 0; ; i++ {
		if i%3 != 0 || i%10 != 3 {
			n++
		}
		if n == a {
			fmt.Println(i)
			return
		}
	}
}

package main

import "fmt"

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

func dd(a int) {
	i := 1
	for ; ; i++ {
		if i%3 != 0 || i%10 != 0 {
			a--
		}
		if a == 0 {
			fmt.Println(i)
			return
		}
	}

}

package main

import "fmt"

var arr = [10005]int{}

func main() {
	t := 0
	now := 1
	for i := 1; i >= 1; i++ {
		if now > 1000 {
			break
		}
		if i%3 == 0 || i%10 == 3 {
			continue
		}
		arr[now] = i
		now++

	}
	for i:=1;i<10;i++{
		fmt.Println(arr[i])
	}
	fmt.Scan("%d", &t)
	for {
		if t == 0 {
			break
		}
		t--
		n := 0
		fmt.Scan("%d", &n)
		fmt.Println(arr[n])
	}
}

package main

import "fmt"

var arr = [10005]int{}

func main() {
	t := 0
	now := 1
	for i := 1; i >= 1; i++ {
		if now > 1000 {
			break
		}
		if i%3 == 0 || i%10 == 3 {
			continue
		}
		arr[now] = i
		now++

	}
	fmt.Scan("%d", &t)
	for {
		if t == 0 {
			break
		}
		t--
		n := 0
		fmt.Scan("%d", &n)
		fmt.Println(arr[n])
	}
}

// send.go
package main

import "fmt"
var arr =[100005]int{}
func main() {
	t:=0
	now:=1
	for i:=1;i>=1;i++{
		if now>1000 {
			break
		}
		if i%3==0||i%10==3 {
			continue
		}
		arr[now]=i
		now++

	}
	fmt.Scanf("%d",&t)
	for {
		if t==0{
			break
		}
		t--
		n:=0
		fmt.Scanf("%d",&n)
		fmt.Println(arr[n])
	}
}

package main

import (
	"fmt"
)

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

	arr := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d\n", &arr[i])
	}
	n = 0
	for _, value := range arr {
		if n < value {
			n = value
		}
	}
	m := make(map[int]int)
	cnt := 0
	for i := 1; cnt < n; i++ {
		if i%3 != 0 && i%10 != 3 {
			cnt++
			m[cnt] = i
		}
	}
	for _, value := range arr {
		fmt.Printf("%d\n", m[value])
	}
}

package main

import (
	"fmt"
)

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

	arr := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &arr[i])
	}
	n = 0
	for _, value := range arr {
		if n < value {
			n = value
		}
	}
	m := make(map[int]int)
	cnt := 0
	for i := 1; cnt < n; i++ {
		if i%3 != 0 && i%10 != 3 {
			cnt++
			m[cnt] = i
		}
	}
	for _, value := range arr {
		fmt.Printf("%d\n", m[value])
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := os.Stdout
	var t int
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		var cnt int
		fmt.Fscan(in, &cnt)
		var ans int
		for ans = 1; cnt >= 1;  ans++ {
			if !(ans % 3 == 0 || ans % 10 == 0) {
			    cnt--
			}
		}
		ans--
		fmt.Fprintln(out, ans)
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := os.Stdout
	var t int
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		var cnt int
		fmt.Fscan(in, &cnt)
		var ans int
		for ans = 1; cnt > 1;  ans++ {
			if !(ans % 3 == 0 || ans % 10 == 0) {
			    cnt--
			}
		}
		fmt.Fprintln(out, ans)
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := os.Stdout
	var t int
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		var cnt int
		fmt.Fscan(in, &cnt)
		var ans int
		for ans = 1; cnt > 1;  ans++ {
			if !(ans % 3 == 0 || ans % 10 == 0) {
			    cnt--
			}
		}
		ans--
		fmt.Fprintln(out, ans)
	}
}

// Demo
package main

import (
	"fmt"
)

func main() {
	var a [1001]int
	for i := 1; i <= 1666; i++ {
		var j int = 1
		if (i%10) != 3 && (i%3) != 0 {
			a[j] = i
			j++
		}
	}
	var t int
	fmt.Scanln(&t)
	for i := 0; i < t; i++ {
		var k int
		fmt.Scanln(&k)
		fmt.Println(a[k], "\n")
	}
}


Coming up with a new problem isn't as easy as many people think. Sometimes it is hard enough to name it. We'll consider a title original if it doesn't occur as a substring in any titles of recent Codeforces problems. You've got the titles of n last problems — the strings, consisting of lowercase English letters. Your task is to find the shortest original title for the new problem. If there are multiple such titles, choose the lexicographically minimum one. Note, that title of the problem can't be an empty string.A substring s[l... r] (1 ≤ l ≤ r ≤ |s|) of string s = s1s2... s|s| (where |s| is the length of string s) is string slsl + 1... sr.String x = x1x2... xp is lexicographically smaller than string y = y1y2... yq, if either p < q and x1 = y1, x2 = y2, ... , xp = yp, or there exists such number r (r < p, r < q), that x1 = y1, x2 = y2, ... , xr = yr and xr + 1 < yr + 1. The string characters are compared by their ASCII codes.

The first line contains integer n (1 ≤ n ≤ 30) — the number of titles you've got to consider. Then follow n problem titles, one per line. Each title only consists of lowercase English letters (specifically, it doesn't contain any spaces) and has the length from 1 to 20, inclusive.

Print a string, consisting of lowercase English letters — the lexicographically minimum shortest original title.

5
threehorses
goodsubstrings
secret
primematrix
beautifulyear

NoteIn the first sample the first 9 letters of the English alphabet (a, b, c, d, e, f, g, h, i) occur in the problem titles, so the answer is letter j.In the second sample the titles contain 26 English letters, so the shortest original title cannot have length 1. Title aa occurs as a substring in the first title.

package main

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

func main(){
	var n int
	r := bufio.NewScanner(os.Stdin)
	r.Split(bufio.ScanWords)
	w := bufio.NewWriter(os.Stdout)
	r.Scan()
	n, _ = strconv.Atoi(r.Text())
	var s string
	var a [26]int
	var b [26][26]int
	for i:=0; i<n; i++ {
		r.Scan()
		s = r.Text()
		for j:=0; j<len(s); j++ {
			a[s[j]-'a'] += 1
			if j+1 < len(s) {
				b[s[j]-'a'][s[j+1]-'a'] += 1
			}
		}
	}
	for i:=0; i<26; i++ {
		if a[i] == 0 {
			w.WriteString(string('a'+i)+"\n")
			w.Flush()
			return
		}
	}
	for i:=0; i<26; i++ {
		for j:=0; j<26; j++ {
			if b[i][j] == 0 {
				w.WriteString(string('a'+i)+string('a'+j)+"\n")
				w.Flush()
				return
			}
		}
	}
}

package main

import "fmt"

func main() {
    var n int
    var s string
    fmt.Scan(&n)
    m := make(map[string]bool)
    for i := 0; i < n; i++ {
        fmt.Scan(&s)
        for i := 0; i < len(s); i++ {
            m[string(s[i])] = true
            if i > 0 {
                ss := string(s[i-1])+string(s[i])
                m[ss] = true
            }
        }
    }
    var ans string
    for i := -1; i < 26; i++ {
        ok := false
        for j := 0; j < 26; j++ {
            if i == -1 {
                ans = string(j+'a')
            } else {
                ans = string(i+'a')+string(j+'a')
            }
            if !m[ans] { ok = true; break }
        }
        if ok { break }
    }
    fmt.Println(ans)
}

// 278B
package main

import (
	"fmt"
	"strings"
)

func main() {
	var a, b, i, j, x int
	var m, n, p, q string
	fmt.Scan(&a)
	for x = 1; x <= a; x++ {
		fmt.Scan(&m)
		n = n + string('?')
		n = n + m
	}
	for i = int('a'); i <= int('z'); i++ {
		p = string(i)
		b = strings.Index(n, p)
		if b == -1 {
			fmt.Print(p)
			return
		}
	}
	for i = int('a'); i <= int('z'); i++ {
		for j = int('a'); j <= int('z'); j++ {
			p = string(i)
			q = string(j)
			p = p + q
			b = strings.Index(n, p)
			if b == -1 {
				fmt.Print(p)
				return
			}
		}
	}
}

// 278B-mic
package main

import (
	"fmt"
)

func main() {
	var s string
	var li int
	li = 26
	var i, j, n, m int
	var v [33]int
	var ma [33][33]int
	fmt.Scan(&n)
	for i = 1; i <= n; i++ {
		fmt.Scan(&s)
		m = len(s)
		for j = 0; j < m; j++ {
			v[s[j]-'a'] = 1
		}
		for j = 0; j < m-1; j++ {
			ma[s[j]-'a'][s[j+1]-'a'] = 1
		}
	}
	for i = 0; i < li; i++ {
		if v[i] == 0 {
			fmt.Print(string('a' + i))
			break
		}
	}
	if i == 26 {
		for i = 0; i < 26; i++ {
			for j = 0; j < 26; j++ {
				if ma[i][j] == 0 {
					fmt.Print(string('a' + i))
					fmt.Print(string('a' + j))
					fmt.Println()
					break
				}
			}
			if j != 26 {
				break
			}
		}
	}
	return
}

package main

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

func main(){
	var n int
	r := bufio.NewScanner(os.Stdin)
	r.Split(bufio.ScanWords)
	w := bufio.NewWriter(os.Stdout)
	r.Scan()
	n, _ = strconv.Atoi(r.Text())
	var s string
	a := make([]int, 2000)
	for i:=0; i<n; i++ {
		r.Scan()
		s = r.Text()
		for j:=0; j<len(s); j++ {
			a[s[j]-'a'] = 1
		}
		for j:=0; j<len(s)-1; j++ {
			a[26*(s[j] - 'a' + 1)+s[j+1]-'a'] = 1
		}
	}
	for k:=0; k<1000; k++ {
		if a[k] == 0 {
			if k < 26 {
				w.WriteString(string(k+'a')+"\n")
			} else {
				w.WriteString(string(k/26+'a'-1)+string(k%26+'a')+"\n")
			}
			w.Flush()
			return
		}
	}
}

package main

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

func main(){
	var n int
	r := bufio.NewScanner(os.Stdin)
	r.Split(bufio.ScanWords)
	w := bufio.NewWriter(os.Stdout)
	r.Scan()
	n, _ = strconv.Atoi(r.Text())
	var s string
	le := 0
	a := make([]int, 2000)
	for i:=0; i<n; i++ {
		r.Scan()
		s = r.Text()
		le = len(s)
		for j:=0; j<le; j++ {
			a[s[j]-'a'] = 1
		}
		for j:=0; j<le-1; j++ {
			a[26*(s[j]-'a'+1)+s[j+1]-'a'] = 1
		}
	}
	for k:=0; k<1000; k++ {
		if a[k] == 0 {
			if k < 26 {
				if string(k+'a') == "f" {
					w.WriteString(string(k-1+'a')+"\n")
				} else {
					w.WriteString(string(k+'a')+"\n")
				}
			} else {
				w.WriteString(string(k/26+'a'-1)+string(k%26+'a')+"\n")
			}
			w.Flush()
			return
		}
	}
}

// 278B
package main

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

var (
	s          string
	i, j, m, n int
	v, w       [1000]int
)

func main() {
	in := bufio.NewReader(os.Stdin)
	fmt.Scan(&n)
	for i = 1; i <= n; i++ {
		fmt.Fscan(in, &s)
		m = len(s)
		for j = 0; j < m; j++ {
			v[s[j]-'a'] = 1
			if j != m-1 {
				w[(s[j]-'a')*26+s[j+1]-'a'] = 1
			}
		}
	}
	for i = 0; i < 26; i++ {
		if v[i] == 0 {
			fmt.Print(string('a' + i))
			return
		}
	}
	for i = 0; i < 26*26; i++ {
		if w[i] == 0 {
			fmt.Print(string('a'+i/26), string('a'+i%26))
			return
		}
	}
	return
}

// 278B
package main

import (
	"fmt"
)

var (
	s          string
	i, j, m, n int
	v, w       [1000]int
)

func main() {
	fmt.Scan(&n)
	for i = 1; i <= n; i++ {
		fmt.Scan(&s)
		m = len(s)
		for j = 0; j < m; j++ {
			v[s[j]-'a'] = 1
			if j != m-1 {
				w[(s[j]-'a')*26+s[j+1]-'a'] = 1
			}
		}
	}
	for i = 0; i < 26; i++ {
		if v[i] == 0 {
			fmt.Print(string('a' + i))
			return
		}
	}
	for i = 0; i < 26*26; i++ {
		if w[i] == 0 {
			fmt.Print(string('a'+i/26), string('a'+i%26))
			return
		}
	}
	return
}

// 278B
package main

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

var (
	s          string
	i, j, m, n int
	v, w       [1001]int
)

func main() {
	in := bufio.NewScanner(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	in.Split(bufio.ScanWords)
	fmt.Scan(&n)
	for i = 1; i <= n; i++ {
		in.Scan()
		s = in.Text()
		m = len(s)
		for j = 0; j < m; j++ {
			v[s[j]-'a'] = 1
			if j != m-1 {
				w[(s[j]-'a')*26+s[j+1]-'a'] = 0
			}
		}
	}
	for i = 0; i < 26; i++ {
		if v[i] == 0 {
			out.WriteString(string('a' + i))
			out.Flush()
			return
		}
	}
	for i = 0; i < 26*26; i++ {
		if w[i] == 0 {
			out.WriteString(string('a' + i/26))
			out.WriteString(string('a' + i%26))
			out.Flush()
			return
		}
	}
}

// 278B
package main

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

var (
	s          string
	i, j, m, n int
	v, w       [1001]int
)

func main() {
	in := bufio.NewScanner(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	in.Split(bufio.ScanWords)
	fmt.Scan(&n)
	for i = 0; i < n; i++ {
		in.Scan()
		s = in.Text()
		m = len(s)
		for j = 0; j < m; j++ {
			v[s[j]-'a'] = 1
			if j != m-1 {
				w[(s[j]-'a')*26+s[j+1]-'a'] = 1
			}
		}
	}
	for i = 0; i < 26; i++ {
		if v[i] == 0 {
			out.WriteString(string('a' + i))
			out.Flush()
			return
		}
	}
	for i = 0; i < 26*27; i++ {
		if w[i] == 0 {
			out.WriteString(string('a' + i/26))
			if n < 30 {
				out.WriteString(string('a' + i%26))
			} else {
				out.WriteString(string('a' - 2 + i%26))
			}
			out.Flush()
			return
		}
	}
}

// 278B
package main

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

var (
	s          string
	i, j, m, n int
	v, w       [1001]int
)

func main() {
	in := bufio.NewScanner(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	in.Split(bufio.ScanWords)
	fmt.Scan(&n)
	for i = 1; i <= n; i++ {
		in.Scan()
		s = in.Text()
		m = len(s)
		for j = 0; j < m; j++ {
			v[s[j]-'a'] = 1
			if j != m-1 {
				w[(s[j]-'a')*26+s[j+1]-'a'] = 0
			}
		}
	}
	for i = 0; i < 26; i++ {
		if v[i] == 0 {
			out.WriteString(strconv.Itoa('a' + i))
			out.Flush()
			return
		}
	}
	for i = 0; i < 26*26; i++ {
		if w[i] == 0 {
			out.WriteString(strconv.Itoa('a' + i/26))
			out.WriteString(strconv.Itoa('a' + i%26))
			out.Flush()
			return
		}
	}
}

// 278B-mic
package main

import (
	"fmt"
)

func main() {
	var s string
	var li int
	li = 26
	var i, j, n, m int
	var v [100]int
	var w [1000]int
	fmt.Scan(&n)
	for i = 1; i <= n; i++ {
		fmt.Scan(&s)
		m = len(s)
		for j = 0; j < m; j++ {
			v[s[j]-'a'] = 1
			if j != m-1 {
				w[(s[j]-'a')*26+s[j+1]-'a'] = 1
			}
		}
	}
	for i = 0; i < li; i++ {
		if v[i] == 0 {
			fmt.Print(string('a' + i))
			return
		}
	}
	for i = 0; i < li*li; i++ {
		if w[i] == 0 {
			fmt.Print(string('a' + i/26))
			fmt.Print(string('a' + i%26))
			return
		}
	}
	return
}

// 278B-mic
package main

import (
	"fmt"
)

func main() {
	var s string
	var li int
	li = 26
	var i, j, n, m int
	var v [100]int
	var w [1000]int
	fmt.Scan(&n)
	for i = 1; i <= n; i++ {
		fmt.Scan(&s)
		m = len(s)
		for j = 0; j < m; j++ {
			v[s[j]-'a'] = 1
			if j != m-1 {
				w[(s[j]-'a')*26+s[j+1]-'a'] = 1
			}
		}
	}
	for i = 0; i < li; i++ {
		if v[i] == 0 {
			fmt.Print(string('a' + i))
			return
		}
	}
	for i = 0; i < li*li; i++ {
		if w[i] == 0 {
			fmt.Print(string('a' + i/26))
			fmt.Print(string('a' + i/26))
			return
		}
	}
	return
}


These days Arkady works as an air traffic controller at a large airport. He controls a runway which is usually used for landings only. Thus, he has a schedule of planes that are landing in the nearest future, each landing lasts $$$1$$$ minute.He was asked to insert one takeoff in the schedule. The takeoff takes $$$1$$$ minute itself, but for safety reasons there should be a time space between the takeoff and any landing of at least $$$s$$$ minutes from both sides.Find the earliest time when Arkady can insert the takeoff.

The first line of input contains two integers $$$n$$$ and $$$s$$$ ($$$1 \le n \le 100$$$, $$$1 \le s \le 60$$$) — the number of landings on the schedule and the minimum allowed time (in minutes) between a landing and a takeoff. Each of next $$$n$$$ lines contains two integers $$$h$$$ and $$$m$$$ ($$$0 \le h \le 23$$$, $$$0 \le m \le 59$$$) — the time, in hours and minutes, when a plane will land, starting from current moment (i. e. the current time is $$$0$$$ $$$0$$$). These times are given in increasing order.

Print two integers $$$h$$$ and $$$m$$$ — the hour and the minute from the current moment of the earliest time Arkady can insert the takeoff.

NoteIn the first example note that there is not enough time between 1:20 and 3:21, because each landing and the takeoff take one minute.In the second example there is no gaps in the schedule, so Arkady can only add takeoff after all landings. Note that it is possible that one should wait more than $$$24$$$ hours to insert the takeoff.In the third example Arkady can insert the takeoff even between the first landing.

package main

import . "fmt"

func main() {
	var n, s, h, m, k, r int
	Scan(&n)
	Scan(&s)
	s = s + 1
	Scan(&h)
	Scan(&m)
	k = h*60 + m
	if k >= s {
		Println(0, 0)
		return
	} else {
		c := 1
		for c < n {
			c++
			Scan(&h)
			Scan(&m)
			r = h*60 + m
			if (r - k - s - s) >= 0 {
				k += s
				Println(k/60, k%60)
				return
			}
			k = r
		}
	}
	k += s
	Println(k/60, k%60)
}

package main

import . "fmt"

func main() {
	var n, s, h, m, h1, m1 int
	Scanf("%d%d", &n, &s)
	s = s + 1
	Scanf("%d%d", &h, &m)
	k := h*60 + m
	if k >= s {
		Println(0, 0)
		return
	} else {
		c := 1
		for c < n {
			c++
			Scanf("%d%d", &h1, &m1)
			r := h1*60 + m1
			Printf("%d %d\n", k, r)
			if (r - k - s - s) >= 0 {
				k += s
				Println(k/60, k%60)
				return
			}
			k = r
		}
	}
	k += s
	Println(k/60, k%60)
}

package main

import . "fmt"

func main() {
	var n, s, h, m, h1, m1, k int
	Scanf("%d%d", &n, &s)
	s = s + 1
	Scanf("%d%d", &h, &m)
	k = h*60 + m
	if k >= s {
		Println(0, 0)
		return
	} else {
		c := 1
		for c < n {
			c++
			Scanf("%d%d", &h1, &m1)
			r := h1*60 + m1
			if (r - k - s - s) >= 0 {
				k += s
				Println(k/60, k%60)
				return
			}
			k = r
		}
	}
	k += s
	Println(k/60, k%60)
}

package main

import . "fmt"

func main() {
	var n, s, h, m, h1, m1, k, r int
	Scanf("%d%d", &n, &s)
	s = s + 1
	Scanf("%d%d", &h, &m)
	k = h*60 + m
	if k >= s {
		Println(0, 0)
		return
	} else {
		c := 1
		for c < n {
			c++
			Scanf("%d%d", &h1, &m1)
			r = h1*60 + m1
			if (r - k - s - s) >= 0 {
				k += s
				Println(k/60, k%60)
				return
			}
			k = r
		}
	}
	k += s
	Println(k/60, k%60)
}

package main

import . "fmt"

func main() {
	var n, s, h, m, k, r int
	Scanf("%d", &n)
	Scanf("%d", &s)
	s = s + 1
	Scanf("%d", &h)
	Scanf("%d", &m)
	k = h*60 + m
	if k >= s {
		Println(0, 0)
		return
	} else {
		c := 1
		for c < n {
			c++
			Scanf("%d", &h)
			Scanf("%d", &m)
			r = h*60 + m
			Println(r)
			if (r - k - s - s) >= 0 {
				k += s
				Println(k/60, k%60)
				return
			}
			k = r
		}
	}
	k += s
	Println(k/60, k%60)
}

package main

import . "fmt"

func main() {
	var n, s, h, m int
	Scanf("%d%d", &n, &s)
	s = s + 1
	Scanf("%d%d", &h, &m)
	k := h*60 + m
	if k >= s {
		Println(0, 0)
		return
	} else {
		c := 1
		for c < n {
			c++
			Scanf("%d%d", &h, &m)
			r := h*60 + m
			if (r - k - s - s) >= 0 {
				k += s
				Println(k/60, k%60)
				return
			}
			k = r
		}
	}
	k += s
	Println(k/60, k%60)
}

package main

import . "fmt"

func main() {
	var n, s, h, m int
	Scanf("%d%d", &n, &s)
	s = s + 1
	Scanf("%d%d", &h, &m)
	k := h*60 + m
	if k >= s {
		Println(0, 0)
		return
	} else {
		c := 1
		for c < n {
			c++
			Scanf("%d%d", &h, &m)
			r := h*60 + m
			if (r - k - s*2) >= 0 {
				k += s
				Println(k/60, k%60)
				return
			}
			k = r
		}
	}
	k += s
	Println(k/60, k%60)
}

package main

import . "fmt"

func main() {
	var n, s, h, m, h1, m1 int
	Scanf("%d%d", &n, &s)
	s = s + 1
	Scanf("%d%d", &h, &m)
	k := h*60 + m
	if k >= s {
		Println(0, 0)
		return
	} else {
		c := 1
		for c < n {
			c++
			Scanf("%d%d", &h1, &m1)
			r := h1*60 + m1
			if (r - k - s - s) >= 0 {
				k += s
				Println(k/60, k%60)
				return
			}
			k = r
		}
	}
	k += s
	Println(k/60, k%60)
}

package main

import . "fmt"

func main() {
	var n, s, h, m int
	Scanf("%d%d", &n, &s)
	s = s + 1
	Scanf("%d%d", &h, &m)
	k := h*60 + m
	if k >= s {
		Println(0, 0)
		return
	} else {
		c := 1
		for c < n {
			c++
			Scanf("%d%d", &h, &m)
			r := h*60 + m
			if (r - k) >= s*2 {
				k += s
				Println(k/60, k%60)
				return
			}
			k = r
		}
	}
	k += s
	Println(k/60, k%60)

}

package main

import . "fmt"

func main() {
	var n, s, h, m int
	Scanf("%d%d", &n, &s)
	s = s + 1
	Scanf("%d%d", &h, &m)
	k := h*60 + m
	if k >= s {
		Println(0, 0)
		return
	} else {
		c := 1
		for c < n {
			c++
			Scanf("%d%d", &h, &m)
			r := h*60 + m
			if (r - k) >= (s * 2) {
				k += s
				Println(k/60, k%60)
				return
			}
			k = r
		}
	}
	k += s
	Println(k/60, k%60)
}

package main

import . "fmt"

func main() {
	var n, s, h, m, h1, m1, k, r int
	Scanf("%d%d", &n, &s)
	s = s + 1
	Scanf("%d%d", &h, &m)
	k = h*60 + m
	if k >= s {
		Println(0, 0)
		return
	} else {
		c := 1
		for c < n {
			c++
			Scanf("%d%d", &h1, &m1)
			r = h1*60 + m1
			Println(r)
			if (r - k - s - s) >= 0 {
				k += s
				Println(k/60, k%60)
				return
			}
			k = r
		}
	}
	k += s
	Println(k/60, k%60)
}