package main

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

func Init() {
}

func Solve(io *FastIO) {
	N := io.NextInt()
	K := io.NextInt()
	M := io.NextInt()

	S := make([]string, N)
	idx := make(map[string]int)
	for i := 0; i < N; i++ {
	  S[i] = io.NextString()
	  idx[S[i]] = i
	}

	A := io.NextLongArray(N)

// 	fmt.Println(idx)

	mins := make([]int64, N)
	for i, v := range A {
	  mins[i] = v
	}

	djs := NewDisjointSet(N)
	for i := 0; i < K; i++ {
	  X := io.NextInt()
	  Y := io.NextInt() - 1
	  for j := 1; j < X; j++ {
	    Z := io.NextInt() - 1
	    djs.union(Y, Z)
	    which := djs.find(Z)
	    mins[which] = Min(mins[which], A[Y], A[Z])
	   // mins[Y] = Min(mins[Y], A[Y], A[Z])
	   // mins[Z] = Min(mins[Z], A[Y], A[Z])
	  }
	}

// 	fmt.Println(mins)

	var cost int64
	for i := 0; i < M; i++ {
	  W := io.NextString()
	  which := djs.find(idx[W])
	  cost += mins[which]
	 // fmt.Printf("%s: %d %d %d\n", W, idx[W], which, mins[which])
	}
	io.Println(cost)
}

func Min(args ...int64) int64 {
	min := args[0]
	for i := 1; i < len(args); i++ {
		if args[i] < min {
			min = args[i]
		}
	}
	return min
}

func FillLongArray(arr []int64, val int64) {
	for i := range arr {
		arr[i] = val
	}
}

type DisjointSet struct {
	parent []int
	rank []int
}

func NewDisjointSet(n int) *DisjointSet {
	dj := DisjointSet{
		parent: make([]int, n),
		rank: make([]int, n),
	}
	for i := 0; i < n; i++ {
		dj.parent[i] = i
	}
	return &dj
}

func (dj *DisjointSet) find(x int) int {
	if dj.parent[x] != x {
		dj.parent[x] = dj.find(dj.parent[x])
	}
	return dj.parent[x]
}

func (dj *DisjointSet) union(x, y int) bool {
	xr := dj.find(x)
	yr := dj.find(y)

	if xr == yr {
		return false
	}

	if dj.rank[xr] < dj.rank[yr] {
		dj.parent[xr] = yr
	} else if dj.rank[xr] > dj.rank[yr] {
		dj.parent[yr] = xr
	} else {
		dj.parent[xr] = yr
		dj.rank[yr]++
	}
	return true
}

type FastIO struct {
	reader *bufio.Reader
	writer *bufio.Writer
}

func (io *FastIO) NextChar() byte {
	c, _ := io.reader.ReadByte()
	return c
}

func (io *FastIO) NextInt() int {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	sgn := 1
	if c == '-' {
		sgn = -1
		c = io.NextChar()
	}
	res := 0
	for !IsSpaceChar(c) {
		res = (res * 10) + int(c - '0')
		c = io.NextChar()
	}
	return sgn * res
}

func (io *FastIO) NextLong() int64 {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	sgn := int64(1)
	if c == '-' {
		sgn = -1
		c = io.NextChar()
	}
	res := int64(0)
	for !IsSpaceChar(c) {
		res = (res * 10) + int64(c - '0')
		c = io.NextChar()
	}
	return sgn * res
}

func (io *FastIO) NextIntArray(size int) []int {
	return io.NextIntArrayOffset(size, 0)
}

func (io *FastIO) NextIntArrayOffset(size, offset int) []int {
	arr := make([]int, size + offset)
	for i := 0; i < size; i++ {
		arr[i + offset] = io.NextInt()
	}
	return arr
}

func (io *FastIO) NextLongArray(size int) []int64 {
	return io.NextLongArrayOffset(size, 0)
}

func (io *FastIO) NextLongArrayOffset(size, offset int) []int64 {
	arr := make([]int64, size + offset)
	for i := 0; i < size; i++ {
		arr[i + offset] = io.NextLong()
	}
	return arr
}

func (io *FastIO) NextString() string {
	c := io.NextChar()
	for (IsSpaceChar(c)) {
		c = io.NextChar()
	}
	var sb bytes.Buffer
	for !IsSpaceChar(c) {
		sb.WriteByte(c)
		c = io.NextChar()
	}
	return sb.String()
}

func (io *FastIO) NextLine() string {
	c := io.NextChar()
	for (IsSpaceChar(c)) {
		c = io.NextChar()
	}
	var sb bytes.Buffer
	for !IsLineBreakChar(c) {
		sb.WriteByte(c)
		c = io.NextChar()
	}
	return sb.String()
}

func (io *FastIO) Println(args ...interface{}) {
	io.writer.WriteString(fmt.Sprintln(args...))
}

func (io *FastIO) Printf(format string, args ...interface{}) {
	io.writer.WriteString(fmt.Sprintf(format, args...))
}

func (io *FastIO) FlushOutput() {
	io.writer.Flush()
}

func IsSpaceChar(c byte) bool {
	switch c {
	case 0, '\t', '\n', '\r', ' ':
		return true
	default:
		return false
	}
}

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

func main() {
	io := FastIO{reader: bufio.NewReader(os.Stdin), writer: bufio.NewWriter(os.Stdout)}
	Init()
	Solve(&io)
	io.FlushOutput()
}

package main

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

func solve() {
	n := readInt()
	k := readInt()
	m := readInt()
	words := make([]string, n, n)
	for i := range words {
		words[i] = readString()
	}

	costs := make([]int64, n, n)
	for i := range costs {
		costs[i] = readInt64()
	}

	mcosts := make(map[string]int64)
	for i, w := range words {
		mcosts[w] = costs[i]
	}

	xcost := int64(0)
	for i := 0; i < k; i++ {
		nremap := readInt()
		remaps := make([]int, nremap, nremap)
		for j := range remaps {
			r := readInt() - 1
			remaps[j] = r
			if j == 0 {
				xcost = costs[r]
			} else if costs[r] < xcost {
				xcost = costs[r]
			}
		}

		// we can send each word in this group
		// at the minimum costs computed above
		for _, r := range remaps {
			mcosts[words[r]] = xcost
		}
	}

	sum := int64(0)
	for i := 0; i < m; i++ {
		sum += mcosts[readString()]
	}
	fmt.Println(sum)
}

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

package main

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

func Init() {
}

func Solve(io *FastIO) {
	N := io.NextInt()
	K := io.NextInt()
	M := io.NextInt()

	S := make([]string, N)
	idx := make(map[string]int)
	for i := 0; i < N; i++ {
	  S[i] = io.NextString()
	  idx[S[i]] = i
	}

	A := io.NextLongArray(N)

// 	fmt.Println(idx)

	mins := make([]int64, N)
	for i, v := range A {
	  mins[i] = v
	}

	djs := NewDisjointSet(N)
	for i := 0; i < K; i++ {
	  X := io.NextInt()
	  Y := io.NextInt() - 1
	  for j := 1; j < X; j++ {
	    Z := io.NextInt() - 1
	    djs.union(Y, Z)
	   // which := djs.find(Z)
	   // mins[which] = Min(mins[which], A[Z])
	    mins[Y] = Min(mins[Y], A[Y], A[Z])
	    mins[Z] = Min(mins[Z], A[Y], A[Z])
	  }
	}

// 	fmt.Println(mins)

	var cost int64
	for i := 0; i < M; i++ {
	  W := io.NextString()
	  which := djs.find(idx[W])
	  cost += mins[which]
	 // fmt.Printf("%s: %d %d %d\n", W, idx[W], which, mins[which])
	}
	io.Println(cost)
}

func Min(args ...int64) int64 {
	min := args[0]
	for i := 1; i < len(args); i++ {
		if args[i] < min {
			min = args[i]
		}
	}
	return min
}

func FillLongArray(arr []int64, val int64) {
	for i := range arr {
		arr[i] = val
	}
}

type DisjointSet struct {
	parent []int
	rank []int
}

func NewDisjointSet(n int) *DisjointSet {
	dj := DisjointSet{
		parent: make([]int, n),
		rank: make([]int, n),
	}
	for i := 0; i < n; i++ {
		dj.parent[i] = i
	}
	return &dj
}

func (dj *DisjointSet) find(x int) int {
	if dj.parent[x] != x {
		dj.parent[x] = dj.find(dj.parent[x])
	}
	return dj.parent[x]
}

func (dj *DisjointSet) union(x, y int) bool {
	xr := dj.find(x)
	yr := dj.find(y)

	if xr == yr {
		return false
	}

	if dj.rank[xr] < dj.rank[yr] {
		dj.parent[xr] = yr
	} else if dj.rank[xr] > dj.rank[yr] {
		dj.parent[yr] = xr
	} else {
		dj.parent[xr] = yr
		dj.rank[yr]++
	}
	return true
}

type FastIO struct {
	reader *bufio.Reader
	writer *bufio.Writer
}

func (io *FastIO) NextChar() byte {
	c, _ := io.reader.ReadByte()
	return c
}

func (io *FastIO) NextInt() int {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	sgn := 1
	if c == '-' {
		sgn = -1
		c = io.NextChar()
	}
	res := 0
	for !IsSpaceChar(c) {
		res = (res * 10) + int(c - '0')
		c = io.NextChar()
	}
	return sgn * res
}

