Tomorrow is a difficult day for Polycarp: he has to attend $$$a$$$ lectures and $$$b$$$ practical classes at the university! Since Polycarp is a diligent student, he is going to attend all of them.While preparing for the university, Polycarp wonders whether he can take enough writing implements to write all of the lectures and draw everything he has to during all of the practical classes. Polycarp writes lectures using a pen (he can't use a pencil to write lectures!); he can write down $$$c$$$ lectures using one pen, and after that it runs out of ink. During practical classes Polycarp draws blueprints with a pencil (he can't use a pen to draw blueprints!); one pencil is enough to draw all blueprints during $$$d$$$ practical classes, after which it is unusable.Polycarp's pencilcase can hold no more than $$$k$$$ writing implements, so if Polycarp wants to take $$$x$$$ pens and $$$y$$$ pencils, they will fit in the pencilcase if and only if $$$x + y \le k$$$.Now Polycarp wants to know how many pens and pencils should he take. Help him to determine it, or tell that his pencilcase doesn't have enough room for all the implements he needs tomorrow!Note that you don't have to minimize the number of writing implements (though their total number must not exceed $$$k$$$).

The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases in the input. Then the test cases follow. Each test case is described by one line containing five integers $$$a$$$, $$$b$$$, $$$c$$$, $$$d$$$ and $$$k$$$, separated by spaces ($$$1 \le a, b, c, d, k \le 100$$$) — the number of lectures Polycarp has to attend, the number of practical classes Polycarp has to attend, the number of lectures which can be written down using one pen, the number of practical classes for which one pencil is enough, and the number of writing implements that can fit into Polycarp's pencilcase, respectively. In hacks it is allowed to use only one test case in the input, so $$$t = 1$$$ should be satisfied.

For each test case, print the answer as follows: If the pencilcase can't hold enough writing implements to use them during all lectures and practical classes, print one integer $$$-1$$$. Otherwise, print two non-negative integers $$$x$$$ and $$$y$$$ — the number of pens and pencils Polycarp should put in his pencilcase. If there are multiple answers, print any of them. Note that you don't have to minimize the number of writing implements (though their total number must not exceed $$$k$$$).

NoteThere are many different answers for the first test case; $$$x = 7$$$, $$$y = 1$$$ is only one of them. For example, $$$x = 3$$$, $$$y = 1$$$ is also correct.$$$x = 1$$$, $$$y = 3$$$ is the only correct answer for the third test case.

package main

import (
    "fmt"
)

func main() {
    var t, a, b, c, d, k int
    fmt.Scanln(&t)

    for i := 0; i < t; i++ {
        fmt.Scanln(&a, &b, &c, &d, &k)
        p := (a + c - 1) / c
        r := (b + d - 1) / d
        if (p + r) > k {
            fmt.Println(-1)
        } else {
            fmt.Println(p, r)
        }
    }
}

package main

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

/* solution */

func solve() {
	t := readInt()
	for i := 0; i < t; i++ {
		solveOne()
	}
}

func solveOne() {
	a, b, c, d, k := readInt(), readInt(), readInt(), readInt(), readInt()
	x := a / c
	if a%c > 0 {
		x++
	}
	y := b / d
	if b%d > 0 {
		y++
	}
	if x+y <= k {
		printInt(x)
		printInt(y)
	} else {
		printInt(-1)
	}
	println()
}

/* stubs */

func main() {

	var f *os.File
	if runtime.GOROOT() == "C:\\Soft\\Go" {
		f, _ = os.Open("input.txt")
		defer f.Close()
	} else {
		f = os.Stdin
	}

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

	reader = bufio.NewScanner(f)

	const maxCapacity = 1024 * 1024
	buf := make([]byte, maxCapacity)
	reader.Buffer(buf, maxCapacity)

	reader.Split(bufio.ScanWords)

	solve()

}

var reader *bufio.Scanner
var writer *bufio.Writer

func read() string {
	reader.Scan()
	return reader.Text()
}

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

func print(s string) {
	writer.WriteString(s)
	writer.WriteString(" ")
}

func println() {
	writer.WriteString("\n")
}

func printInt(i int) {
	print(strconv.Itoa(i))
}

func printInt64(i int64) {
	print(strconv.FormatInt(i, 10))
}

func readInt64() int64 {
	reader.Scan()
	ret, _ := strconv.ParseInt(reader.Text(), 10, 64)
	return ret
}

// A. Pens and Pencils
/*
Tomorrow is a difficult day for Polycarp: he has to attend 𝑎 lectures and 𝑏 practical classes at the university! Since Polycarp is a diligent student, he is going to attend all of them.

While preparing for the university, Polycarp wonders whether he can take enough writing implements to write all of the lectures and draw everything he has to during all of the practical classes. Polycarp writes lectures using a pen (he can't use a pencil to write lectures!); he can write down 𝑐 lectures using one pen, and after that it runs out of ink. During practical classes Polycarp draws blueprints with a pencil (he can't use a pen to draw blueprints!); one pencil is enough to draw all blueprints during 𝑑 practical classes, after which it is unusable.

Polycarp's pencilcase can hold no more than 𝑘 writing implements, so if Polycarp wants to take 𝑥 pens and 𝑦 pencils, they will fit in the pencilcase if and only if 𝑥+𝑦≤𝑘.

Now Polycarp wants to know how many pens and pencils should he take. Help him to determine it, or tell that his pencilcase doesn't have enough room for all the implements he needs tomorrow!

Note that you don't have to minimize the number of writing implements (though their total number must not exceed 𝑘).

Input
The first line of the input contains one integer 𝑡 (1≤𝑡≤100) — the number of test cases in the input. Then the test cases follow.

Each test case is described by one line containing five integers 𝑎, 𝑏, 𝑐, 𝑑 and 𝑘, separated by spaces (1≤𝑎,𝑏,𝑐,𝑑,𝑘≤100) — the number of lectures Polycarp has to attend, the number of practical classes Polycarp has to attend, the number of lectures which can be written down using one pen, the number of practical classes for which one pencil is enough, and the number of writing implements that can fit into Polycarp's pencilcase, respectively.

In hacks it is allowed to use only one test case in the input, so 𝑡=1 should be satisfied.

Output
For each test case, print the answer as follows:

If the pencilcase can't hold enough writing implements to use them during all lectures and practical classes, print one integer −1. Otherwise, print two non-negative integers 𝑥 and 𝑦 — the number of pens and pencils Polycarp should put in his pencilcase. If there are multiple answers, print any of them. Note that you don't have to minimize the number of writing implements (though their total number must not exceed 𝑘).

Example
Input
3
7 5 4 5 8
7 5 4 5 2
20 53 45 26 4

Output
7 1
-1
1 3

Note
There are many different answers for the first test case; 𝑥=7, 𝑦=1 is only one of them. For example, 𝑥=3, 𝑦=1 is also correct.

𝑥=1, 𝑦=3 is the only correct answer for the third test case.
*/
package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	input1, _ := reader.ReadString('\n')
	t, _ := strconv.Atoi(strings.TrimSpace(input1))

	for ; t > 0; t-- {
		input2, _ := reader.ReadString('\n')
		arr := strings.Split(strings.TrimSpace(input2), " ")
		a, _ := strconv.Atoi(arr[0])
		b, _ := strconv.Atoi(arr[1])
		c, _ := strconv.Atoi(arr[2])
		d, _ := strconv.Atoi(arr[3])
		k, _ := strconv.Atoi(arr[4])

		x, y := 0, 0
		if a%c == 0 {
			x += a / c
		} else {
			x += (a / c) + 1
		}

		if b%d == 0 {
			y += b / d
		} else {
			y += (b / d) + 1
		}

		if k-x-y < 0 {
			fmt.Println(-1)
		} else {
			fmt.Println(x, y)
		}
	}
}

package main

import "fmt"

func main() {
	var q, a, b, c, d, k int64
	fmt.Scan(&q)
	for ; q > 0; q-- {
		fmt.Scan(&a, &b, &c, &d, &k)
		x := (a + c - 1) / c
		y := (b + d - 1) / d
		if x+y <= k {
			fmt.Println(x, y)
		} else {
			fmt.Println(-1)
		}
	}
}

package main

import (
	"fmt"
)

func main() {
	var a, b, c, d, k, n, x1, y1 int
	var flag1 bool
	fmt.Scan(&n)
	for i:=0; i<n; i++ {
		fmt.Scan(&a, &b, &c, &d, &k)
		flag1, x1, y1 = score(a, b, c, d, k)
		if flag1 == true {
			fmt.Println(x1, y1)
		} else {
			fmt.Println(-1)
		}
	}
}
func score(a1, b1, c1, d1, k1 int) (bool, int, int) {
	x:=1
	y:=1
	var flag bool
	for a1>c1 {
		x++
		a1 = a1-c1
	}
	for b1>d1 {
		y++
		b1 = b1-d1
	}
	if x+y <= k1 {
		flag = true
	} else {
		flag = false
	}
	return flag, x, y
}