func (io *FastIO) NextLong() int64 {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	sgn := int64(1)
	if c == '-' {
		sgn = -1
		c = io.NextChar()
	}
	res := int64(0)
	for !IsSpaceChar(c) {
		res = (res * 10) + int64(c - '0')
		c = io.NextChar()
	}
	return sgn * res
}

func (io *FastIO) NextIntArray(size int) []int {
	return io.NextIntArrayOffset(size, 0)
}

func (io *FastIO) NextIntArrayOffset(size, offset int) []int {
	arr := make([]int, size + offset)
	for i := 0; i < size; i++ {
		arr[i + offset] = io.NextInt()
	}
	return arr
}

func (io *FastIO) NextLongArray(size int) []int64 {
	return io.NextLongArrayOffset(size, 0)
}

func (io *FastIO) NextLongArrayOffset(size, offset int) []int64 {
	arr := make([]int64, size + offset)
	for i := 0; i < size; i++ {
		arr[i + offset] = io.NextLong()
	}
	return arr
}

func (io *FastIO) NextString() string {
	c := io.NextChar()
	for (IsSpaceChar(c)) {
		c = io.NextChar()
	}
	var sb bytes.Buffer
	for !IsSpaceChar(c) {
		sb.WriteByte(c)
		c = io.NextChar()
	}
	return sb.String()
}

func (io *FastIO) NextLine() string {
	c := io.NextChar()
	for (IsSpaceChar(c)) {
		c = io.NextChar()
	}
	var sb bytes.Buffer
	for !IsLineBreakChar(c) {
		sb.WriteByte(c)
		c = io.NextChar()
	}
	return sb.String()
}

func (io *FastIO) Println(args ...interface{}) {
	io.writer.WriteString(fmt.Sprintln(args...))
}

func (io *FastIO) Printf(format string, args ...interface{}) {
	io.writer.WriteString(fmt.Sprintf(format, args...))
}

func (io *FastIO) FlushOutput() {
	io.writer.Flush()
}

func IsSpaceChar(c byte) bool {
	switch c {
	case 0, '\t', '\n', '\r', ' ':
		return true
	default:
		return false
	}
}

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

func main() {
	io := FastIO{reader: bufio.NewReader(os.Stdin), writer: bufio.NewWriter(os.Stdout)}
	Init()
	Solve(&io)
	io.FlushOutput()
}

package main

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

func Init() {
}

func Solve(io *FastIO) {
	N := io.NextInt()
	K := io.NextInt()
	M := io.NextInt()

	S := make([]string, N)
	idx := make(map[string]int)
	for i := 0; i < N; i++ {
	  S[i] = io.NextString()
	  idx[S[i]] = i
	}

	A := io.NextLongArray(N)

// 	fmt.Println(idx)

	mins := make([]int64, N)
	for i, v := range A {
	  mins[i] = v
	}

	djs := NewDisjointSet(N)
	for i := 0; i < K; i++ {
	  X := io.NextInt()
	  Y := io.NextInt() - 1
	  for j := 1; j < X; j++ {
	    Z := io.NextInt() - 1
	    djs.union(Y, Z)
	   // which := djs.find(Z)
	   // mins[which] = Min(mins[which], A[Z])
	    mins[Y] = Min(mins[Y], A[Y], A[Z])
	    mins[Z] = Min(mins[Z], A[Y], A[Z])
	  }
	}

// 	fmt.Println(mins)

	var cost int64
	for i := 0; i < M; i++ {
	  W := io.NextString()
	  which := idx[W]
	  cost += mins[which]
	 // fmt.Printf("%s: %d %d %d\n", W, idx[W], which, mins[which])
	}
	io.Println(cost)
}

func Min(args ...int64) int64 {
	min := args[0]
	for i := 1; i < len(args); i++ {
		if args[i] < min {
			min = args[i]
		}
	}
	return min
}

func FillLongArray(arr []int64, val int64) {
	for i := range arr {
		arr[i] = val
	}
}

type DisjointSet struct {
	parent []int
	rank []int
}

func NewDisjointSet(n int) *DisjointSet {
	dj := DisjointSet{
		parent: make([]int, n),
		rank: make([]int, n),
	}
	for i := 0; i < n; i++ {
		dj.parent[i] = i
	}
	return &dj
}

func (dj *DisjointSet) find(x int) int {
	if dj.parent[x] != x {
		dj.parent[x] = dj.find(dj.parent[x])
	}
	return dj.parent[x]
}

func (dj *DisjointSet) union(x, y int) bool {
	xr := dj.find(x)
	yr := dj.find(y)

	if xr == yr {
		return false
	}

	if dj.rank[xr] < dj.rank[yr] {
		dj.parent[xr] = yr
	} else if dj.rank[xr] > dj.rank[yr] {
		dj.parent[yr] = xr
	} else {
		dj.parent[xr] = yr
		dj.rank[yr]++
	}
	return true
}

type FastIO struct {
	reader *bufio.Reader
	writer *bufio.Writer
}

func (io *FastIO) NextChar() byte {
	c, _ := io.reader.ReadByte()
	return c
}

func (io *FastIO) NextInt() int {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	sgn := 1
	if c == '-' {
		sgn = -1
		c = io.NextChar()
	}
	res := 0
	for !IsSpaceChar(c) {
		res = (res * 10) + int(c - '0')
		c = io.NextChar()
	}
	return sgn * res
}

func (io *FastIO) NextLong() int64 {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	sgn := int64(1)
	if c == '-' {
		sgn = -1
		c = io.NextChar()
	}
	res := int64(0)
	for !IsSpaceChar(c) {
		res = (res * 10) + int64(c - '0')
		c = io.NextChar()
	}
	return sgn * res
}

func (io *FastIO) NextIntArray(size int) []int {
	return io.NextIntArrayOffset(size, 0)
}

func (io *FastIO) NextIntArrayOffset(size, offset int) []int {
	arr := make([]int, size + offset)
	for i := 0; i < size; i++ {
		arr[i + offset] = io.NextInt()
	}
	return arr
}

func (io *FastIO) NextLongArray(size int) []int64 {
	return io.NextLongArrayOffset(size, 0)
}

func (io *FastIO) NextLongArrayOffset(size, offset int) []int64 {
	arr := make([]int64, size + offset)
	for i := 0; i < size; i++ {
		arr[i + offset] = io.NextLong()
	}
	return arr
}

func (io *FastIO) NextString() string {
	c := io.NextChar()
	for (IsSpaceChar(c)) {
		c = io.NextChar()
	}
	var sb bytes.Buffer
	for !IsSpaceChar(c) {
		sb.WriteByte(c)
		c = io.NextChar()
	}
	return sb.String()
}

func (io *FastIO) NextLine() string {
	c := io.NextChar()
	for (IsSpaceChar(c)) {
		c = io.NextChar()
	}
	var sb bytes.Buffer
	for !IsLineBreakChar(c) {
		sb.WriteByte(c)
		c = io.NextChar()
	}
	return sb.String()
}

func (io *FastIO) Println(args ...interface{}) {
	io.writer.WriteString(fmt.Sprintln(args...))
}

func (io *FastIO) Printf(format string, args ...interface{}) {
	io.writer.WriteString(fmt.Sprintf(format, args...))
}

func (io *FastIO) FlushOutput() {
	io.writer.Flush()
}

func IsSpaceChar(c byte) bool {
	switch c {
	case 0, '\t', '\n', '\r', ' ':
		return true
	default:
		return false
	}
}

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

func main() {
	io := FastIO{reader: bufio.NewReader(os.Stdin), writer: bufio.NewWriter(os.Stdout)}
	Init()
	Solve(&io)
	io.FlushOutput()
}


package main

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

func main() {
	var t int
	in := bufio.NewReader(os.Stdin)
	out := os.Stdout
	ans := [10000005]int{}
	f := [10000005]int{}
	for i:=1;i<=10000000;i++{
		for j:=i;j<=10000000;j+=i{
			f[j] += i
		}
		if f[i]<=10000000{
			if ans [f[i]]==0 {
				ans[f[i]] = i
			}
		}
	}
	fmt.Fscan(in,&t)
	for u:=1;u<=t;u++{
		var c int
		fmt.Fscan(in,&c)
		if ans[c]!=0{
			fmt.Fprintln(out,ans[c])
		}else{
			fmt.Fprintln(out,-1)
		}
	}
}

package main

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

// github.com/EndlessCheng/codeforces-go
func run(_r io.Reader, _w io.Writer) {
	out := bufio.NewWriter(_w)
	defer out.Flush()
	_i, buf := 1<<12, make([]byte, 1<<12)
	rc := func() byte {
		if _i == 1<<12 {
			_r.Read(buf)
			_i = 0
		}
		b := buf[_i]
		_i++
		return b
	}
	r := func() (x int) {
		b := rc()
		for ; '0' > b; b = rc() {
		}
		for ; '0' <= b; b = rc() {
			x = x*10 + int(b&15)
		}
		return
	}

	const mx int = 1e7
	d := make([]int, mx+1)
	d[1] = 1
	primes := make([]int, 0, 664579)
	for i := 2; i <= mx; i++ {
		if d[i] == 0 {
			d[i] = 1 + i
			primes = append(primes, i)
		}
		for _, p := range primes {
			v := p * i
			if v > mx {
				break
			}
			if i%p == 0 {
				x := i
				for {
					x /= p
					if x%p > 0 {
						break
					}
				}
				d[v] = d[i]*p + d[x]
				break
			}
			d[v] = d[i] * (1 + p)
		}
	}

	mi := make([]int, mx+1)
	for i := mx; i > 0; i-- {
		if d := d[i]; d <= mx {
			mi[d] = i
		}
	}

	for T := r(); T > 0; T-- {
		if m := mi[r()]; m > 0 {
			Fprintln(out, m)
		} else {
			Fprintln(out, "-1")
		}
	}
}

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

package main

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

// github.com/EndlessCheng/codeforces-go
func run(_r io.Reader, _w io.Writer) {
	out := bufio.NewWriter(_w)
	defer out.Flush()
	_i, buf := 1<<12, make([]byte, 1<<12)
	rc := func() byte {
		if _i == 1<<12 {
			_r.Read(buf)
			_i = 0
		}
		b := buf[_i]
		_i++
		return b
	}
	r := func() (x int) {
		b := rc()
		for ; '0' > b; b = rc() {
		}
		for ; '0' <= b; b = rc() {
			x = x*10 + int(b&15)
		}
		return
	}

	const mx int = 1e7
	d := make([]int, mx+1)
	d[1] = 1
	s := make([]int, mx+1)
	primes := make([]int, 0, 664579)
	for i := 2; i <= mx; i++ {
		if d[i] == 0 {
			s[i] = 1 + i
			d[i] = 1 + i
			primes = append(primes, i)
		}
		for _, p := range primes {
			if p*i > mx {
				break
			}
			if i%p == 0 {
				s[p*i] = s[i]*p + 1
				d[p*i] = d[i] / s[i] * s[p*i]
				break
			}
			s[p*i] = 1 + p
			d[p*i] = d[i] * (1 + p)
		}
	}

	mi := make([]int, mx+1)
	for i := mx; i > 0; i-- {
		if d := d[i]; d <= mx {
			mi[d] = i
		}
	}

	for T := r(); T > 0; T-- {
		if m := mi[r()]; m > 0 {
			Fprintln(out, m)
		} else {
			Fprintln(out, "-1")
		}
	}
}

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

package main

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

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

	const mx int = 1e7
	d := make([]int, mx+1)
	d[1] = 1
	s := make([]int, mx+1)
	primes := make([]int, 0, 664579)
	for i := 2; i <= mx; i++ {
		if d[i] == 0 {
			s[i] = 1 + i
			d[i] = s[i]
			primes = append(primes, i)
		}
		for _, p := range primes {
			if p*i > mx {
				break
			}
			if i%p == 0 {
				s[p*i] = s[i]*p + 1
				d[p*i] = d[i] / s[i] * s[p*i]
				break
			}
			s[p*i] = 1 + p
			d[p*i] = d[i] * s[p*i]
		}
	}

	mi := make([]int, mx+1)
	for i := 1; i <= mx; i++ {
		if d := d[i]; d <= mx && mi[d] == 0 {
			mi[d] = i
		}
	}

	solve := func(Case int) {
		var n int
		Fscan(in, &n)
		if mi[n] == 0 {
			Fprintln(out, -1)
		} else {
			Fprintln(out, mi[n])
		}
	}

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

	_leftData, _ := ioutil.ReadAll(in)
	if _s := strings.TrimSpace(string(_leftData)); _s != "" {
		panic("有未读入的数据：\n" + _s)
	}
}

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

package main

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

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

	const mx int = 1e7
	d := make([]int, mx+1)
	d[1] = 1
	s := make([]int, mx+1)
	primes := []int{}
	for i := 2; i <= mx; i++ {
		if d[i] == 0 {
			d[i] = 1 + i
			s[i] = 1 + i
			primes = append(primes, i)
		}
		for _, p := range primes {
			if p*i > mx {
				break
			}
			if i%p == 0 {
				s[p*i] = s[i]*p + 1
				d[p*i] = d[i] / s[i] * s[p*i]
				break
			}
			s[p*i] = 1 + p
			d[p*i] = d[i] * (p + 1)
		}
	}

	mi := make([]int, mx+1)
	for i := 1; i <= mx; i++ {
		if d := d[i]; d <= mx && mi[d] == 0 {
			mi[d] = i
		}
	}

	solve := func(Case int) {
		var n int
		Fscan(in, &n)
		if mi[n] == 0 {
			Fprintln(out, -1)
		} else {
			Fprintln(out, mi[n])
		}
	}

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

	_leftData, _ := ioutil.ReadAll(in)
	if _s := strings.TrimSpace(string(_leftData)); _s != "" {
		panic("有未读入的数据：\n" + _s)
	}
}

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

package main

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

const m = 10000001

func main() {
	in := bufio.NewReader(os.Stdin)
	sum := make([]int, m)
	for i:=1;i<m;i++ {
		for j:=i;j<m;j+=i {
			sum[j]+=i
		}
	}
	at := make([]int, m)
	for i := m-1; i>0;i-- {
		if(sum[i] < m){
			at[sum[i]] = i + 1
		}
	}
	var t int
	fmt.Fscan(in, &t)
	for t > 0 {
		t--
		var c int
		fmt.Fscan(in, &c)
		fmt.Println(at[c] - 1)
	}
}

package main

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

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

	const mx int = 1e7
	d := make([]int, mx+1)
	d[1] = 1
	mi := make([]int, mx+1)
	mi[1] =1
	s := make([]int, mx+1)
	primes := make([]int, 0, 664579)
	for i := 2; i <= mx; i++ {
		if d[i] == 0 {
			s[i] = 1 + i
			d[i] = s[i]
			if d := d[i]; d <= mx && mi[d] == 0 {
				mi[d] = i
			}
			primes = append(primes, i)
		}
		for _, p := range primes {
			if p*i > mx {
				break
			}
			if i%p == 0 {
				s[p*i] = s[i]*p + 1
				d[p*i] = d[i] / s[i] * s[p*i]
				if d := d[p*i]; d <= mx && mi[d] == 0 {
					mi[d] = p*i
				}
				break
			}
			s[p*i] = 1 + p
			d[p*i] = d[i] * s[p*i]
			if d := d[p*i]; d <= mx && mi[d] == 0 {
				mi[d] = p*i
			}
		}
	}

	solve := func(Case int) {
		var n int
		Fscan(in, &n)
		if mi[n] == 0 {
			Fprintln(out, -1)
		} else {
			Fprintln(out, mi[n])
		}
	}

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

	_leftData, _ := ioutil.ReadAll(in)
	if _s := strings.TrimSpace(string(_leftData)); _s != "" {
		panic("有未读入的数据：\n" + _s)
	}
}

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

package main

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

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

	const mx int = 1e7
	d := make([]int, mx+1)
	d[1] = 1
	powp := make([]int, mx+1)
	s := make([]int, mx+1)
	primes := []int{}
	for i := 2; i <= mx; i++ {
		if d[i] == 0 {
			d[i] = 1 + i
			powp[i] = i
			s[i] = 1 + i
			primes = append(primes, i)
		}
		for _, p := range primes {
			if p*i > mx {
				break
			}
			if i%p == 0 {
				d[p*i] = d[i] / s[i] * (s[i] + powp[i]*p)
				powp[p*i] = powp[i] * p
				s[p*i] = s[i] + powp[p*i]
				break
			}
			d[p*i] = d[i] * d[p]
			powp[p*i] = powp[i] * powp[p]
			s[p*i] = d[i] * d[p]
		}
	}

	mi := make([]int, mx+1)
	for i := 1; i <= mx; i++ {
		if d := d[i]; d <= mx && mi[d] == 0 {
			mi[d] = i
		}
	}

	solve := func(Case int) {
		var n int
		Fscan(in, &n)
		if mi[n] == 0 {
			Fprintln(out, -1)
		} else {
			Fprintln(out, mi[n])
		}
	}

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

	_leftData, _ := ioutil.ReadAll(in)
	if _s := strings.TrimSpace(string(_leftData)); _s != "" {
		panic("有未读入的数据：\n" + _s)
	}
}

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

package main

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

func main() {
	var t int
	in := bufio.NewReader(os.Stdin)
	out := os.Stdout
	ans := [10000005]int{}
	f := [10000005]int{}
	for i:=1;i<=10000000;i++{
		for j:=i;j<=10000000;j+=i{
			f[j] += i
		}
		if f[i]<=10000000{
			ans[f[i]]=i
		}
	}
	fmt.Fscan(in,&t)
	for u:=1;u<=t;u++{
		var c int
		fmt.Fscan(in,&c)
		if ans[c]!=0{
			fmt.Fprintln(out,ans[c])
		}else{
			fmt.Fprintln(out,-1)
		}
	}
}


package main

import (
	"bufio"
	"errors"
	"fmt"
	"io"
	"math"
	"os"
	"sort"
	"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
}

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