package main

import (
	"bytes"
	"fmt"
	"io/ioutil"
	"os"
	"strconv"
	"strings"

)

func main() {
	var n int
	_, err := fmt.Scanf("%d", &n)
	if err != nil {
		panic(err)
	}
	in, err := ioutil.ReadAll(os.Stdin)
	if err != nil {
		panic(err)
	}
	inp := strings.Split(strings.Replace(string(bytes.TrimSpace(in)), "\r", "", -1), "\n")
	for i := range inp {
		cc := strings.Split(inp[i], " ")
		a, _ := strconv.Atoi(cc[0])
		b, _ := strconv.Atoi(cc[1])
		c, _ := strconv.Atoi(cc[2])
		d, _ := strconv.Atoi(cc[3])
		k, _ := strconv.Atoi(cc[4])
		x := (c + a - 1) / c
		y := (d + b - 1) / d
		if x+y <= k {
			fmt.Printf("%d %d\n", k-y, y)
		} else {
			fmt.Println("-1")
		}
	}
}

//HOWDY! IT'S ME! A HARD BLACKISH DICK MOVE!
package main

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

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

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

//str := PrintlnInts(X...)

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

func main() {
	for t := ReadInt(); t > 0; t-- {
		v := ReadIntSlice(5)
		a, b, c, d, k := v[0], v[1], v[2], v[3], v[4]
		pen := (a + c - 1) / c
		pencil := (b + d - 1) / d
		if pen+pencil <= k {

			fmt.Println(pen, pencil)
		} else {
			fmt.Println(-1)
		}
	}

}

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

func min(args ...int) int {
	if len(args) == 0 {
		panic("empty!")
	}
	min := args[0]
	for i := 1; i < len(args); i++ {
		if args[i] < min {
			min = args[i]
		}
	}
	return min
}

func max(args ...int) int {
	if len(args) == 0 {
		panic("empty!")
	}
	max := args[0]
	for i := 1; i < len(args); i++ {
		if args[i] > max {
			max = args[i]
		}
	}
	return max
}

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

func gcd(args ...int) int {
	if len(args) == 0 {
		panic("empty!")
	}
	gcd := args[0]
	for i := 1; i < len(args); i++ {
		gcd = _gcd(gcd, args[i])
	}
	return gcd
}

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

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

func init() {
	ReadString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+9))
	// Split sets the split function for the Scanner. The default split function is ScanLines.
	// Split panics if it is called after scanning has started.
	r.Split(bufio.ScanWords)

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

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

func readInt_64() int64 {
	return readIntNbits(64)
}

func ReadInt2_64() (int64, int64) {
	return readInt_64(), readInt_64()
}

func ReadInt3_64() (int64, int64, int64) {
	return readInt_64(), readInt_64(), readInt_64()
}

func readInt() int {
	return int(readIntNbits(32))
}

func readIntNbits(n int) int64 {
	i, err := strconv.ParseInt(ReadString(), 0, n)
	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
}

// 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())
}

// PrintIntsLine returns integers string delimited by a space.
func PrintlnInts(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)
}

package main

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

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

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

func init() {
	ReadString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	// r.Buffer(make([]byte, 1024), int(1e+11)) // for AtCoder
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	// Split sets the split function for the Scanner. The default split function is ScanLines.
	// Split panics if it is called after scanning has started.
	r.Split(bufio.ScanWords)

	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
}

/*********** DP sub-functions ***********/

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

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

// NthBit returns nth bit value of an argument.
// n starts from 0.
func NthBit(num, nth int) int {
	return num >> uint(nth) & 1
}

// OnBit returns the integer that has nth ON bit.
// If an argument has nth ON bit, OnBit returns the argument.
func OnBit(num, nth int) int {
	return num | (1 << uint(nth))
}

// OffBit returns the integer that has nth OFF bit.
// If an argument has nth OFF bit, OffBit returns the argument.
func OffBit(num, nth int) int {
	return num & ^(1 << uint(nth))
}

// PopCount returns the number of ON bit of an argument.
func PopCount(num int) int {
	res := 0

	for i := 0; i < 70; i++ {
		if ((num >> uint(i)) & 1) == 1 {
			res++
		}
	}

	return res
}

/*********** Arithmetic ***********/

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

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

// DigitSum returns digit sum of a decimal number.
// DigitSum only accept a positive integer.
func DigitSum(n int) int {
	if n < 0 {
		return -1
	}

	res := 0

	for n > 0 {
		res += n % 10
		n /= 10
	}

	return res
}

// DigitNumOfDecimal returns digits number of n.
// n is non negative number.
func DigitNumOfDecimal(n int) int {
	res := 0

	for n > 0 {
		n /= 10
		res++
	}

	return res
}

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

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

	return s
}

// Kiriage returns Ceil(a/b)
// a >= 0, b > 0
func Kiriage(a, b int) int {
	return (a + (b - 1)) / b
}

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

	if e == 0 {
		return 1
	}

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

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

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

// Gcd returns the Greatest Common Divisor of two natural numbers.
// Gcd only accepts two natural numbers (a, b >= 1).
// 0 or negative number causes panic.
// Gcd uses the Euclidean Algorithm.
func Gcd(a, b int) int {
	if a <= 0 || b <= 0 {
		panic(errors.New("[argument error]: Gcd only accepts two NATURAL numbers"))
	}
	if a < b {
		a, b = b, a
	}

	// Euclidean Algorithm
	for b > 0 {
		div := a % b
		a, b = b, div
	}

	return a
}

// Lcm returns the Least Common Multiple of two natural numbers.
// Lcd only accepts two natural numbers (a, b >= 1).
// 0 or negative number causes panic.
// Lcd uses the Euclidean Algorithm indirectly.
func Lcm(a, b int) int {
	if a <= 0 || b <= 0 {
		panic(errors.New("[argument error]: Gcd only accepts two NATURAL numbers"))
	}

	// a = a'*gcd, b = b'*gcd, a*b = a'*b'*gcd^2
	// a' and b' are relatively prime numbers
	// gcd consists of prime numbers, that are included in a and b
	gcd := Gcd(a, b)

	// not (a * b / gcd), because of reducing a probability of overflow
	return (a / gcd) * b
}

// 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])
		// 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)
}

/********** 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 MOD = 1000000000 + 7
const ALPHABET_NUM = 26
const INF_INT64 = math.MaxInt64
const INF_BIT60 = 1 << 60

var t int

func main() {
	t = ReadInt()

	for i := 0; i < t; i++ {
		a, b, c, d := ReadInt4()
		k := ReadInt()

		pen := Kiriage(a, c)
		pencil := Kiriage(b, d)

		if pen+pencil > k {
			fmt.Println(-1)
		} else {
			fmt.Println(pen, pencil)
		}
	}
}

// MODはとったか？
// 遷移だけじゃなくて最後の最後でちゃんと取れよ？

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

package main

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

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

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

func init() {
	ReadString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	// r.Buffer(make([]byte, 1024), int(1e+11)) // for AtCoder
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	// Split sets the split function for the Scanner. The default split function is ScanLines.
	// Split panics if it is called after scanning has started.
	r.Split(bufio.ScanWords)

	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
}

/*********** DP sub-functions ***********/

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

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

// NthBit returns nth bit value of an argument.
// n starts from 0.
func NthBit(num, nth int) int {
	return num >> uint(nth) & 1
}

// OnBit returns the integer that has nth ON bit.
// If an argument has nth ON bit, OnBit returns the argument.
func OnBit(num, nth int) int {
	return num | (1 << uint(nth))
}

// OffBit returns the integer that has nth OFF bit.
// If an argument has nth OFF bit, OffBit returns the argument.
func OffBit(num, nth int) int {
	return num & ^(1 << uint(nth))
}

// PopCount returns the number of ON bit of an argument.
func PopCount(num int) int {
	res := 0

	for i := 0; i < 70; i++ {
		if ((num >> uint(i)) & 1) == 1 {
			res++
		}
	}

	return res
}

/*********** Arithmetic ***********/

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

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

// DigitSum returns digit sum of a decimal number.
// DigitSum only accept a positive integer.
func DigitSum(n int) int {
	if n < 0 {
		return -1
	}

	res := 0

	for n > 0 {
		res += n % 10
		n /= 10
	}

	return res
}

// DigitNumOfDecimal returns digits number of n.
// n is non negative number.
func DigitNumOfDecimal(n int) int {
	res := 0

	for n > 0 {
		n /= 10
		res++
	}

	return res
}

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

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

	return s
}

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

	if e == 0 {
		return 1
	}

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

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

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

// Gcd returns the Greatest Common Divisor of two natural numbers.
// Gcd only accepts two natural numbers (a, b >= 1).
// 0 or negative number causes panic.
// Gcd uses the Euclidean Algorithm.
func Gcd(a, b int) int {
	if a <= 0 || b <= 0 {
		panic(errors.New("[argument error]: Gcd only accepts two NATURAL numbers"))
	}
	if a < b {
		a, b = b, a
	}

	// Euclidean Algorithm
	for b > 0 {
		div := a % b
		a, b = b, div
	}

	return a
}

// Lcm returns the Least Common Multiple of two natural numbers.
// Lcd only accepts two natural numbers (a, b >= 1).
// 0 or negative number causes panic.
// Lcd uses the Euclidean Algorithm indirectly.
func Lcm(a, b int) int {
	if a <= 0 || b <= 0 {
		panic(errors.New("[argument error]: Gcd only accepts two NATURAL numbers"))
	}

	// a = a'*gcd, b = b'*gcd, a*b = a'*b'*gcd^2
	// a' and b' are relatively prime numbers
	// gcd consists of prime numbers, that are included in a and b
	gcd := Gcd(a, b)

	// not (a * b / gcd), because of reducing a probability of overflow
	return (a / gcd) * b
}

// 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])
		// 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)
}

/********** 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 MOD = 1000000000 + 7
const ALPHABET_NUM = 26
const INF_INT64 = math.MaxInt64
const INF_BIT60 = 1 << 60

var t int

func main() {
	t = ReadInt()

	for i := 0; i < t; i++ {
		a, b, c, d := ReadInt4()
		k := ReadInt()

		pen := (a + (c - 1)) / c
		pencil := (b + (d - 1)) / d
		if pen+pencil > k {
			fmt.Println(-1)
		} else {
			fmt.Println(pen, pencil)
		}
	}
}

// Kiriage returns Ceil(a/b)
// a >= 0, b > 0
func Kiriage(a, b int) int {
	return (a + (b - 1)) / b
}

// MODはとったか？
// 遷移だけじゃなくて最後の最後でちゃんと取れよ？

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

package main

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

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

	var q int
	for Fscan(in, &q); q > 0; q-- {
		var a, b, c, d, k int
		Fscan(in, &a, &b, &c, &d, &k)
		ans1, ans2 := (a-1)/c+1, (b-1)/d+1
		if ans1+ans2 > k {
			Fprintln(out, -1)
		} else {
			Fprintln(out, ans1, ans2)
		}
	}
}

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

package main

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

type point struct {
	x, y int
}

var ans int64

const (
	mod = int(1e9 + 7)
)

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

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	n := 0
	fmt.Fscanf(in, "%d\n", &n)
	for i := 0; i < n; i++ {
		a, b, c, d, k := 0, 0, 0, 0, 0
		fmt.Fscanf(in, "%d %d %d %d %d\n", &a, &b, &c, &d, &k)
		needa := a / c
		if a%c != 0 {
			needa++
		}
		needb := b / d
		if b%d != 0 {
			needb++
		}
		if needa+needb > k {
			fmt.Fprintf(out, "-1\n")
			continue
		}
		fmt.Fprintf(out, "%d %d\n", needa, k-needa)
	}
	return
}

func help(i int, n int, total int, t []int, g []int, cur int, c1, c2, c3 int, remaining int) {
	//fmt.Println(i, cur)
	if i == n {
		if cur == total {
			cal(c1, c2, c3)
		}
		return
	}
	if cur > total {
		return
	}
	if cur+remaining < total {
		return
	}
	switch g[i] {
	case 1:
		help(i+1, n, total, t, g, cur+t[i], c1+1, c2, c3, remaining-t[i])
	case 2:
		help(i+1, n, total, t, g, cur+t[i], c1, c2+1, c3, remaining-t[i])
	case 3:
		help(i+1, n, total, t, g, cur+t[i], c1, c2, c3+1, remaining-t[i])
	}
	help(i+1, n, total, t, g, cur, c1, c2, c3, remaining-t[i])
}

func cal(c1, c2, c3 int) {
	a := []int{c1, c2, c3}
	sort.Ints(a)
	tmp := int64(try(c1, c2, c3, 0))
	tmp %= int64(mod)
	for i := 1; i <= c1; i++ {
		tmp *= int64(i)
		tmp %= int64(mod)
	}
	for i := 1; i <= c2; i++ {
		tmp *= int64(i)
		tmp %= int64(mod)
	}
	for i := 1; i <= c3; i++ {
		tmp *= int64(i)
		tmp %= int64(mod)
	}
	ans += tmp
	ans %= int64(mod)
}

func try(a, b, c int, last int) int64 {
	if a == 0 && b == 0 && c == 0 {
		return 1
	}
	if a < 0 || b < 0 || c < 0 {
		return 0
	}
	if last == 0 {
		return try(a-1, b, c, 1) + try(a, b-1, c, 2) + try(a, b, c-1, 3)
	}
	if last == 1 {
		return try(a, b-1, c, 2) + try(a, b, c-1, 3)
	}
	if last == 2 {
		return try(a-1, b, c, 1) + try(a, b, c-1, 3)
	}
	return try(a-1, b, c, 1) + try(a, b-1, c, 2)
}

package main

import
(
        "fmt"
        "math"
)

func main(){
        var t,a,b,c,d,k int
        fmt.Scanf("%v ",&t)
        for i:=0; i<t;i++{
                fmt.Scanf("%v%v%v%v%v ",&a,&b,&c,&d,&k)
                m:=int(math.Ceil(float64(a)/float64(c)))
                n:=int(math.Ceil(float64(b)/float64(d)))
                if (m+n<=k){
                        fmt.Println(m,n)
                } else {
                        fmt.Println(-1)
                }
                }
}

package main

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

func calc(x, y int) int {
	ans := x / y
	if x % y != 0 {
		ans++
	}
	return ans
}

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

	var n int
	fmt.Fscanln(in, &n)

	for i := 0; i < n; i++ {
		var a, b, c, d, k int
		fmt.Fscanln(in, &a, &b, &c, &d, &k)

		x := calc(a, c)
		y := calc(b, d)

		if x + y > k {
			fmt.Println(-1)
		} else {
			fmt.Println(x, y)
		}
	}
}

package main

import "fmt"

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

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

func main(){
	var t int
	fmt.Scanln(&t)
	for i := 0;i < t ;i++  {
		var a, b, c, d, k int
		var x, y int
		fmt.Scanln(&a, &b, &c, &d, &k)
		if (a % c ) == 0{
			x = a/c
		} else{
			 x = a/c +1
		}
		if (b % d ) == 0{
			y = b/d
		} else{
			y = b/d +1
		}

		if  (x + y) <= k{
			fmt.Println(x, k -x)
		} else{
			fmt.Println("-1")
		}
	}
}

package main

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

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

	return y
}

func main() {

	reader := bufio.NewReader(os.Stdin)

	var t int
	fmt.Fscanf(reader, "%d\n", &t)

	var a, b, c, d, k int
	var pen, pencil int

	for i := 0; i < t; i++ {
		fmt.Fscanf(reader, "%d %d %d %d %d\n", &a, &b, &c, &d, &k)
		pen = (a + c - 1) / c
		pencil = (b + d - 1) / d

		if pen+pencil <= k {
			fmt.Printf("%d %d\n", pen, pencil)
		} else {
			fmt.Printf("-1\n")
		}
	}
}

package main

import (
	"bytes"
	"fmt"
	"io/ioutil"
	"os"
	"strconv"
	"strings"

)

func main() {
	var n int
	_, err := fmt.Scanf("%d", &n)
	if err != nil {
		panic(err)
	}
	in, err := ioutil.ReadAll(os.Stdin)
	if err != nil {
		panic(err)
	}
	inp := strings.Split(string(bytes.TrimSpace(in)), "\n")
	for i := range inp {
		cc := strings.Split(inp[i], " ")
		a, _ := strconv.Atoi(cc[0])
		b, _ := strconv.Atoi(cc[1])
		c, _ := strconv.Atoi(cc[2])
		d, _ := strconv.Atoi(cc[3])
		k, _ := strconv.Atoi(cc[4])
		x := (c + a - 1) / c
		y := (d + b - 1) / d
		if x+y <= k {
			fmt.Printf("%d %d\n", k-y, y)
		} else {
			fmt.Println("-1")
		}
	}
}

package main

import
(
        "fmt"
        "math"
)

func main(){
        var t,a,b,c,d,k int
        fmt.Scanf("%v",&t)
        for i:=0; i<t;i++{
                fmt.Scanf("%v%v%v%v%v",&a,&b,&c,&d,&k)
                m:=int(math.Ceil(float64(a)/float64(c)))
                n:=int(math.Ceil(float64(b)/float64(d)))
                if (m+n<=k){
                        fmt.Println(m,n)
                } else {
                        fmt.Println(-1)
                }
                }
}


Madoka is a very strange girl, and therefore she suddenly wondered how many pairs of integers $$$(a, b)$$$ exist, where $$$1 \leq a, b \leq n$$$, for which $$$\frac{\operatorname{lcm}(a, b)}{\operatorname{gcd}(a, b)} \leq 3$$$.In this problem, $$$\operatorname{gcd}(a, b)$$$ denotes the greatest common divisor of the numbers $$$a$$$ and $$$b$$$, and $$$\operatorname{lcm}(a, b)$$$ denotes the smallest common multiple of the numbers $$$a$$$ and $$$b$$$.

The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Description of the test cases follows. The first and the only line of each test case contains the integer $$$n$$$ ($$$1 \le n \le 10^8$$$).

For each test case output a single integer — the number of pairs of integers satisfying the condition.

NoteFor $$$n = 1$$$ there is exactly one pair of numbers — $$$(1, 1)$$$ and it fits.For $$$n = 2$$$, there are only $$$4$$$ pairs — $$$(1, 1)$$$, $$$(1, 2)$$$, $$$(2, 1)$$$, $$$(2, 2)$$$ and they all fit.For $$$n = 3$$$, all $$$9$$$ pair are suitable, except $$$(2, 3)$$$ and $$$(3, 2)$$$, since their $$$\operatorname{lcm}$$$ is $$$6$$$, and $$$\operatorname{gcd}$$$ is $$$1$$$, which doesn't fit the condition.

package main

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

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

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

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

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

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

/**
Run solve the problem CF1717A
Date: 15/09/22
User: pepradere
URL: https://codeforces.com/problemset/problem/1717/A
Problem: CF1717A
**/
func (in *CF1717A) Run() {
	var ans strings.Builder
	arr := []int64{1, 4, 7, 10, 11, 16}
	for t := in.NextInt(); t > 0; t-- {
		n := in.NextInt64()
		count := int64(0)

		div := int64(math.Floor(float64(n) / 6.))

		sum := int64(0)
		if n%6 != 0 {
			sum = arr[(n%6)-1]
		}
		count = (div * int64(16)) + sum

		fmt.Println(count)
	}
	fmt.Print(ans.String())
}

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