/********** 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 m, n, k, t int
var A []int

type Trap struct {
	key     int
	l, r, d int
}
type TrapList []*Trap
type byKey struct {
	TrapList
}

func (l TrapList) Len() int {
	return len(l)
}
func (l TrapList) Swap(i, j int) {
	l[i], l[j] = l[j], l[i]
}

func (l byKey) Less(i, j int) bool {
	return l.TrapList[i].key < l.TrapList[j].key
}

// how to use
// L := make(TrapList, 0, 200000+5)
// L = append(L, &Trap{key: intValue})
// sort.Stable(byKey{ L })                // Stable ASC
// sort.Stable(sort.Reverse(byKey{ L }))  // Stable DESC

var L TrapList

func main() {
	m, n, k, t = ReadInt4()
	A = ReadIntSlice(m)
	L = make(TrapList, 0)
	for i := 0; i < k; i++ {
		l, r, d := ReadInt3()
		L = append(L, &Trap{key: l, l: l, r: r, d: d})
	}
	maxAgility := Max(A...)

	// 区間の左端で昇順ソート
	sort.Stable(byKey{L})

	// m は中央を意味する何らかの値
	isOK := func(m int) bool {
		if C(m) {
			return true
		}
		return false
	}

	ng, ok := -1, maxAgility+1
	for int(math.Abs(float64(ok-ng))) > 1 {
		mid := (ok + ng) / 2
		if isOK(mid) {
			ok = mid
		} else {
			ng = mid
		}
	}
	minAgility := ok

	// if minAgility == maxAgility+1 {
	// 	fmt.Println(0)
	// 	return
	// }
	// fmt.Printf("minAgility: %d\n", minAgility)

	num := 0
	for i := 0; i < m; i++ {
		if A[i] >= minAgility {
			num++
		}
	}
	fmt.Println(num)
}

func C(m int) bool {
	segments := []Trap{}
	l, r := 0, -1
	for i := 0; i < len(L); i++ {
		t := L[i]
		if t.d <= m {
			continue
		}

		if r == -1 {
			l, r = t.l, t.r
			continue
		}

		if r >= t.l-1 {
			// マージして継続
			// r = t.r
			ChMax(&r, t.r)
		} else {
			// マージせず中断して追加
			segments = append(segments, Trap{l: l, r: r})
			l, r = t.l, t.r
		}
	}
	if r != -1 {
		segments = append(segments, Trap{l: l, r: r})
	}

	time := 1 + n
	for _, seg := range segments {
		time += 2 * (seg.r - seg.l + 1)
	}
	// fmt.Printf("time: %d\n", time)

	return time <= t
}

/*
- MODは最後にとりましたか？
- ループを抜けた後も処理が必要じゃありませんか？
- 和・積・あまりを求められたらint64が必要ではありませんか？
*/

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

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

package main

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

var (
	m, n, k, t int
	A          []int
	L          []Trap
)

type Trap struct {
	l, r, d int
}

func main() {
	m, n, k, t = readi4()
	A = readis(m)
	// L = make(TrapList, 0)
	for i := 0; i < k; i++ {
		l, r, d := readi3()
		// L = append(L, &Trap{key: l, l: l, r: r, d: d})
		L = append(L, Trap{l, r, d})
	}
	maxAgility := Max(A...)

	// 区間の左端で昇順ソート
	// sort.Stable(byKey{L})
	sort.Slice(L, func(i, j int) bool { return L[i].l < L[j].l })

	// m は中央を意味する何らかの値
	isOK := func(m int) bool {
		if C(m) {
			return true
		}
		return false
	}

	ng, ok := -1, maxAgility+1
	for int(math.Abs(float64(ok-ng))) > 1 {
		mid := (ok + ng) / 2
		if isOK(mid) {
			ok = mid
		} else {
			ng = mid
		}
	}
	minAgility := ok

	num := 0
	for i := 0; i < m; i++ {
		if A[i] >= minAgility {
			num++
		}
	}
	fmt.Println(num)
}

func C(m int) bool {
	segments := []Trap{}
	l, r := 0, -1
	for i := 0; i < len(L); i++ {
		t := L[i]
		if t.d <= m {
			continue
		}

		if r == -1 {
			l, r = t.l, t.r
			continue
		}

		if r >= t.l-1 {
			// マージして継続
			// r = t.r
			ChMax(&r, t.r)
		} else {
			// マージせず中断して追加
			segments = append(segments, Trap{l: l, r: r})
			l, r = t.l, t.r
		}
	}
	if r != -1 {
		segments = append(segments, Trap{l: l, r: r})
	}

	time := 1 + n
	for _, seg := range segments {
		time += 2 * (seg.r - seg.l + 1)
	}
	// fmt.Printf("time: %d\n", time)

	return time <= t
}

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

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

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

/********** common constants **********/

const (
	// General purpose
	MOD = 1000000000 + 7
	// MOD          = 998244353
	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
)

// modint can calculate a right residual whether value is positive or negative.
func modint(val, m int) int {
	res := val % m
	if res < 0 {
		res += m
	}
	return res
}

// modll can calculate a right residual whether value is positive or negative.
func modll(val, m int64) int64 {
	res := val % m
	if res < 0 {
		res += m
	}
	return res
}

/********** bufio setting **********/

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

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

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

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

//str := reads()
//i := readi()
//X := readis(n)
//S := readrs()
//a := readf()
//A := readfs(n)

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

/*********** Input ***********/

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

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

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

// readi returns an integer.
func readi() int {
	return int(_readInt64())
}
func readi2() (int, int) {
	return int(_readInt64()), int(_readInt64())
}
func readi3() (int, int, int) {
	return int(_readInt64()), int(_readInt64()), int(_readInt64())
}
func readi4() (int, int, int, int) {
	return int(_readInt64()), int(_readInt64()), int(_readInt64()), int(_readInt64())
}

// readll returns as integer as int64.
func readll() int64 {
	return _readInt64()
}
func readll2() (int64, int64) {
	return _readInt64(), _readInt64()
}
func readll3() (int64, int64, int64) {
	return _readInt64(), _readInt64(), _readInt64()
}
func readll4() (int64, int64, int64, int64) {
	return _readInt64(), _readInt64(), _readInt64(), _readInt64()
}

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

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

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

// readf returns an float64.
func readf() float64 {
	return float64(_readFloat64())
}

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

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

// readrs returns a rune slice.
func readrs() []rune {
	return []rune(reads())
}

/*********** Output ***********/

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

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

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

	return string(res)
}

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

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

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

	return string(res)
}

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

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

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

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

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

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

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

	return res
}

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

package main

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

var (
	m, n, k, t int
	A          []int
	L          []Trap
)

type Trap struct {
	l, r, d int
}

func main() {
	m, n, k, t = readi4()
	A = readis(m)
	// L = make(TrapList, 0)
	for i := 0; i < k; i++ {
		l, r, d := readi3()
		// L = append(L, &Trap{key: l, l: l, r: r, d: d})
		L = append(L, Trap{l, r, d})
	}
	maxAgility := Max(A...)

	// 区間の左端で昇順ソート
	// sort.Stable(byKey{L})
	sort.Slice(L, func(i, j int) bool { return L[i].l < L[j].l })

	// m は中央を意味する何らかの値
	isOK := func(m int) bool {
		if C(m) {
			return true
		}
		return false
	}

	ng, ok := -1, maxAgility+1
	for int(math.Abs(float64(ok-ng))) > 1 {
		mid := (ok + ng) / 2
		if isOK(mid) {
			ok = mid
		} else {
			ng = mid
		}
	}
	minAgility := ok

	num := 0
	for i := 0; i < m; i++ {
		if A[i] >= minAgility {
			num++
		}
	}
	fmt.Println(num)
}

func C(m int) bool {
	// segments := []Trap{}
	// l, r := 0, -1
	// for i := 0; i < len(L); i++ {
	// 	t := L[i]
	// 	if t.d <= m {
	// 		continue
	// 	}

	// 	if r == -1 {
	// 		l, r = t.l, t.r
	// 		continue
	// 	}

	// 	if r >= t.l-1 {
	// 		// マージして継続
	// 		// r = t.r
	// 		ChMax(&r, t.r)
	// 	} else {
	// 		// マージせず中断して追加
	// 		segments = append(segments, Trap{l: l, r: r})
	// 		l, r = t.l, t.r
	// 	}
	// }
	// if r != -1 {
	// 	segments = append(segments, Trap{l: l, r: r})
	// }

	S := [][2]int{}
	for i := 0; i < len(L); i++ {
		if L[i].d <= m {
			continue
		}
		S = append(S, [2]int{L[i].l, L[i].r})
	}

	segments := MergeSegments(S)

	time := 1 + n
	for _, seg := range segments {
		// time += 2 * (seg.r - seg.l + 1)
		time += 2 * (seg[1] - seg[0] + 1)
	}
	// fmt.Printf("time: %d\n", time)

	return time <= t
}

// MergeSegments returns merged source segments.
// Segments(Sections) are closed section.
// e.g.: [l, r], [l', r'] are merged if r >= l'
func MergeSegments(srcSegments [][2]int) [][2]int {
	_chmax := func(updatedValue *int, target int) bool {
		if *updatedValue < target {
			*updatedValue = target
			return true
		}
		return false
	}

	res := [][2]int{}
	isInitialized := false

	// current segment
	curL, curR := 0, 0

	// sort asc by LEFT coordinate
	sort.Slice(srcSegments, func(i, j int) bool {
		return srcSegments[i][0] < srcSegments[j][0]
	})

	for i := 0; i < len(srcSegments); i++ {
		seg := srcSegments[i]

		if !isInitialized {
			curL, curR = seg[0], seg[1]
			isInitialized = true
			continue
		}

		if curR >= seg[0] {
			// merge and continue
			_chmax(&curR, seg[1])
		} else {
			// do not merge, and add it to result
			res = append(res, [2]int{curL, curR})
			curL, curR = seg[0], seg[1]
		}
	}

	if isInitialized {
		res = append(res, [2]int{curL, curR})
	}

	return res
}

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

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

/********** common constants **********/

const (
	// General purpose
	MOD = 1000000000 + 7
	// MOD          = 998244353
	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
)

// modint can calculate a right residual whether value is positive or negative.
func modint(val, m int) int {
	res := val % m
	if res < 0 {
		res += m
	}
	return res
}

// modll can calculate a right residual whether value is positive or negative.
func modll(val, m int64) int64 {
	res := val % m
	if res < 0 {
		res += m
	}
	return res
}

/********** bufio setting **********/

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

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

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

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

//str := reads()
//i := readi()
//X := readis(n)
//S := readrs()
//a := readf()
//A := readfs(n)

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

/*********** Input ***********/

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

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

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

// readi returns an integer.
func readi() int {
	return int(_readInt64())
}
func readi2() (int, int) {
	return int(_readInt64()), int(_readInt64())
}
func readi3() (int, int, int) {
	return int(_readInt64()), int(_readInt64()), int(_readInt64())
}
func readi4() (int, int, int, int) {
	return int(_readInt64()), int(_readInt64()), int(_readInt64()), int(_readInt64())
}

// readll returns as integer as int64.
func readll() int64 {
	return _readInt64()
}
func readll2() (int64, int64) {
	return _readInt64(), _readInt64()
}
func readll3() (int64, int64, int64) {
	return _readInt64(), _readInt64(), _readInt64()
}
func readll4() (int64, int64, int64, int64) {
	return _readInt64(), _readInt64(), _readInt64(), _readInt64()
}

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

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

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

// readf returns an float64.
func readf() float64 {
	return float64(_readFloat64())
}

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

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

// readrs returns a rune slice.
func readrs() []rune {
	return []rune(reads())
}

/*********** Output ***********/

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

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

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

	return string(res)
}

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

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

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

	return string(res)
}

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

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

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

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

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

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

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

	return res
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	m, n, k, t := 0, 0, 0, 0
	fmt.Fscanf(in, "%d %d %d %d\n", &m, &n, &k, &t)
	a := make([]int, m)
	for i := 0; i < m; i++ {
		fmt.Fscanf(in, "%d", &a[i])
	}
	fmt.Fscanf(in, "\n")
	l, r, d := make([]int, k), make([]int, k), make([]int, k)
	for i := 0; i < k; i++ {
		fmt.Fscanf(in, "%d %d %d\n", &l[i], &r[i], &d[i])
	}
	sort.Ints(a)
	left := 0
	right := m - 1
	for left < right {
		mid := (left + right) / 2
		weakest := a[mid]
		// all traps > weakest should be removed
		time := 0
		b, c := make([]int, n+2), make([]int, n+2)
		for i := 0; i < k; i++ {
			if d[i] > weakest {
				b[l[i]]++
				c[r[i]]++
			}
		}
		i := 0
		//fmt.Println("debug1", b, c)
		for i < n+1 {
			//fmt.Println("here", time)
			if b[i+1] > 0 {
				j := i
				bomb := 0
				for true {
					j++
					bomb += b[j]
					bomb -= c[j]
					b[j] = 0
					c[j] = 0
					if bomb == 0 {
						break
					}
				}
				//fmt.Println("debug3", j)
				time += (j - i) * 2
			}
			time++
			i++
		}
		//fmt.Println("debug", weakest, time)
		if time > t {
			left = mid + 1
		} else {
			right = mid
		}
	}
	mid := left
	weakest := a[mid]
	// all traps > weakest should be removed
	time := 0
	b, c := make([]int, n+2), make([]int, n+2)
	for i := 0; i < k; i++ {
		if d[i] > weakest {
			b[l[i]]++
			c[r[i]]++
		}
	}
	i := 0
	for i < n+1 {
		//fmt.Println("here", time)
		if b[i+1] > 0 {
			j := i
			bomb := 0
			for true {
				j++
				bomb += b[j]
				bomb -= c[j]
				b[j] = 0
				c[j] = 0
				if bomb == 0 {
					break
				}
			}
			//fmt.Println("debug3", j)
			time += (j - i) * 2
		}
		time++
		i++
	}
	if time > t {
		fmt.Fprintf(out, "%d\n", 0)
	} else {
		fmt.Fprintf(out, "%d\n", m-left)
	}

	return
}

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

package main

import (
	"bufio"
	"errors"
	"fmt"
	"io"
	"math"
	"os"
	"sort"
	"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
}

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

/********** 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 m, n, k, t int
var A []int

type Trap struct {
	key     int
	l, r, d int
}
type TrapList []*Trap
type byKey struct {
	TrapList
}

func (l TrapList) Len() int {
	return len(l)
}
func (l TrapList) Swap(i, j int) {
	l[i], l[j] = l[j], l[i]
}

func (l byKey) Less(i, j int) bool {
	return l.TrapList[i].key < l.TrapList[j].key
}

// how to use
// L := make(TrapList, 0, 200000+5)
// L = append(L, &Trap{key: intValue})
// sort.Stable(byKey{ L })                // Stable ASC
// sort.Stable(sort.Reverse(byKey{ L }))  // Stable DESC

var L TrapList

func main() {
	m, n, k, t = ReadInt4()
	A = ReadIntSlice(m)
	L = make(TrapList, 0)
	for i := 0; i < k; i++ {
		l, r, d := ReadInt3()
		L = append(L, &Trap{key: l, l: l, r: r, d: d})
	}
	maxAgility := Max(A...)

	// 区間の左端で昇順ソート
	sort.Stable(byKey{L})

	// m は中央を意味する何らかの値
	isOK := func(m int) bool {
		if C(m) {
			return true
		}
		return false
	}

	ng, ok := -1, maxAgility+1
	for int(math.Abs(float64(ok-ng))) > 1 {
		mid := (ok + ng) / 2
		if isOK(mid) {
			ok = mid
		} else {
			ng = mid
		}
	}
	minAgility := ok

	// if minAgility == maxAgility+1 {
	// 	fmt.Println(0)
	// 	return
	// }
	// fmt.Printf("minAgility: %d\n", minAgility)

	num := 0
	for i := 0; i < m; i++ {
		if A[i] >= minAgility {
			num++
		}
	}
	fmt.Println(num)
}

func C(m int) bool {
	segments := []Trap{}
	l, r := 0, -1
	for i := 0; i < len(L); i++ {
		t := L[i]
		if t.d <= m {
			continue
		}

		if r == -1 {
			l, r = t.l, t.r
			continue
		}

		if r >= t.l-1 {
			// マージして継続
			r = t.r
		} else {
			// マージせず中断して追加
			segments = append(segments, Trap{l: l, r: r})
			l, r = 0, -1
		}
	}
	if r != -1 {
		segments = append(segments, Trap{l: l, r: r})
	}

	time := 1 + n
	for _, seg := range segments {
		time += 2 * (seg.r - seg.l + 1)
	}
	// fmt.Printf("time: %d\n", time)

	return time <= t
}

/*
- MODは最後にとりましたか？
- ループを抜けた後も処理が必要じゃありませんか？
- 和・積・あまりを求められたらint64が必要ではありませんか？
*/

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

package main

import (
	"bufio"
	"errors"
	"fmt"
	"io"
	"math"
	"os"
	"sort"
	"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
}

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

/********** 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 m, n, k, t int
var A []int

type Trap struct {
	key     int
	l, r, d int
}
type TrapList []*Trap
type byKey struct {
	TrapList
}

func (l TrapList) Len() int {
	return len(l)
}
func (l TrapList) Swap(i, j int) {
	l[i], l[j] = l[j], l[i]
}

func (l byKey) Less(i, j int) bool {
	return l.TrapList[i].key < l.TrapList[j].key
}

// how to use
// L := make(TrapList, 0, 200000+5)
// L = append(L, &Trap{key: intValue})
// sort.Stable(byKey{ L })                // Stable ASC
// sort.Stable(sort.Reverse(byKey{ L }))  // Stable DESC

var L TrapList

func main() {
	m, n, k, t = ReadInt4()
	A = ReadIntSlice(m)
	L = make(TrapList, 0)
	for i := 0; i < k; i++ {
		l, r, d := ReadInt3()
		L = append(L, &Trap{key: l, l: l, r: r, d: d})
	}
	maxAgility := Max(A...)

	// 区間の左端で昇順ソート
	sort.Stable(byKey{L})

	// m は中央を意味する何らかの値
	isOK := func(m int) bool {
		if C(m) {
			return true
		}
		return false
	}

	ng, ok := -1, maxAgility+1
	for int(math.Abs(float64(ok-ng))) > 1 {
		mid := (ok + ng) / 2
		if isOK(mid) {
			ok = mid
		} else {
			ng = mid
		}
	}
	minAgility := ok

	// if minAgility == maxAgility+1 {
	// 	fmt.Println(0)
	// 	return
	// }
	// fmt.Printf("minAgility: %d\n", minAgility)

	num := 0
	for i := 0; i < m; i++ {
		if A[i] >= minAgility {
			num++
		}
	}
	fmt.Println(num)
}

func C(m int) bool {
	segments := []Trap{}
	l, r := 0, -1
	for i := 0; i < len(L); i++ {
		t := L[i]
		if t.d <= m {
			continue
		}

		if r == -1 {
			l, r = t.l, t.r
			continue
		}

		if r >= t.l-1 {
			// マージして継続
			// r = t.r
			ChMax(&r, t.r)
		} else {
			// マージせず中断して追加
			segments = append(segments, Trap{l: l, r: r})
			l, r = 0, -1
		}
	}
	if r != -1 {
		segments = append(segments, Trap{l: l, r: r})
	}

	time := 1 + n
	for _, seg := range segments {
		time += 2 * (seg.r - seg.l + 1)
	}
	// fmt.Printf("time: %d\n", time)

	return time <= t
}

/*
- MODは最後にとりましたか？
- ループを抜けた後も処理が必要じゃありませんか？
- 和・積・あまりを求められたらint64が必要ではありませんか？
*/

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


package main

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