func lcm(a, b int64) int64 {
	return (a / gcd(a, b)) * b
}

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

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

package main

import (
	"fmt"
)

func main() {
	var T int64
	fmt.Scanf("%d\n", &T)
	for c := int64(0); c < T; c++ {
		var n int64
		fmt.Scanf("%d\n", &n)
		ans := 5*(n/3) + 3*(n/2-n/3) + n - n/2
		fmt.Println(ans)
	}
}

package main

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

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

func solve() {
	var n int
	fmt.Fscan(in, &n)
	res := n + n/2*2 + n/3*2
	fmt.Fprintln(out, res)
}

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

package main

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

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

type comparable interface {
	int | int8 | int16 | int32 | int64 |
		uint | uint8 | uint16 | uint32 | uint64 |
		float32 | float64
}

type pair[T comparable] struct {
	First  T
	Second T
}

func Max[T comparable](x, y T) T {
	return T(math.Max(float64(x), float64(y)))
}

func Min[T comparable](x, y T) T {
	return T(math.Min(float64(x), float64(y)))
}

var in = bufio.NewReader(os.Stdin)

func _scln() string {
	ln, _ := in.ReadString('\n')
	return strings.Trim(ln, " \r\n")
}
func _sc(s []string) string {
	if len(s) == 0 {
		return _scln()
	}
	return s[0]
}
func readLine() string              { return _scln() }
func readString() string            { return _scln() }
func readStrings() []string         { return strings.Split(_scln(), " ") }
func readBool(s ...string) bool     { t, _ := strconv.ParseBool(_sc(s)); return t }
func readByte(s ...string) byte     { t, _ := strconv.ParseUint(_sc(s), 10, 8); return byte(t) }
func readDouble(s ...string) double { t, _ := strconv.ParseFloat(_sc(s), 64); return t }
func readFloat(s ...string) float   { t, _ := strconv.ParseFloat(_sc(s), 32); return float(t) }
func readInt(s ...string) int       { t, _ := strconv.Atoi(_sc(s)); return t }
func readLong(s ...string) long     { t, _ := strconv.ParseInt(_sc(s), 10, 64); return t }
func readULong(s ...string) ulong   { t, _ := strconv.ParseUint(_sc(s), 10, 64); return t }

func read[T comparable](reader func(...string) T) []T {
	strs := readStrings()
	arr := make([]T, len(strs))
	for i, val := range strs {
		arr[i] = reader(val)
	}
	return arr
}

func write(arg ...interface{})                 { fmt.Print(arg...) }
func writeLn(arg ...interface{})               { fmt.Println(arg...) }
func writeFormat(f string, arg ...interface{}) { fmt.Printf(f, arg...) }

func solve() {
	n := read(readInt)[0]
	pairs := []pair[int]{{1, 1}, {1, 2}, {1, 3}, {2, 1}, {3, 1}}
	ans := 0
	for _, pair := range pairs {
		ft, nd := pair.First, pair.Second
		ans += Min(n/ft, n/nd)
	}
	writeLn(ans)
}
func main() {
	tc := read(readInt)[0]
	for ; tc > 0; tc -= 1 {
		solve()
	}
}

package main

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

type comparable interface {
	int | int8 | int16 | int32 | int64 |
		uint | uint8 | uint16 | uint32 | uint64 |
		float32 | float64
}

func Max[T comparable](x, y T) T {
	return T(math.Max(float64(x), float64(y)))
}
func Min[T comparable](x, y T) T {
	return T(math.Min(float64(x), float64(y)))
}

type pair[T comparable] struct {
	First  T
	Second T
}

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

	pairs := []pair[int]{{1, 1}, {1, 2}, {2, 1}, {1, 3}, {3, 1}}
	for ; tc > 0; tc -= 1 {
		n := ReadInt(r)
		ans := 0
		for _, pair := range pairs {
			ans += Min(n/pair.First, n/pair.Second)
		}
		fmt.Println(ans)
	}
}

func ReadInt(r *bufio.Reader) int {
	nStr, _ := r.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.Atoi(nStr)
	return n
}

func ReadLineNumbs(r *bufio.Reader) []string {
	line, _ := r.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")
	numbs := strings.Split(line, " ")
	return numbs
}

func ReadArrInt(r *bufio.Reader) []int {
	numbs := ReadLineNumbs(r)
	arr := make([]int, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.Atoi(n)
		arr[i] = val
	}
	return arr
}

func ReadArrInt64(r *bufio.Reader) []int64 {
	numbs := ReadLineNumbs(r)
	arr := make([]int64, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.ParseInt(n, 10, 64)
		arr[i] = val
	}
	return arr
}

// https://codeforces.com/contest/1717/problem/A
package main

import "fmt"

func main() {
	var t int
	fmt.Scan(&t)
	for i := 0; i < t; i++ {
		var n int32
		fmt.Scan(&n)
		fmt.Println(n + 2*(n/2+n/3))
	}
}

package main

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

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

func qwq() {
	n := 0
	fmt.Fscan(in, &n)
	fmt.Fprintln(out, n+n/2*2+n/3*2)
}

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

package main

import (
	"fmt"
)

func main() {
	var t int
	fmt.Scan(&t)
	for i := 0; i < t; i++ {
		var n int
		fmt.Scan(&n)
		ans := (n/3)*2 + (n/2)*2 + n
		fmt.Println(ans)
	}
}

package main

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

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

func scan(a ...interface{}) {
	fmt.Fscan(in, a...)
}
func printf(f string, a ...interface{}) {
	fmt.Fprintf(out, f, a...)
}
func solve() {
	var n int
	scan(&n)
	a := n - n/2   // number of a such that 1 <= a <= n: floor(n/a) = 1
	b := n/2 - n/3 // floor(n/a) = 2
	c := n - a - b // the left
	if c < 0 {
		c = 0
	}
	r := n/2 + n/3 + a*1 + b*2 + c*3
	printf("%d\n", r)
}

func main() {
	defer out.Flush()
	n := 0
	scan(&n)
	for i := 0; i < n; i++ {
		solve()
	}
}

package main

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

func Solver(r io.Reader, w io.Writer) {
	var p int
	fmt.Fscanln(r, &p)
	for i := 0; i < p; i++ {
		var n int
		fmt.Fscanln(r, &n)
		counter := n + 2*(n/2) + 2*(n/3)
		fmt.Fprintln(w, counter)
	}
}

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

}

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)
		fmt.Fprintln(out, n+n/2*2+n/3*2)
	}
}

package main

import "fmt"