func solve(N int, a []int) (bool, [][]int) {
	res := [][]int{}
	for i := 0; i < N; i++ {
		res = append(res, make([]int, N))
	}

	counts := map[int]int{}
	for _, n := range a {
		counts[n]++
	}

	oddCount := 0
	centerValue := 0
	for k, v := range counts {
		if v%2 == 1 {
			oddCount++
			centerValue = k
		}
	}

	if oddCount > 1 {
		return false, nil
	}

	mid := N >> 1

	if oddCount == 1 {
		if N%2 == 1 {
			res[mid][mid] = centerValue
			counts[centerValue]--
		} else {
			return false, nil
		}
	}

	center := N >> 1

	components := [][][]int{}

	x, y := 0, 0
	for x < center && y < center {
		com := [][]int{
			[]int{x, y},
			[]int{N - 1 - x, y},
			[]int{x, N - 1 - y},
			[]int{N - 1 - x, N - 1 - y},
		}

		components = append(components, com)

		y++
		if y >= center {
			y = 0
			x++
		}
	}

	if N%2 == 1 {
		x, y = center, 0
		for y < center {
			com := [][]int{
				[]int{x, y},
				[]int{x, N - 1 - y},
			}

			components = append(components, com)

			com = [][]int{
				[]int{y, x},
				[]int{N - 1 - y, x},
			}

			components = append(components, com)

			y++
		}
	}

	for _, com := range components {
		slotsCount := len(com)
		n := 0

		for k, v := range counts {
			if v >= slotsCount {
				n = k
				counts[k] -= slotsCount
			}
			if counts[k] == 0 {
				delete(counts, k)
			}
			if n > 0 {
				break
			}
		}

		if n <= 0 {
			return false, nil
		}

		for _, pair := range com {
			res[pair[0]][pair[1]] = n
		}
	}

	return true, res
}

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

func main() {
	n := 0

	fmt.Scan(&n)
	a := make([]int, n*n)

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	for i := range a {
		scanner.Scan()
		a[i] = toInt(scanner.Bytes())
	}

	valid, res := (solve(n, a))
	if !valid {
		fmt.Println("NO")
		return
	}

	fmt.Println("YES")
	for _, r := range res {
		for _, n := range r {
			fmt.Print(n, " ")
		}
		fmt.Println()
	}
}

package main

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

func fillOdd(mapp [][]int, cnt []int, n int) bool {

	l := len(cnt)
	for i := 0; i < l; i++ {
		if cnt[i]%2==1{
			mapp[n/2][n/2]=i
			cnt[i]--
			break
		}
	}
	for i := 0; i < n/2; i++ {
		index := findC(cnt)
		if index < 0{
			return false
		}
		mapp[n/2][i] = index
		mapp[n/2][n-i-1] = index
		cnt[index]-=2
		index = findC(cnt)
		if index < 0{
			return false
		}
		mapp[i][n/2] = index
		mapp[n-i-1][n/2] = index
		cnt[index]-=2
	}

	if mapp[n/2][n/2] <= 0 {
		return false
	}
	return true
}
func fillEven(mapp [][]int, cnt []int, n int) bool {
	index := 0
	l := len(cnt)
	for i := 0; i < n/2; i++ {
		for j := 0; j < n/2; j++ {
			for index < l {
				if cnt[index]>0&& cnt[index]%4 == 0 {
					break
				}
				index++
			}
			if index >= l {
			//	fmt.Printf("->%d %d\n",i,j)
			//	PrintC(mapp,n)
				return false
			}
			mapp[i][j] = index
			mapp[n-1-i][j] = index
			mapp[i][n-1-j] = index
			mapp[n-1-i][n-1-j] = index
			cnt[index] -= 4
		}
	}
	return true
}
func PrintC(mapp [][]int,n int)  {
	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			if j != 0 {
				fmt.Printf(" ")
			}
			fmt.Printf("%d", mapp[i][j])
		}
		fmt.Printf("\n")
	}
}
func findC(cnt []int) (int) {
	l := len(cnt)
	for i := 0; i < l; i++ {
		if cnt[i] > 0&&cnt[i]%4==2 {
			return i
		}
	}
	for i := 0; i < l; i++ {
		if cnt[i] > 0&&cnt[i]%4==0 {
			return i
		}
	}
	return -1
}
func main() {
	buf := bufio.NewReader(os.Stdin)

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

	mat := make([]int, n*n)
	cnt := make([]int, 1010)
	for i := 0; i < n*n; i++ {
		fmt.Fscanf(buf, "%d", &mat[i])
		cnt[mat[i]]++
	}
	mapp := make([][]int,n)
	for i:=0;i< n;i++{
		mapp[i] = make([]int,n)
	}
	if (n&1)==1&&fillOdd(mapp, cnt, n) == false {
		fmt.Printf("No Even\n")
		return
	}
	if fillEven(mapp, cnt, n) == false {
		fmt.Printf("No\n")
		return
	}
	fmt.Printf("Yes\n")
	PrintC(mapp,n)

}

package main

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

        "sort"
)

func main() {
	n := readInts()[0]
	a := readInts()

        sort.Sort(sort.IntSlice(a))
	r := make([]int, n*n)
	r4, r2h, r2v, r1 := (n/2)*(n/2), (n%2)*(n/2), (n%2)*(n/2), n%2
	for i := 0; i < n*n; {
		switch {
		case r4 > 0 && i < n*n-3 && a[i] == a[i+1] && a[i] == a[i+2] && a[i] == a[i+3]:
			r4 -= 1
			x, y := r4 % (n/2), r4 / (n/2)
			r[x+n*y], r[(n-1-x)+n*y], r[x+n*(n-1-y)], r[(n-1-x)+n*(n-1-y)] = a[i], a[i], a[i], a[i]
			i += 4
		case r2h > 0 && i < n*n-1 && a[i] == a[i+1]:
			r2h -= 1
			r[r2h+n*(n/2)], r[(n-1-r2h)+n*(n/2)] = a[i], a[i]
			i += 2
		case r2v > 0 && i < n*n-1 && a[i] == a[i+1]:
			r2v -= 1
			r[(n/2)+n*r2v], r[(n/2)+n*(n-1-r2v)] = a[i], a[i]
			i += 2
		case r1 > 0:
			r1 -= 1
			r[n*n/2] = a[i]
			i += 1
		default:
			fmt.Println("NO")
			return
		}
	}
	fmt.Println("YES")
	for y := 0; y < n; y++ {
		for x := 0; x < n; x++ {
			fmt.Print(r[x+n*y], " ")
		}
		fmt.Println()
	}
}

var (
	stdin = bufio.NewReader(os.Stdin)
)

func readLine() string {
	s, _ := stdin.ReadString('\n')
	return s
}

func readInts() (r []int) {
	reader := strings.NewReader(readLine())
	for {
		var x int
		_, err := fmt.Fscan(reader, &x)
		if err != nil {
			break
		}
		r = append(r, x)
	}
	return
}

package main

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

func solve(N int, a []int) (string, [][]int) {
	const NO = "NO"
	const YES = "YES"

	res := [][]int{}
	for i := 0; i < N; i++ {
		res = append(res, make([]int, N))
	}

	counts := map[int]int{}
	for _, n := range a {
		counts[n]++
	}

	oddCount := 0
	centerValue := 0
	for k, v := range counts {
		if v%2 == 1 {
			oddCount++
			centerValue = k
		}
	}

	if oddCount > 1 {
		return NO, res
	}

	mid := N >> 1

	if oddCount == 1 {
		if N%2 == 1 {
			res[mid][mid] = centerValue
			counts[centerValue]--
		} else {
			return NO, res
		}
	}

	center := N >> 1

	components := [][][]int{}

	x, y := 0, 0
	for x < center && y < center {
		com := [][]int{
			[]int{x, y},
			[]int{N - 1 - x, y},
			[]int{x, N - 1 - y},
			[]int{N - 1 - x, N - 1 - y},
		}

		components = append(components, com)

		y++
		if y >= center {
			y = 0
			x++
		}
	}

	if N%2 == 1 {
		x, y = center, 0
		for y < center {
			com := [][]int{
				[]int{x, y},
				[]int{x, N - 1 - y},
			}

			components = append(components, com)

			com = [][]int{
				[]int{y, x},
				[]int{N - 1 - y, x},
			}

			components = append(components, com)

			y++
		}
	}

	for _, com := range components {
		slotsCount := len(com)
		n := 0

		for k, v := range counts {
			if v >= slotsCount {
				n = k
				counts[k] -= slotsCount
			}
			if counts[k] < slotsCount {
				delete(counts, k)
			}
			if n > 0 {
				break
			}
		}

		if n <= 0 {
			//fmt.Println(counts)
			return NO, res
		}

		for _, pair := range com {
			res[pair[0]][pair[1]] = n
		}
	}

	return YES, res
}

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

func main() {
	n := 0

	fmt.Scan(&n)
	a := make([]int, n*n)

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	for i := range a {
		scanner.Scan()
		a[i] = toInt(scanner.Bytes())
	}

	fmt.Println(solve(n, a))
}

package main

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

func solve(N int, a []int) (bool, [][]int) {
	res := [][]int{}
	for i := 0; i < N; i++ {
		res = append(res, make([]int, N))
	}

	counts := map[int]int{}
	for _, n := range a {
		counts[n]++
	}

	oddCount := 0
	centerValue := 0
	for k, v := range counts {
		if v%2 == 1 {
			oddCount++
			centerValue = k
		}
	}

	if oddCount > 1 {
		return false, res
	}

	mid := N >> 1

	if oddCount == 1 {
		if N%2 == 1 {
			res[mid][mid] = centerValue
			counts[centerValue]--
		} else {
			return false, res
		}
	}

	center := N >> 1

	components := [][][]int{}

	x, y := 0, 0
	for x < center && y < center {
		com := [][]int{
			[]int{x, y},
			[]int{N - 1 - x, y},
			[]int{x, N - 1 - y},
			[]int{N - 1 - x, N - 1 - y},
		}

		components = append(components, com)

		y++
		if y >= center {
			y = 0
			x++
		}
	}

	if N%2 == 1 {
		x, y = center, 0
		for y < center {
			com := [][]int{
				[]int{x, y},
				[]int{x, N - 1 - y},
			}

			components = append(components, com)

			com = [][]int{
				[]int{y, x},
				[]int{N - 1 - y, x},
			}

			components = append(components, com)

			y++
		}
	}

	for _, com := range components {
		slotsCount := len(com)
		n := 0

		for k, v := range counts {
			if v >= slotsCount {
				n = k
				counts[k] -= slotsCount
			}
			if counts[k] < slotsCount {
				delete(counts, k)
			}
			if n > 0 {
				break
			}
		}

		if n <= 0 {
			return false, res
		}

		for _, pair := range com {
			res[pair[0]][pair[1]] = n
		}
	}

	return true, res
}

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

func main() {
	n := 0

	fmt.Scan(&n)
	a := make([]int, n*n)

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	for i := range a {
		scanner.Scan()
		a[i] = toInt(scanner.Bytes())
	}

	valid, res := (solve(n, a))
	if !valid {
		fmt.Println("NO")
		return
	}

	fmt.Println("YES")
	for _, r := range res {
		for _, n := range r {
			fmt.Print(n, " ")
		}
		fmt.Println()
	}
}


package main

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

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

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

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

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

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

/**
Run solve the problem CF1651B
Date: 18/04/22
User: epradere
URL: https://codeforces.com/problemset/problem/1651/B
Problem: CF1651B
**/
func (in *CF1651B) Run() {
	var str strings.Builder
	for t := in.NextInt(); t > 0; t-- {
		n := in.NextInt()
		if n > 19 {
			str.WriteString("NO\n")
		} else {
			str.WriteString("YES\n")
			value := int64(1)
			for i := 0; i < n; i++ {
				str.WriteString(fmt.Sprintf("%v ", value))
				value *= 3
			}
			str.WriteString("\n")
		}
	}
	fmt.Println(str.String())
}

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

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

package main

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

var in = bufio.NewReader(os.Stdin)

func main() {
	var n int
	fmt.Fscan(in, &n)

	arr := make([]int64, 50)

	arr[0] = 1
	r := 21
	for i := 1; i < r; i += 1 {
		arr[i] = arr[i-1] * 3
		if arr[i] >= int64(1000000000) {
			r = i
			break
		}
	}

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

		if z > r {
			fmt.Printf("NO\n")
			continue
		}

		str := fmt.Sprintf("%v", arr[:z])
		fmt.Printf("YES\n%v\n", str[1:len(str)-1])
	}
	println()
}

package main
// github.com/jamesgrimard/codeforces
import(
    "fmt"
    "bufio"
    "os"
    "math"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var n int
		fmt.Fscan(in,&n)
		if n <= 19 {
			fmt.Fprintln(out,"YES")
			for j:=0;j<n;j++{
				fmt.Fprintf(out,"%v ",int(math.Pow(float64(3),float64(j))))
			}
			fmt.Fprintln(out)
		} else {
			fmt.Fprintln(out,"NO")
		}
	}
}

package main

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

/*
3
5
10
20
*/

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

	arr := make([]int, 0)

	num := int64(1)

	for i := 0; i < n; i++ {
		if num <= 1e9 {
			arr = append(arr, int(num))
			num = 3 * num
		} else {
			fmt.Fprintln(writer, "NO")
			return
		}
	}

	fmt.Fprintln(writer, "YES")
	for _, num := range arr {
		fmt.Fprintf(writer, "%d ", num)
	}
	fmt.Fprintln(writer)
}

//goland:noinspection GoUnhandledErrorResult
func main() {
	defer writer.Flush()

	t := 1
	scanf("%d\n", &t)

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

const maxUint = ^uint(0)

//goland:noinspection GoUnusedConst
const minUint = 0
const maxInt = int(maxUint >> 1)

//goland:noinspection GoUnusedConst
const minInt = -maxInt - 1

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

func scanf(f string, a ...interface{}) {
	if _, err := fmt.Fscanf(reader, f, a...); err != nil {
		panic(err)
	}
}

//goland:noinspection GoUnusedFunction
func reversed(s string) string {
	input := []rune(s)
	li := len(input)
	ret := make([]rune, li)
	for i, r := range input {
		ret[li-i-1] = r
	}
	return string(ret)
}

//goland:noinspection GoUnusedFunction
func divCeil(num, div int) int {
	quot := num / div
	if num%div != 0 {
		quot++
	}
	return quot
}

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

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

	return nums[idx]
}

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

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

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

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

	return true
}

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

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

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

	num = abs(num)

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

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

package main

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

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

const mod = 998244353

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

	for ii := 0; ii < t; ii++ {
		var n int
		fmt.Fscan(in, &n)
		nums := make([]int64, n)
		nums[0] = 1
		ok := true
		for i := 1; i < n; i++ {
			nums[i] = nums[i-1]*3 + 1
			if nums[i] > 1e9 {
				ok = false
				break
			}
		}
		if ok {
			fmt.Fprintln(out, "YES")
			for i := 0; i < n; i++ {
				fmt.Fprint(out, nums[i])
				if i < n-1 {
					fmt.Fprint(out, " ")
				} else {
					fmt.Fprintln(out)
				}
			}
		} else {
			fmt.Fprintln(out, "NO")
		}
	}
}

package main
import ."fmt"

// github.com/EndlessCheng/codeforces-go
func main() {
	var T, n int
	for Scan(&T); T > 0; T-- {
		Scan(&n)
		if n > 19 {
			Println("NO")
			continue
		}
		Println("YES")
		for v := 1; n > 0; n-- {
			Println(v)
			v *= 3
		}
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	a := make([]int, 0)
	a = append(a, 1)
	for {
		b := a[len(a)-1]*3 + 1
		if b >= int(1e9) {
			break
		} else {
			a = append(a, b)
		}
	}
	var t int
	fmt.Fscan(in, &t)
	for ; t > 0; t-- {
		var n int
		fmt.Fscan(in, &n)
		if n > len(a) {
			fmt.Println("NO")
		} else {
			fmt.Println("YES")
			for i := 0; i < n; i++ {
				fmt.Printf("%d ", a[i])
			}
			fmt.Println()
		}
	}
}

package main

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

func main() {
	var (
		t int
	)

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

	for t > 0 {
		t--

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

		/*val := 0
                for i := 0; val < 1e+9; i++ {
                	val = val * 3 + 1
			fmt.Println(val, i+1, "R:", n)
		}*/
		if n > 19 {
			fmt.Println("NO")
		} else {
			fmt.Println("YES")
			val := 0
			for i := 0; i < n; i++ {
                		val = val * 3 + 1
				fmt.Printf("%d ", val)
			}
		}
	}
}

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)
	ar := make([]int64, 0, 500)
	for i := int64(1); i <= 1000_000_000; i *= 3 {
		ar = append(ar, i)
	}
	for ; t > 0; t-- {
		var n int
		fmt.Fscan(in, &n)
		if n <= len(ar) {
			fmt.Fprintln(out, "YES")
			for i := 0; i < n; i++ {
				if i > 0 {
					fmt.Fprint(out, " ")
				}
				fmt.Fprint(out, ar[i])
			}
			fmt.Fprintln(out)
		} else {
			fmt.Fprintln(out, "NO")
		}
	}
}

package main

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

func solve(cin *scanner, cout *writer, cerr *writer) {
	n := cin.NextInt()
	var b []int
	for j := 1; j <= 1000000000; j += j + j {
		b = append(b, j)
	}
	if n <= len(b) {
		cout.Println("YES")
		for i, v := range b[:n] {
			cout.Print(v)
			if i+1 < n {
				cout.Print(" ")
			}
		}
		cout.Println()
	} else {
		cout.Println("NO")
	}

}

func main() {
	cin := NewScanner(os.Stdin)
	cout, cerr := NewWriter(os.Stdout), NewWriter(os.Stderr)
	defer cout.Flush()
	defer cerr.Flush()
	t := cin.NextInt()
	// t := 1
	for ti := 0; ti < t; ti++ {
		solve(cin, cout, cerr)
	}
}

// Template Bolierplate {{{
type scanner struct {
	*bufio.Scanner
}

func NewScanner(r io.Reader) *scanner {
	s := bufio.NewScanner(r)
	s.Split(bufio.ScanWords)
	s.Buffer(nil, 1024*1024)
	return &scanner{s}
}

func (i *scanner) Next() string {
	i.Scan()
	return i.Text()
}

func (i *scanner) Nexts(n int) []string {
	res := make([]string, n)
	for j := range res {
		res[j] = i.Next()
	}
	return res
}

func (i *scanner) NextInt() int {
	v, _ := strconv.Atoi(i.Next())
	return v
}

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

func (i *scanner) NextInts(n int) []int {
	res := make([]int, n)
	for j := range res {
		res[j] = i.NextInt()
	}
	return res
}

func (i *scanner) NextInt64s(n int) []int64 {
	res := make([]int64, n)
	for j := range res {
		res[j] = i.NextInt64()
	}
	return res
}