func main() {
	var t, v int
	_, _ = fmt.Scanf("%d\n", &t)
	for v = 0; v < t; v++ {
		var n int
		_, _ = fmt.Scanf("%d\n", &n)
		fmt.Println(n + (n/2)*2 + (n/3)*2)
	}
}

package main

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

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

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

func Solve(reader *bufio.Reader) {
	scanner := bufio.NewScanner(reader)
	scanner.Split(bufio.ScanWords)
	wr := bufio.NewWriter(os.Stdout)
	defer wr.Flush()

	scanner.Scan()
	t, _ := strconv.Atoi(scanner.Text())
	for i_ := 0; i_ < t; i_++ {
		scanner.Scan()
		n, _ := strconv.Atoi(scanner.Text())
		wr.WriteString(strconv.Itoa(n+(n/2)*2+(n/3)*2) + "\n")
	}
}

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

package main

import (
	"fmt"
)

func main() {
	var T int64
	fmt.Scanf("%d", &T)
	for c := int64(0); c < T; c++ {
		var n int64
		fmt.Scanf("%d", &n)
		ans := 5*(n/3) + 3*(n/2-n/3) + n - n/2
		fmt.Println(ans)
	}
}

package main

import (
	"fmt"
)

func main() {
	var T int64
	fmt.Scanf("%d %d", &T)
	for c := int64(0); c < T; c++ {
		var n int64
		fmt.Scanf("%d", &n)
		ans := 5*(n/3) + 3*(n/2-n/3) + n - n/2
		fmt.Println(ans)
	}
}

package main

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

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

func solve() {
	var n int
	fmt.Fscan(in, &n)
	res := n + n/2*2 + n/3*3
	fmt.Fprintln(out, res)
}

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

// https://codeforces.com/contest/1717/problem/A
package main

import "fmt"

func main() {
	var t int
	fmt.Scan(&t)
	for i := 0; i < t; i++ {
		var n int32
		fmt.Scan(&n)
		fmt.Print(n+2*(n/2+n/3))
	}
}


You are given a string $$$s$$$. Each character is either 0 or 1.You want all 1's in the string to form a contiguous subsegment. For example, if the string is 0, 1, 00111 or 01111100, then all 1's form a contiguous subsegment, and if the string is 0101, 100001 or 11111111111101, then this condition is not met.You may erase some (possibly none) 0's from the string. What is the minimum number of 0's that you have to erase?

The first line contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ lines follow, each representing a test case. Each line contains one string $$$s$$$ ($$$1 \le |s| \le 100$$$); each character of $$$s$$$ is either 0 or 1.

Print $$$t$$$ integers, where the $$$i$$$-th integer is the answer to the $$$i$$$-th testcase (the minimum number of 0's that you have to erase from $$$s$$$).

NoteIn the first test case you have to delete the third and forth symbols from string 010011 (it turns into 0111).

package main

import (
	"fmt"
	"strings"
)

func main() {
	var nb_test int
	fmt.Scan(&nb_test)
	for nb_test > 0 {
		var given string
		fmt.Scan(&given)
		ones := strings.Count(given, "1")
		if ones == 0 {
			fmt.Println("0")
		} else {
			firstIndex := strings.Index(given, "1")
			lastIndex := strings.LastIndex(given, "1")
			sslice := given[firstIndex : lastIndex+1]
			fmt.Println(strings.Count(sslice, "0"))
		}
		nb_test--
	}
}

package main

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

func main() {
	var t int
	var s string
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		fmt.Fscan(in, &s)
		s = removeLeadingZero(s)
		count := 0
		ans := 0
		for _, v := range s {
			if v == '1' {
				ans += count
				count = 0
			} else {
				count++
			}
		}
		fmt.Println(ans)
	}
}

func removeLeadingZero(s string) string {
	idx := 0
	for ; idx < len(s) && s[idx] == '0'; idx++ {
	}
	return s[idx:]
}

// A. Erasing Zeroes
/*
You are given a string 𝑠. Each character is either 0 or 1.

You want all 1's in the string to form a contiguous subsegment. For example, if the string is 0, 1, 00111 or 01111100, then all 1's form a contiguous subsegment, and if the string is 0101, 100001 or 11111111111101, then this condition is not met.

You may erase some (possibly none) 0's from the string. What is the minimum number of 0's that you have to erase?

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

Then 𝑡 lines follow, each representing a test case. Each line contains one string 𝑠 (1≤|𝑠|≤100); each character of 𝑠 is either 0 or 1.

Output
Print 𝑡 integers, where the 𝑖-th integer is the answer to the 𝑖-th testcase (the minimum number of 0's that you have to erase from 𝑠).

Example
Input
3
010011
0
1111000

Output
2
0
0

Note
In the first test case you have to delete the third and forth symbols from string 010011 (it turns into 0111).
*/
package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	input1, _ := reader.ReadString('\n')
	t, _ := strconv.Atoi(strings.TrimSpace(input1))

	for ; t > 0; t-- {
		input2, _ := reader.ReadString('\n')
		s := strings.TrimSpace(input2)

		// this for loop is to get start and end index on '1'
		start, end := -1, -1
		for i, v := range s {
			if start == -1 && v == '1' {
				start = i
			} else if v == '1' {
				end = i
			}
		}

		// this loop will find any '0' between '1's
		total := 0
		for i := start; i < end; i++ {
			if s[i] == '0' {
				total++
			}
		}
		fmt.Println(total)
	}
}

package main

import (
	"fmt"
	"strings"
)

func main() {
	var t int
	fmt.Scan(&t)
	for ; t > 0; t-- {
		var s string
		fmt.Scan(&s)
		fmt.Println(strings.Count(strings.Trim(s, "0"), "0"))
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	t := int64(1)
	fmt.Fscanf(in, "%d\n", &t)
	//fmt.Println("debug", t)
	for tt := int64(0); tt < t; tt++ {
		s := ""
		fmt.Fscanf(in, "%s\n", &s)
		ans := 0
		from := -1
		for i := 0; i < len(s); i++ {
			if s[i] == '1' {
				from = i
				break
			}
		}
		to := -1
		for i := len(s) - 1; i >= 0; i-- {
			if s[i] == '1' {
				to = i
				break
			}
		}
		if from != -1 {
			for i := from; i <= to; i++ {
				if s[i] == '0' {
					ans++
				}
			}
		}
		fmt.Fprintf(out, "%d\n", ans)
	}
	return
}

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

func same(s string, ss string) bool {
	a := make([]int, 26)
	for i := 0; i < len(s); i++ {
		b := int(s[i] - 'a')
		a[b]++
	}
	for i := 0; i < len(ss); i++ {
		b := int(ss[i] - 'a')
		a[b]--
		if a[b] == -1 {
			return false
		}
	}
	for i := 0; i < 26; i++ {
		if a[i] != 0 {
			return false
		}
	}
	return true
}

package main

import (
	"fmt"
	"strings"
)

func ErasingZero(s string) int {
	count := 0
	iFirst := -1
	iFirst = strings.Index(s, "1")
	iLast := strings.LastIndex(s, "1")
	if iFirst == -1 {
		return 0
	}
	nums := strings.Split(s,"")
	for i := iFirst; i < iLast; i++ {
		if nums[i] == "0" {
			count++
		}
	}
	return  count
}

func main() {
	var n int
	var sList []string
	fmt.Scanf("%d\n", &n)
	for i := 0; i < n; i++ {
		var s string
		fmt.Scanf("%s\n", &s)
		sList = append(sList, s)
	}
	for i := 0; i < len(sList); i ++ {
		fmt.Println(ErasingZero(sList[i]))
	}
}

package main

import (
	"fmt"
	"log"
	"strings"
)

func scanf(format string, args ...interface{}) {
	_, err := fmt.Scanf(format, args...)
	if err != nil {
		fmt.Printf("%v\n", err)
		log.Fatal(err)
	}
}

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

	for i := 0; i < n; i++ {
		var line string
		_, err := fmt.Scanln(&line)
		if err != nil {
			log.Fatal(err)
		}

		zeros := countZerosToErase(line)
		fmt.Println(zeros)
	}
}

func countZerosToErase(line string) int {
	left := strings.Index(line, "1")
	right := strings.LastIndex(line, "1")

	if left == -1 || right == -1 {
		return 0
	}

	return strings.Count(line[left:right], "0")
}

package main

import (
	"fmt"
)