type writer struct {
	w *bufio.Writer
}

func NewWriter(w io.Writer) *writer {
	return &writer{bufio.NewWriter(w)}
}

func (i *writer) Print(a ...interface{}) {
	fmt.Fprint(i.w, a...)
}

func (i *writer) Println(a ...interface{}) {
	fmt.Fprintln(i.w, a...)
}

func (i *writer) Printf(format string, a ...interface{}) {
	fmt.Fprintf(i.w, format, a...)
}

func (i *writer) Flush() {
	i.w.Flush()
}

// }}}

// vim: fdm=marker

package main

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

var in = bufio.NewReader(os.Stdin)

func main() {
	var n int
	fmt.Fscan(in, &n)

	arr := make([]int64, 50)

	v := int64(1)
	r := 21
	for i := 0; i < r; i += 1 {
		arr[i] = v
		v *= int64(3)
	}

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

		if z > r {
			fmt.Printf("NO\n")
			continue
		}

		str := fmt.Sprintf("%v", arr[:z])
		fmt.Printf("YES\n%v\n", str[1:len(str)-1])
	}
	println()
}

package main

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

var in = bufio.NewReader(os.Stdin)

func main() {
	var n int
	fmt.Fscan(in, &n)

	arr := make([]int64, 50)

	v := int64(1)
	r := -1
	for i := 0; i < 1024; i += 1 {
		arr[i] = v
		v *= int64(3)
		if v >= 1000000000 {
			r = i
			break
		}
	}

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

		if z >= r {
			fmt.Printf("NO\n")
			continue
		}

		str := fmt.Sprintf("%v", arr[:z])
		fmt.Printf("YES\n%v\n", str[1:len(str)-1])
	}
	println()
}

package main

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

var in = bufio.NewReader(os.Stdin)

func main() {
	var n int
	fmt.Fscan(in, &n)

	arr := make([]int64, 50)

	v := int64(1)
	r := -1
	for i := 0; i < 1024; i += 1 {
		arr[i] = v
		v *= int64(3)
		if v >= 1000000000 {
			r = i
			break
		}
	}

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

		if z >= r {
			fmt.Printf("NO\n")
			continue
		}

		str := fmt.Sprintf("%v", arr[:z])
		fmt.Printf("YES\n%v\n", str[1:len(str)-1])
	}
}

package main

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

var in = bufio.NewReader(os.Stdin)

func main() {
	var n int
	fmt.Fscan(in, &n)

	arr := make([]int64, 50)

	v := int64(1)
	r := -1
	for i := 0; i < 1024; i += 1 {
		arr[i] = v
		v *= int64(3)
		if v > 10e9 {
			r = i + 1
			break
		}
	}

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

		if z >= r {
			fmt.Printf("NO\n")
			continue
		}

		str := fmt.Sprintf("%v", arr[:z])
		fmt.Printf("YES\n%v\n", str[1:len(str)-1])
	}
}

package main

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

var in = bufio.NewReader(os.Stdin)

func main() {
	var n int
	fmt.Fscan(in, &n)

	arr := make([]int64, 50)

	v := int64(1)
	r := -1
	for i := 0; i < 1024; i += 1 {
		arr[i] = v
		v *= int64(3)
		if v > 10e9 {
			r = i + 1
			break
		}
	}

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

		if z > r {
			fmt.Printf("NO\n")
			continue
		}

		str := fmt.Sprintf("%v", arr[:z])
		fmt.Printf("YES\n%v\n", str[1:len(str)-1])
	}
}

package main

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

var in = bufio.NewReader(os.Stdin)

func main() {
	var n int
	fmt.Fscan(in, &n)

	arr := make([]int64, 50)

	v := int64(1)
	r := -1
	for i := 0; i < 1024; i += 1 {
		arr[i] = v
		v *= 3
		if v > 10e9 {
			r = i + 1
			break
		}
	}

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

		if z > r {
			fmt.Printf("NO\n")
			continue
		}

		fmt.Printf("YES\n")

		str := fmt.Sprintf("%v", arr[0:z+1])
		fmt.Printf("%v\n", str[1:len(str)-2])
	}
}

package main

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

var in = bufio.NewReader(os.Stdin)

func main() {
	var n int
	fmt.Fscan(in, &n)

	arr := make([]int64, 50)

	v := int64(1)
	r := -1
	for i := 0; i < 1024; i += 1 {
		arr[i] = v
		v *= 3
		if v > 10e9 {
			r = i + 1
			break
		}
	}

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

		if z > r {
			fmt.Printf("NO\n")
			continue
		}

		fmt.Printf("YES\n")

		str := fmt.Sprintf("%v", arr[0:z])
		fmt.Printf("%v\n", str[1:len(str)-2])
	}
}

package main
// github.com/jamesgrimard/codeforces
import(
    "fmt"
    "bufio"
    "os"
    "math"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var n int
		fmt.Fscan(in,&n)
		if n < 19 {
			fmt.Fprintln(out,"YES")
			for j:=0;j<n;j++{
				fmt.Fprintf(out,"%v ",int(math.Pow(float64(3),float64(j))))
			}
			fmt.Fprintln(out)
		} else {
			fmt.Fprintln(out,"NO")
		}
	}
}

package main
// github.com/jamesgrimard/codeforces
import(
    "fmt"
    "bufio"
    "os"
    "math"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var n int
		fmt.Fscan(in,&n)
		if (n%2 == 1 || n == 2) && n <= 19 {
			fmt.Fprintln(out,"YES")
			for j:=0;j<n;j++{
				fmt.Fprintf(out,"%v ",int(math.Pow(float64(3),float64(j))))
			}
			fmt.Fprintln(out)
		} else {
			fmt.Fprintln(out,"NO")
		}
	}
}

package main
// github.com/jamesgrimard/codeforces
import(
    "fmt"
    "bufio"
    "os"
    "math"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var n int
		fmt.Fscan(in,&n)
		if (n%2 == 1 || n == 2) && n < 19 {
			fmt.Fprintln(out,"YES")
			for j:=0;j<n;j++{
				fmt.Fprintf(out,"%v ",int(math.Pow(float64(3),float64(j))))
			}
			fmt.Fprintln(out)
		} else {
			fmt.Fprintln(out,"NO")
		}
	}
}

package main
// github.com/jamesgrimard/codeforces
import(
    "fmt"
    "bufio"
    "os"
    "math"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var n int
		fmt.Fscan(in,&n)
		if (n%2 == 1 || n == 2) && int(math.Pow(float64(3),float64(n))) <= int(math.Pow(float64(10),float64(9))) {
			fmt.Fprintln(out,"YES")
			for j:=0;j<n;j++{
				fmt.Fprintf(out,"%v ",int(math.Pow(float64(3),float64(j))))
			}
			fmt.Fprintln(out)
		} else {
			fmt.Fprintln(out,"NO")
		}
	}
}

package main
// github.com/jamesgrimard/codeforces
import(
    "fmt"
    "bufio"
    "os"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var n int
		fmt.Fscan(in,&n)
		if n%2 == 1 || n == 2 {
			fmt.Fprintln(out,"YES")
			var sum int
			for j:=1;j<=n;j++{
				sum = sum * j + 1
				fmt.Fprintf(out,"%v ",sum)
			}
			fmt.Fprintln(out)
		} else {
			fmt.Fprintln(out,"NO")
		}
	}
}

package main

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

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

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

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

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

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

/**
Run solve the problem CF1651B
Date: 18/04/22
User: epradere
URL: https://codeforces.com/problemset/problem/1651/B
Problem: CF1651B
**/
func (in *CF1651B) Run() {
	var str strings.Builder
	for t := in.NextInt(); t > 0; t-- {
		n := in.NextInt()
		if n > 18 {
			str.WriteString("NO\n")
		} else {
			str.WriteString("YES\n")
			value := int64(1)
			for i := 0; i < n; i++ {
				str.WriteString(fmt.Sprintf("%v ", value))
				value *= 3
			}
			str.WriteString("\n")
		}
	}
	fmt.Println(str.String())
}

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

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

package main

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

/*
3
5
10
20
*/

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

	arr := make([]int, 0)

	num := int64(1)

	for i := 0; i < n; i++ {
		if num <= 1e9 {
			arr = append(arr, int(num))
			num = 2*num + 1
		} else {
			fmt.Fprintln(writer, "NO")
			return
		}
	}

	fmt.Fprintln(writer, "YES")
	for _, num := range arr {
		fmt.Fprintf(writer, "%d ", num)
	}
	fmt.Fprintln(writer)
}

//goland:noinspection GoUnhandledErrorResult
func main() {
	defer writer.Flush()

	t := 1
	scanf("%d\n", &t)

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

const maxUint = ^uint(0)

//goland:noinspection GoUnusedConst
const minUint = 0
const maxInt = int(maxUint >> 1)

//goland:noinspection GoUnusedConst
const minInt = -maxInt - 1

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

func scanf(f string, a ...interface{}) {
	if _, err := fmt.Fscanf(reader, f, a...); err != nil {
		panic(err)
	}
}

//goland:noinspection GoUnusedFunction
func reversed(s string) string {
	input := []rune(s)
	li := len(input)
	ret := make([]rune, li)
	for i, r := range input {
		ret[li-i-1] = r
	}
	return string(ret)
}

//goland:noinspection GoUnusedFunction
func divCeil(num, div int) int {
	quot := num / div
	if num%div != 0 {
		quot++
	}
	return quot
}

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

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

	return nums[idx]
}

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

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

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

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

	return true
}

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

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

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

	num = abs(num)

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

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