func main() {
	var t int
	fmt.Scanf("%d\n", &t)
	s := make([]string, t)

	for i := 0; i < t; i++ {
		fmt.Scanf("%s\n", &s[i])
	}
	for i := 0; i < t; i++ {
		zeros := make([]int, len(s[i]))
		d := make([]int, len(s[i]))
		flag := true
		if s[i][0] == '1' {
			flag = false
		}
		for j := 1; j < len(s[i]); j++ {
			if s[i][j] == '1' {
				zeros[j] = 0
				if flag {
					flag = false
				}
			} else if !flag {
				zeros[j] = zeros[j-1] + 1
			}
		}

		for j := 1; j < len(s[i]); j++ {
			if s[i][j] != s[i][j-1] && s[i][j] == '1' {
				d[j] = d[j-1] + zeros[j-1]
			} else {
				d[j] = d[j-1]
			}
		}
		fmt.Println(d[len(s[i])-1])
	}

}

/**
 * @Author : Yuxiang.Lei
 * @Date : 2020-02-12
 **/

package main

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

func main() {
	reader := bufio.NewScanner(os.Stdin)
	reader.Scan()
	numStr := reader.Text()
	num, _ := strconv.ParseInt(numStr, 10, 64)
	for i := int64(0); i < num; i++ {
		reader.Scan()
		str := reader.Text()
		steps := 0
		str = strings.Trim(str, "0")
		for _, char := range str {
			if char == '0' {
				steps++
			}
		}
		fmt.Println(steps)
	}
}

package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string { sc.Scan(); return sc.Text() }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

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

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1000000)

	tests := scanInt()
	for t := 0; t < tests; t++ {
		s := scanString()
		ans := 0
		l := -1
		for i, e := range s {
			if e == '1' {
				if l != -1 {
					ans += i-l-1
					l = i
				} else {
					l = i
				}
			}
		}

		fmt.Println(ans)
	}
}

package main

import (
	"fmt"
	"strings"
)

func eZ(s string) int {
	s = strings.TrimRight(s, "0")
	s = strings.TrimLeft(s, "0")
	return strings.Count(s, "0")
}

func main() {
	var noCases int
	fmt.Scanf("%d\n", &noCases)
	for i := 0; i < noCases; i++ {
		var s string
		fmt.Scanf("%s\n", &s)
		fmt.Printf("%d\n", (eZ(s)))
	}
}

package main

import "fmt"
import "strings"

func main() {
    var t int
    fmt.Scan(&t)
    //~ fmt.Println(t)
    for i := 0; i < t; i++ {
        var s string
        fmt.Scan(&s)
        i1 := strings.IndexByte(s, '1')
        if i1 == -1 {
            fmt.Println(0);
        } else {
            i2 := strings.LastIndexByte(s, '1')
            substr := s[i1:i2 + 1]
            count := strings.Count(substr, "0")
            //~ fmt.Println("line:", s, "substr:", substr, "count:", count)
            fmt.Println(count)
        }
    }
}

package main

import "fmt"

func main(){
	var x int
	fmt.Scanf("%d\n", &x);
	for i:= 0; i < x; i++{
		var s string
		fmt.Scanf("%s\n", &s)

		var l, kur, bo int

		l = len(s)
		for j := 0; j < l; j++{
			if s[j] == '0'{
				kur++
			} else {
				break
			}
		}
		for j := l-1; j > -1; j--{
			if s[j] == '0'{
				kur++
			} else {
				break
			}
		}
		for j := 0; j < l; j++{
			if s[j] == '0'{
				bo++
			}
		}
		if bo == l {
			fmt.Printf("0\n")
		} else {
			fmt.Printf("%d\n", bo -kur)
		}
	}
}

package main

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

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

	solve := func() (ans int) {
		var s string
		Fscan(in, &s)
		i := strings.IndexByte(s, '1')
		j := strings.LastIndexByte(s, '1')
		if i == -1 {
			return
		}
		return strings.Count(s[i:j], "0")
	}

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

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

package main

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

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

	var n int

	fmt.Fscanf(reader, "%d\n", &n)

	for q := 0; q < n; q++ {

		var s string
		var ans int
		var cnt int
		var ok bool

		fmt.Fscanf(reader, "%s\n", &s)
		l := len(s)
		// fmt.Fprintf(writer, "%d\n", l)

		ok = false
		ans = 0
		cnt = 0

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

			if s[i] == 49 {
				ok = true
				ans += cnt
				cnt = 0
			}

			if s[i] == 48 && ok == true {
				cnt++
			}
		}

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

package main

import "fmt"

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

	for q := 0; q < n; q++ {
		var s string
		var ans, f int
		var ok bool

		fmt.Scan(&s)
		l := len(s)

		ans = 0
		f = 0
		ok = false

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

			if s[i] == 49 {
				ok = true
				ans += f
				f = 0
			}

			if s[i] == 48 && ok == true {
				f++
			}
		}

		fmt.Println(ans)

	}
}

package main

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

func main() {
	defer Flush()

	t := readi()
	for i := 0; i < t; i++ {
		s := readb()
		println(solve(s))
	}
}

func solve(s []byte) int {
	for 0 < len(s) && s[0] == '0' {
		s = s[1:]
	}
	for 0 < len(s) && s[len(s)-1] == '0' {
		s = s[:len(s)-1]
	}
	var ans int
	for _, v := range s {
		if v == '0' {
			ans++
		}
	}
	return ans
}

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

// IO helper functions

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// IO functions

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

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

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

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

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

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

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

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

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

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

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

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

// Utilities

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

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

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

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

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

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

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

// Simple math functions

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

package main

import (
	"fmt"
)

func main() {
	t := 0
	fmt.Scanln(&t)
	for i := 0; i < t; i++ {
		s := ""
		fmt.Scanln(&s)
		seenOne := false
		res := 0
		t := 0
		for j := 0; j < len(s); j++ {
			if s[j] == '0' && seenOne {
				t++
			}
			if s[j] == '1' {
				seenOne = true
				res += t
				t = 0
			}
		}
		fmt.Println(res)
	}
}

package main

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

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

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

func main() {
  defer writer.Flush()
  var n int
  scanf("%d\n", &n)
  var s string
  for i := 0; i < n; i++ {
    scanf("%s\n", &s)
    solve(s)
  }
}

func solve(s string) {
  total, last := 0, -1
  for i := range s {
    if s[i] == '1' {
      if last >= 0 {
        total += i - last - 1
      }
      last = i
    }
  }
  printf("%d\n", total)
}

package main

import (
	"fmt"
	"math"
)

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

	for x := 0; x < t; x++ {
		var s string
		fmt.Scanf("%v\n", &s)
		add := 0
		answer := 0
		for _, v := range s {
			if v == '1' {
				add = 1
			}
			if v == '0' {
				answer += add
			}
		}
		for i := len(s) - 1; i >= 0; i-- {
			if s[i] == '1' {
				break
			}
			answer--
		}
		fmt.Printf("%v\n", int(math.Max(float64(answer), 0)))
	}
}

package main

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

const (
	MX_INT int64 = math.MaxInt64
	MN_INT int64 = math.MinInt64
)

func main() {

	for t := ScanInt64(); t > 0; t-- {
		s := ScanWord()
		left1Idx, right1Idx := getLeft1Idx(s), getRight1Idx(s)

		if left1Idx == right1Idx {
			fmt.Println("0")
		} else {
			count0 := 0
			for i := left1Idx; i <= right1Idx; i++ {
				if s[i] == '0' {
					count0++
				}
			}
			fmt.Println(count0)
		}
	}
	close(O)
	oWg.Wait()
}

func getLeft1Idx(s string) int {
	for i := range s {
		if s[i] == '1' {
			return i
		}
	}
	return -1
}

func getRight1Idx(s string) int {
	for i := len(s) - 1; i >= 0; i-- {
		if s[i] == '1' {
			return i
		}
	}
	return -1
}

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

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

func init() {
	P = fmt.Println

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

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

	writer := bufio.NewWriterSize(os.Stdout, int(1e7))
	go func(writer *bufio.Writer) {
		defer oWg.Done()
		defer writer.Flush()

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

func ScanWord() string {
	in.Scan()
	return in.Text()
}

func ScanStringSlice(n int) []string {
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = ScanWord()
	}
	return s
}

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

func ScanInt() int {
	intStr := ScanWord()
	i, err := strconv.Atoi(intStr)
	if err != nil {
		panic(err)
	}
	return i
}

func ScanInt64Slice(n int) []int64 {
	arr := make([]int64, n)
	for i := 0; i < n; i++ {
		arr[i] = ScanInt64()
	}
	return arr
}

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

func Mx(args ...int64) int64 {
	maxVal := MN_INT
	for _, v := range args {
		if v > maxVal {
			maxVal = v
		}
	}
	return maxVal
}

func Mn(args ...int64) int64 {
	minVal := MX_INT
	for _, v := range args {
		if v < minVal {
			minVal = v
		}
	}
	return minVal
}

func MnMx(args ...int64) (int64, int64) {
	minVal, maxVal := MX_INT, MN_INT

	for _, v := range args {
		if v < minVal {
			minVal = v
		}
		if v > maxVal {
			maxVal = v
		}
	}
	return minVal, maxVal
}

func LCM(a, b int64) int64 {
	return a / GCD(a, b) * b
}

func GCD(a, b int64) int64 {
	if (a == 0) {
		return b
	}
	return GCD(b%a, a)
}

func S(v interface{}) string {
	return fmt.Sprintf("%v", v)
}
/*
func SArr(a []int64) string {
	sb := strings.Builder{}
	sb.Grow(len(a) * 9)

	for i := range a {
		numStr := strconv.FormatInt(a[i], 10)
		sb.WriteString(numStr + " ")
	}
	return sb.String()
}
*/

package main

import (
	"fmt"
	"strings"
)

func main() {
	var t int
	fmt.Scan(&t)
	for i := 0; i < t; i++ {
		var s string
		fmt.Scan(&s)
		s = strings.Trim(s, "0")
		fmt.Println(strings.Count(s, "0"))
	}
}

package main

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

func main() {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	s.Buffer(make([]byte, 1<<12), 1<<20)

	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()

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

	buf := new(bytes.Buffer)
	for i := 0; i < t && s.Scan(); i++ {
		a := s.Text()
		var x, y int
		var flag bool
		for _, c := range a[:] {
			if c == '1' && !flag {
				flag = true
			}
			if c == '0' && flag  {
				y++
			}
			if c == '1' {
				x += y
				y = 0
			}
		}
		buf.WriteString(strconv.Itoa(x) + "\n")
	}
	fmt.Fprint(w, buf.String())
}

package main

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

func main() {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	s.Buffer(make([]byte, 1<<12), 1<<20)

	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()

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

	buf := new(bytes.Buffer)
	for i := 0; i < t && s.Scan(); i++ {
		a := s.Text()
		a = strings.Trim(a, "0")
		buf.WriteString(strconv.Itoa(strings.Count(a, "0")) + "\n")
	}
	fmt.Fprint(w, buf.String())
}

package main

import (
	"fmt"
	"strings"
)

func ErasingZero(s string) int {
	count := 0
	iFirst := strings.Index(s, "1")
	iLast := strings.LastIndex(s, "1")
	if iFirst == 0 {
		return 0
	}
	nums := strings.Split(s,"")
	for i := iFirst; i < iLast; i++ {
		if nums[i] == "0" {
			count++
		}
	}
	return  count
}

func main() {
	fmt.Println(ErasingZero("1111000"))
}

package main

import (
	"fmt"
)

func main() {
	var t int
	fmt.Scanf("%d\n", &t)
	s := make([]string, t)

	for i := 0; i < t; i++ {
		fmt.Scanf("%s\n", &s[i])
	}
	for i := 0; i < t; i++ {
		zeros := make([]int, len(s[i]))
		d := make([]int, len(s[i]))

		for j := 1; j < len(s[i]); j++ {
			if s[i][j] == '1' {
				zeros[j] = 0
			} else {
				zeros[j] = zeros[j-1] + 1
			}
		}

		for j := 1; j < len(s[i]); j++ {
			if s[i][j] != s[i][j-1] && s[i][j] == '1' {
				d[j] = d[j-1] + zeros[j-1]
			} else {
				d[j] = d[j-1]
			}
		}
		fmt.Println(d[len(s[i])-1])
	}

}

package main

import (
	"fmt"
	"strings"
)

func eZ(s string) int {
	s = strings.TrimRight(s, "0")
	s = strings.TrimLeft(s, "0")
	return strings.Count(s, "0")
}

func main() {
	var noCases int
	fmt.Scanf("%d", &noCases)
	for i := 0; i < noCases; i++ {
		var s string
		fmt.Scanf("%s", &s)
		fmt.Printf("%d\n", (eZ(s)))
	}
}

package main

import "fmt"

func main(){
	var x int
	fmt.Scanf("%d", &x);
	for i:= 0; i < x; i++{
		var s string
		fmt.Scanf("%s", &s)

		var l, kur, bo int

		l = len(s)
		for j := 0; j < l; j++{
			if s[j] == '0'{
				kur++
			} else {
				break
			}
		}
		for j := l-1; j > -1; j--{
			if s[j] == '0'{
				kur++
			} else {
				break
			}
		}
		for j := 0; j < l; j++{
			if s[j] == '0'{
				bo++
			}
		}
		if bo == l {
			fmt.Printf("0\n")
		} else {
			fmt.Printf("%d\n", bo -kur)
		}
	}
}

package main

import "fmt"

func main(){
	var x int
	fmt.Scanf("%d", &x);
	for i:= 0; i < x; i++{
		var s string
		fmt.Scanf("%s", &s)
		fmt.Printf("%s", s)
		var l, kur, bo int

		l = len(s)
		for j := 0; j < l; j++{
			if s[j] == '0'{
				kur++
			} else {
				break
			}
		}
		for j := l-1; j > -1; j--{
			if s[j] == '0'{
				kur++
			} else {
				break
			}
		}
		for j := 0; j < l; j++{
			if s[j] == '0'{
				bo++
			}
		}
		if bo == l {
			fmt.Printf("0\n")
		} else {
			fmt.Printf("%d\n", bo -kur)
		}
	}
}

package main

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

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

	var n int

	fmt.Fscanf(reader, "%d\n", &n)

	for q := 0; q < n; q++ {

		var s string
		var ans int
		var cnt int
		var ok bool

		fmt.Fscanf(reader, "%s", &s)
		l := len(s)
		// fmt.Fprintf(writer, "%d\n", l)

		ok = false
		ans = 0
		cnt = 0

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

			if s[i] == 49 {
				ok = true
				ans += cnt
				cnt = 0
			}

			if s[i] == 48 && ok == true {
				cnt++
			}
		}

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

package main

import (
	"fmt"
	"math"
)

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

	for x := 0; x < t; x++ {
		var s string
		fmt.Scanf("%v", &s)

		prefix := make([]int, len(s))
		suffix := make([]int, len(s))

		count := 10000
		for i := 0; i < len(s); i++ {
			if s[i] == '1' {
				prefix[i] = count
				count = 0
			} else {
				count++
			}
		}

		answer := 0

		count = 10000
		for i := len(s) - 1; i >= 0; i-- {
			if s[i] == '1' {
				suffix[i] = count
				count = 0
			} else {
				count++
			}
			if s[i] == '1' {
				add := int(math.Min(float64(prefix[i]), float64(suffix[i])))
				if add < 10000 {
					answer += add
				}
			}
		}
		// fmt.Print(prefix, " ", suffix, "\n")

		fmt.Printf("%v\n", answer)
	}
}

package main

import (
	"fmt"
	"math"
)

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

	for x := 0; x < t; x++ {
		var s string
		_, _ = fmt.Scanf("%v", &s)

		prefix := make([]int, len(s))
		suffix := make([]int, len(s))

		count := 1000
		for i := 0; i < len(s); i++ {
			if s[i] == '1' {
				prefix[i] = count
				count = 0
			} else {
				count++
			}
		}

		answer := 0

		count = 1000
		for i := len(s) - 1; i >= 0; i-- {
			if s[i] == '1' {
				suffix[i] = count
				count = 0
			} else {
				count++
			}
			if s[i] == '1' {
				answer += int(math.Min(float64(prefix[i]), float64(suffix[i])))
			}
		}

		fmt.Printf("%v\n", answer)
	}

	var v string
	_, _ = fmt.Scanf("%v", &v)
	fmt.Print(v)
}

package main

import (
	"fmt"
	"math"
)

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

	for x := 0; x < t; x++ {
		var s string
		fmt.Scanf("%v", &s)
		add := 0
		answer := 0
		for _, v := range s {
			if v == '1' {
				add = 1
			}
			if v == '0' {
				answer += add
			}
		}
		for i := len(s) - 1; i >= 0; i-- {
			if s[i] == '1' {
				break
			}
			answer--
		}
		fmt.Printf("%v\n", int(math.Max(float64(answer), 0)))
	}
}

package main

import (
	"fmt"
	"math"
)

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

	for x := 0; x < t; x++ {
		var s string
		fmt.Scanf("%v\n", &s)
		add := 0
		answer := 0
		for _, v := range s {
			if v == '1' {
				add = 1
			}
			if v == '0' {
				answer += add
			}
		}
		for i := len(s) - 1; i >= 0; i-- {
			if s[i] == '1' {
				break
			}
			answer--
		}
		fmt.Printf("%v\n", int(math.Max(float64(answer), 0)))
	}
}


Boboniu has a directed graph with $$$n$$$ vertices and $$$m$$$ edges.The out-degree of each vertex is at most $$$k$$$.Each edge has an integer weight between $$$1$$$ and $$$m$$$. No two edges have equal weights.Boboniu likes to walk on the graph with some specific rules, which is represented by a tuple $$$(c_1,c_2,\ldots,c_k)$$$. If he now stands on a vertex $$$u$$$ with out-degree $$$i$$$, then he will go to the next vertex by the edge with the $$$c_i$$$-th $$$(1\le c_i\le i)$$$ smallest weight among all edges outgoing from $$$u$$$.Now Boboniu asks you to calculate the number of tuples $$$(c_1,c_2,\ldots,c_k)$$$ such that  $$$1\le c_i\le i$$$ for all $$$i$$$ ($$$1\le i\le k$$$).  Starting from any vertex $$$u$$$, it is possible to go back to $$$u$$$ in finite time by walking on the graph under the described rules.

The first line contains three integers $$$n$$$, $$$m$$$ and $$$k$$$ ($$$2\le n\le 2\cdot 10^5$$$, $$$2\le m\le \min(2\cdot 10^5,n(n-1) )$$$, $$$1\le k\le 9$$$). Each of the next $$$m$$$ lines contains three integers $$$u$$$, $$$v$$$ and $$$w$$$ $$$(1\le u,v\le n,u\ne v,1\le w\le m)$$$, denoting an edge from $$$u$$$ to $$$v$$$ with weight $$$w$$$. It is guaranteed that there are no self-loops or multiple edges and each vertex has at least one edge starting from itself. It is guaranteed that the out-degree of each vertex is at most $$$k$$$ and no two edges have equal weight.

Print one integer: the number of tuples.

NoteFor the first example, there are two tuples: $$$(1,1,3)$$$ and $$$(1,2,3)$$$. The blue edges in the picture denote the $$$c_i$$$-th smallest edges for each vertex, which Boboniu chooses to go through.  For the third example, there's only one tuple: $$$(1,2,2,2)$$$.  The out-degree of vertex $$$u$$$ means the number of edges outgoing from $$$u$$$.

package main

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

var in *bufio.Reader
var out *bufio.Writer

func printf(x string, a ...interface{}) (n int, err error) {
	return fmt.Fprintf(out, x, a...)
}

func scanf(x string, a ...interface{}) (n int, err error) {
	return fmt.Fscanf(in, x, a...)
}

var err error

func next() (n string) {
	for {
		_, err = scanf("%v", &n)
		if err == nil {
			return n
		}
		if err.Error() == "EOF" {
			return ""
		}
	}
}

func nextInt() (n int) {
	for {
		_, err = scanf("%v", &n)
		if err == nil {
			return n
		}
		if err.Error() == "EOF" {
			return 0
		}
	}
}

func nextLong() (n int64) {
	for {
		_, err = scanf("%v", &n)
		if err == nil {
			return n
		}
		if err.Error() == "EOF" {
			return 0
		}
	}
}

func nextDouble() (n float64) {
	for {
		_, err = scanf("%v", &n)
		if err == nil {
			return n
		}
		if err.Error() == "EOF" {
			return 0
		}
	}
}

func Fill(a []int, v int) {
	for i := range a {
		a[i] = v
	}
}

func FillB(a []bool, v bool) {
	for i := range a {
		a[i] = v
	}
}

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

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

const (
	mod = 1000000009
)

var (
	primes = [4]int{999989857, 999999733, 1000000007, 1000000009}
)

func mult(a, b int64) int64 {
	return (a * b) % mod
}
func add(a, b int64) int64 {
	return (a + b) % mod
}
func sub(a, b int64) int64 {
	return (a - b + mod) % mod
}

func solve() {
	n, m, k := nextInt(), nextInt(), nextInt()
	adj := make([][][2]int, n)
	for i := 0; i < m; i++ {
		x, y := nextInt()-1, nextInt()-1
		adj[x] = append(adj[x], [2]int{y, nextInt()})
	}

	maps := [4][]int{}

	ans := [4]int{}

	for i := range maps {
		maps[i] = make([]int, n)
		for j := range maps[i] {
			maps[i][j] = rand.Intn(primes[i])
			ans[i] = (ans[i] + maps[i][j]) % primes[i]
		}
	}

	sets := [4][][]int{}
	for i := range sets {
		sets[i] = make([][]int, k)
		for j := range sets[i] {
			sets[i][j] = make([]int, j+1)
		}
	}

	for _, edges := range adj {
		nums := len(edges) - 1
		sort.Slice(edges, func(a, b int) bool {
			return edges[a][1] < edges[b][1]
		})
		for x, e := range edges {
			for i := range sets {
				sets[i][nums][x] = (sets[i][nums][x] + maps[i][e[0]]) % primes[i]
			}
		}
	}

	pow := 1
	for i := 1; i <= k; i++ {
		pow *= i
	}

	xx := 0
	arr := make([]int, k)
	arr[0] = -1

	for i := 0; i < pow; i++ {
		arr[0]++
		for j := range arr {
			if arr[j] > j {
				arr[j] = 0
				arr[j+1]++
			}
		}
		res := [4]int{}
		for j, v := range primes {
			for x := 0; x < k; x++ {
				res[j] = (res[j] + sets[j][x][arr[x]]) % v
			}
		}
		if res[0] == ans[0] && res[1] == ans[1] && res[2] == ans[2] {
			xx++
		}
	}
	printf("%d\n", xx)
}

func main() {
	in = bufio.NewReaderSize(os.Stdin, 8192)
	out = bufio.NewWriterSize(os.Stdout, 8192)
	if false {
		file1, err := os.Open("input.txt")
		if err != nil {
			log.Fatal(err)
		}
		file2, err := os.Create("output.txt")
		if err != nil {
			log.Fatal(err)
		}
		in = bufio.NewReaderSize(file1, 8192)
		out = bufio.NewWriterSize(file2, 8192)
	}
	defer out.Flush()

	// start := time.Now()

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

	// printf("%v\n", time.Now().Sub(start))
}

package main

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

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

	n, m, k := readThreeNums(reader)
	E := make([][]int, m)
	for i := 0; i < m; i++ {
		E[i] = readNNums(reader, 3)
	}
	fmt.Println(solve(n, m, k, E))
}

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

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

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

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

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

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

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

	return i
}

var r *rand.Rand

func init() {
	r = rand.New(rand.NewSource(99))

}

var MOD = [...]uint64{1000000007, 1000000008, 1000000009}

type HashNum struct {
	val [3]uint64
}

func (this HashNum) Add(that HashNum) HashNum {
	var res [3]uint64
	res[0] = (this.val[0] + that.val[0]) % MOD[0]
	res[1] = (this.val[1] * that.val[1]) % MOD[1]
	res[2] = (this.val[2] + that.val[2]) % MOD[2]
	return HashNum{res}
}

func NewHashNum(v uint64) HashNum {
	var arr [3]uint64
	for i := 0; i < 3; i++ {
		arr[i] = v % MOD[i]
	}
	return HashNum{arr}
}

func solve(n, m, k int, E [][]int) int {
	hashValues := make([]HashNum, n+1)

	mem := make(map[uint64]bool)
	for i := 0; i <= n; i++ {
		tmp := r.Uint64()
		for mem[tmp] {
			tmp = r.Uint64()
		}
		hashValues[i] = NewHashNum(tmp)
		mem[tmp] = true
	}

	var tot HashNum

	for i := 1; i <= n; i++ {
		tot = tot.Add(hashValues[i])
	}

	degree := make([]int, n+1)
	for i := 0; i < m; i++ {
		e := E[i]
		degree[e[0]]++
	}
	G := make([][]Pair, n+1)
	for i := 0; i <= n; i++ {
		G[i] = make([]Pair, 0, degree[i])
	}
	for i := 0; i < m; i++ {
		e := E[i]
		u, v, w := e[0], e[1], e[2]
		G[u] = append(G[u], Pair{w, v})
	}

	C := make([][]HashNum, k+1)

	for i := 0; i <= k; i++ {
		C[i] = make([]HashNum, k+1)
	}

	for i := 1; i <= n; i++ {
		sort.Sort(Pairs(G[i]))
		d := degree[i]
		for j := 1; j <= d; j++ {
			v := G[i][j-1].second
			C[d][j] = C[d][j].Add(hashValues[v])
		}
	}

	var res int
	var dfs func(x int, cur HashNum)

	dfs = func(x int, cur HashNum) {
		if x == k {
			if cur == tot {
				res++
			}
			return
		}
		for i := 1; i <= x+1; i++ {
			dfs(x+1, cur.Add(C[x+1][i]))
		}
	}
	dfs(0, NewHashNum(0))

	return res
}

type Pair struct {
	first, second int
}

type Pairs []Pair

func (ps Pairs) Len() int {
	return len(ps)
}

func (ps Pairs) Less(i, j int) bool {
	return ps[i].first < ps[j].first
}

func (ps Pairs) Swap(i, j int) {
	ps[i], ps[j] = ps[j], ps[i]
}