In Omkar's last class of math, he learned about the least common multiple, or $$$LCM$$$. $$$LCM(a, b)$$$ is the smallest positive integer $$$x$$$ which is divisible by both $$$a$$$ and $$$b$$$.Omkar, having a laudably curious mind, immediately thought of a problem involving the $$$LCM$$$ operation: given an integer $$$n$$$, find positive integers $$$a$$$ and $$$b$$$ such that $$$a + b = n$$$ and $$$LCM(a, b)$$$ is the minimum value possible.Can you help Omkar solve his ludicrously challenging math problem?

Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \leq t \leq 10$$$). Description of the test cases follows. Each test case consists of a single integer $$$n$$$ ($$$2 \leq n \leq 10^{9}$$$).

For each test case, output two positive integers $$$a$$$ and $$$b$$$, such that $$$a + b = n$$$ and $$$LCM(a, b)$$$ is the minimum possible.

NoteFor the first test case, the numbers we can choose are $$$1, 3$$$ or $$$2, 2$$$. $$$LCM(1, 3) = 3$$$ and $$$LCM(2, 2) = 2$$$, so we output $$$2 \ 2$$$.For the second test case, the numbers we can choose are $$$1, 5$$$, $$$2, 4$$$, or $$$3, 3$$$. $$$LCM(1, 5) = 5$$$, $$$LCM(2, 4) = 4$$$, and $$$LCM(3, 3) = 3$$$, so we output $$$3 \ 3$$$.For the third test case, $$$LCM(3, 6) = 6$$$. It can be shown that there are no other pairs of numbers which sum to $$$9$$$ that have a lower $$$LCM$$$.

fun main() {
    for (c in 1..readLine()!!.toInt()) {
        val n = readLine()!!.toInt()
        var p = 0
        for (m in 2..100000) {
            if (n % m == 0) {
                p = m
                break
            }
        }
        if (p == 0) {
            p = n
        }
        println("${n / p} ${n - (n / p)}")
    }
}

import kotlin.math.sqrt

fun main() {

    repeat(readLine()!!.toInt()) {
        val num = readLine()!!.toInt()
        val leastPrime = leastPrime(num)
        println("${num / leastPrime} ${num / leastPrime * (leastPrime - 1)}")
    }
}

fun leastPrime(n: Int): Int {
    var num = 2
    if (n % 2 == 0)
        return 2
    num += 1
    while (n % num != 0 && num < sqrt(n.toDouble())) {
        num += 2
    }
    if (num > sqrt(n.toDouble()))
        return n
    return num
}

import java.util.*
import kotlin.collections.*
import kotlin.math.*

fun readInts() = readLine()!!.split(" ").map{i -> i.toInt()}.toMutableList()
fun readInt() = readLine()!!.toInt()
fun readLongs() = readLine()!!.split(" ").map{i -> i.toLong()}.toMutableList()

fun main() {
    val t = readInt()
    repeat(t) {
        val n = readInt()
        var a = 0
        for(i in 2..sqrt(n.toDouble()).toInt()) {
            if (n % i == 0) {
                a = n / i
                break
            }
        }
        println(if(a == 0) "1 ${n - 1}" else "$a ${n - a}")
    }
}

import java.lang.Math.*

private fun readLn() = readLine()!! // string line
private fun readStrings() = readLn().split(" ") // list of strings
private fun readLong() = readLn().toLong()
private fun readLongs() = readStrings().map { it.toLong() } // list of ints
private fun readInt() = readLn().toInt() // single int
private fun readInts() = readStrings().map { it.toInt() } // list of ints

//var n = 0
//var ar = listOf<Int>()
val visited = mutableSetOf<Char>()
val graph = mutableMapOf<Char, MutableList<Char>>()

fun main() {
    val t = readInt()
    for (cases in 0 until t) {
        solve()
    }

//    solve()
}

fun solve() {
    val n = readInt()

    var ans1 = 1
    var ans2 = n - 1
    var min = n - 1
    for (i in 2 until sqrt(n.toDouble()).toInt() + 1) {
        if (n % i == 0) {
            val d = n / i
            if ((i - 1) * d < min) {
                ans1 = d
                ans2 = (i - 1) * d
                min = ans2
            }

        }
    }

    println("$ans1 $ans2")
}

fun main(args: Array<String>) {
    var numberTests = readLine()!!.toInt()
    var results = mutableListOf<String>()

    for (i in 0..numberTests-1) {
        var n = readLine()!!.toLong()
        val result = experimentB(n)
        results.add(result)
    }

    for (result in results) {
        println(result)
    }
}

fun experimentB(n : Long) : String {
    var result = ""

    if (n % 2 == 0L) {
        result = "${n / 2} ${n / 2}"
    } else {
        val divideList = divisor(n)
//        println(divideList)
        val candidate = divideList.takeLast(2) [0]
//        println (candidate)
        result = "${candidate} ${n - candidate}"
    }

    return result
}

// 約数のList
fun divisor(value : Long) : List<Long> {
    val max = Math.sqrt(value.toDouble()).toLong()
    return (1..max)
            .filter { value % it == 0L }
            .map { listOf(it, value / it) }
            .flatten()
            .sorted()
}

fun main() {
    repeat(readLine()!!.toInt()) {
        val n = readLine()!!.toInt()
        var d = 2
        while (d * d <= n) {
            if (n % d == 0) break
            d++
        }
        if (n % d == 0) {
            val a = n / d
            println("$a ${n - a}")
        } else {
            println("1 ${n - 1}")
        }
    }
}

import kotlin.math.sqrt

fun solve(n: Int) {
    var i = 2
    val limit = (sqrt(n.toDouble()) + 1).toInt()
    while (n % i != 0) {
        ++i
        if (i == limit) {
            println("1 ${n - 1}")
            return@solve
        }
    }
    println("${n / i} ${n / i * (i - 1)}")
}

fun main() {
    val t = readLine()!!.toInt()
    for (i in 1..t ) {
        solve(readLine()!!.toInt())
    }
}

import java.io.IOException
import java.io.InputStream
import java.util.*

fun main(args : Array<String>){
    val reader =InputReader(System.`in`)
    val t = reader.readInt()
    repeat(t){
        val n = reader.readInt()
        var found = false
            for (i in 2 until Math.sqrt(n.toDouble()).toInt() + 1) {
                if (n % i == 0) {
                    val factor = n / i     //greatest factor
                    println("$factor ${n - factor}")
                    found = true
                    break
                }
            }
         if (!found){
             println("1 ${n-1}")
         }
        }
}

internal class InputReader(private val stream: InputStream) {
    private val buf = ByteArray(1024)
    private var curChar: Int = 0
    private var numChars: Int = 0
    private val filter: SpaceCharFilter? = null

    fun read(): Int {
        if (numChars == -1)
            throw InputMismatchException()
        if (curChar >= numChars) {
            curChar = 0
            try {
                numChars = stream.read(buf)
            } catch (e: IOException) {
                throw InputMismatchException()
            }

            if (numChars <= 0)
                return -1
        }
        return buf[curChar++].toInt()
    }

    fun readInt(): Int {
        var c = read()
        while (isSpaceChar(c))
            c = read()
        var sgn = 1
        if (c == '-'.toInt()) {
            sgn = -1
            c = read()
        }
        var res = 0
        do {
            if (c < '0'.toInt() || c > '9'.toInt())
                throw InputMismatchException()
            res *= 10
            res += c - '0'.toInt()
            c = read()
        } while (!isSpaceChar(c))
        return res * sgn
    }

    fun readString(): String {
        var c = read()
        while (isSpaceChar(c))
            c = read()
        val res = StringBuilder()
        do {
            res.appendCodePoint(c)
            c = read()
        } while (!isSpaceChar(c))
        return res.toString()
    }

    fun isSpaceChar(c: Int): Boolean {
        return filter?.isSpaceChar(c)
            ?: (c == ' '.toInt() || c == '\n'.toInt() || c == '\r'.toInt() || c == '\t'.toInt() || c == -1)
    }

    operator fun next(): String {
        return readString()
    }

    interface SpaceCharFilter {
        fun isSpaceChar(ch: Int): Boolean
    }
}

fun main() {
    val t = readInt()
    fun findOther(x: Int, n: Int): Int {
        val a = n/x - 1
        return a * x
    }

    repeat(t) {
        val n = readInt()
        if (n % 2 == 0) println("${n/2} ${n/2}")
        else {
            var divisor = 1
            val candidates = mutableListOf<Int>()
            while (divisor * divisor <= n) {
                if (n % divisor == 0) {
                    candidates.add(divisor)
                    if (divisor != 1 && divisor * divisor != n) candidates.add(n/divisor)
                }

                divisor += 2
            }
            val ans = candidates.map { Pair(it, findOther(it, n)) }.minBy { it.second }!!
            println("${ans.first} ${ans.second}")
        }
    }
}

// Input Reader
private fun readLn() = readLine()!!

private fun readStrings() = readLn().trim().split(" ")
private fun readInt() = readLn().toInt()
private fun readInts() = readStrings().map { it.toInt() }

@file:Suppress("NOTHING_TO_INLINE", "EXPERIMENTAL_FEATURE_WARNING", "OVERRIDE_BY_INLINE")
//@file:OptIn(ExperimentalStdlibApi::class)

import java.io.PrintWriter
import kotlin.math.*
import kotlin.random.Random
import kotlin.collections.sort as _sort
import kotlin.collections.sortDescending as _sortDescending
import kotlin.io.println as iprintln

/** @author Spheniscine */
fun main() { _writer.solve(); _writer.flush() }

fun PrintWriter.solve() {
    //val startTime = System.nanoTime()

    val numCases = readInt()
    case@ for(case in 1..numCases) {
        //print("Case #$case: ")

        val n = readInt()

        val p = run p@ {
            n.factorize { return@p it }
            n
        }

        val a = n/p
        val b = n - a

        println("$a $b")
    }

//    iprintln("Time: ${(System.nanoTime() - startTime) / 1000000} ms")
}

inline fun Int.factorize(yield: (Int) -> Unit)  {
    var n = this

    for(p in 2..n) {
        if(p * p > n) break

        while(n % p == 0) {
            yield(p)
            n /= p
        }
    }

    if(n > 1) yield(n)
}

/** IO */
//@JvmField val INPUT = File("input.txt").inputStream()
//@JvmField val OUTPUT = File("output.txt").outputStream()
@JvmField val INPUT = System.`in`
@JvmField val OUTPUT = System.out

const val _BUFFER_SIZE = 1 shl 16
@JvmField val _buffer = ByteArray(_BUFFER_SIZE)
@JvmField var _bufferPt = 0
@JvmField var _bytesRead = 0

tailrec fun readChar(): Char {
    if(_bufferPt == _bytesRead) {
        _bufferPt = 0
        _bytesRead = INPUT.read(_buffer, 0, _BUFFER_SIZE)
    }
    return if(_bytesRead < 0) Char.MIN_VALUE
    else {
        val c = _buffer[_bufferPt++].toChar()
        if (c == '\r') readChar()
        else c
    }
}

fun readLine(): String? {
    var c = readChar()
    return if(c == Char.MIN_VALUE) null
    else buildString {
        while(c != '\n' && c != Char.MIN_VALUE) {
            append(c)
            c = readChar()
        }
    }
}
fun readLn() = readLine()!!

fun read() = buildString {
    var c = readChar()
    while(c <= ' ') {
        if(c == Char.MIN_VALUE) return@buildString
        c = readChar()
    }
    do {
        append(c)
        c = readChar()
    } while(c > ' ')
}
fun readInt() = read().toInt()
fun readDouble() = read().toDouble()
fun readLong() = read().toLong()
fun readStrings(n: Int) = List(n) { read() }
fun readLines(n: Int) = List(n) { readLn() }
fun readInts(n: Int) = List(n) { read().toInt() }
fun readIntArray(n: Int) = IntArray(n) { read().toInt() }
fun readDoubles(n: Int) = List(n) { read().toDouble() }
fun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }
fun readLongs(n: Int) = List(n) { read().toLong() }
fun readLongArray(n: Int) = LongArray(n) { read().toLong() }

@JvmField val _writer = PrintWriter(OUTPUT, false)

/** shuffles and sort overrides to avoid quicksort attacks */
private inline fun <T> _shuffle(rnd: Random, get: (Int) -> T, set: (Int, T) -> Unit, size: Int) {
    // Fisher-Yates shuffle algorithm
    for (i in size - 1 downTo 1) {
        val j = rnd.nextInt(i + 1)
        val temp = get(i)
        set(i, get(j))
        set(j, temp)
    }
}

@JvmField var _random: Random? = null
val random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }

fun IntArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)
fun IntArray.sort() { shuffle(); _sort() }
fun IntArray.sortDescending() { shuffle(); _sortDescending() }

fun LongArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)
fun LongArray.sort() { shuffle(); _sort() }
fun LongArray.sortDescending() { shuffle(); _sortDescending() }

fun DoubleArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)
fun DoubleArray.sort() { shuffle(); _sort() }
fun DoubleArray.sortDescending() { shuffle(); _sortDescending() }

fun CharArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)
inline fun CharArray.sort() { _sort() }
inline fun CharArray.sortDescending() { _sortDescending() }

inline fun <T: Comparable<T>> Array<out T>.sort() = _sort()
inline fun <T: Comparable<T>> Array<out T>.sortDescending() = _sortDescending()
inline fun <T: Comparable<T>> MutableList<out T>.sort() = _sort()
inline fun <T: Comparable<T>> MutableList<out T>.sortDescending() = _sortDescending()

fun `please stop removing these imports IntelliJ`() { iprintln(max(1, 2)) }

/** additional commons */
inline fun <T> Iterable<T>.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }
inline fun <T> Sequence<T>.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }
inline fun <T> Array<T>.sumByLong(func: (T) -> Long) = fold(0L) { acc, t -> acc + func(t) }
fun IntArray.sumLong() = fold(0L, Long::plus)

import java.io.BufferedReader
import java.io.IOException
import java.io.InputStreamReader
import java.util.*

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong() // single int
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map { it.toInt() } // list of ints
private fun readLongs() = readStrings().map { it.toLong() } // list of longs

fun main(args: Array<String>) {
    b()
}

fun divisor(n: Int): Int {
    var i = 2
    while (i * i <= n) {
        if (n % i == 0) return i
        i++
    }
    return n
}

fun a() {
    repeat(readInt()) {
        val n = readInt()
        val a = List<Int>(n) { 1 }
        println(a.joinToString(separator = " "))
    }
}

fun pow(a: Int, b: Int): Long {
    var res = 1L
    repeat(b) { res *= a }
    return res
}

fun adj(i: Int, j: Int, n: Int, m: Int): Int {
    var adj = 4
    if (i == 0) adj--
    if (j == 0) adj--
    if (i == n - 1) adj--
    if (j == m - 1) adj--
    return adj
}

fun activeAdj(i: Int, j: Int, n: Int, m: Int, a: Array<IntArray>): Int {
    var activeAdj = 0
    if (i - 1 >= 0 && a[i - 1][j] > 0) activeAdj++
    if (j - 1 >= 0 && a[i][j - 1] > 0) activeAdj++
    if (i + 1 < n && a[i + 1][j] > 0) activeAdj++
    if (j + 1 < m && a[i][j + 1] > 0) activeAdj++
    return activeAdj
}

fun b() {
    repeat(readInt()) {
        val n = readInt()
        val divisor = leastDivisor(n)

        if (divisor == 1) {
            println("1 ${n - 1}")
        } else {
            println("${n / divisor} ${n - n / divisor}")
        }
    }
}

fun c() {
    repeat(readInt()) {
        val n = readInt()
        val a = readInts()

        val right = mutableListOf<Int>()
        val notRight = mutableListOf<Int>()

        for (i in 0 until n) {
            if (a[i] == i + 1) {
                right.add(i)
            } else {
                notRight.add(i)
            }
        }

        if (notRight.isEmpty()) {
            println(0)
            return@repeat
        }

        var isSubsequent = true
        for (i in 1 until notRight.size) {
            if (notRight[i] != notRight[i - 1] + 1) {
                isSubsequent = false
                break
            }
        }

        if (isSubsequent) {
            println(1)
            return@repeat
        }

        println(2)
    }
}

fun df(a: IntArray): Pair<Triple<Long, Int, Int>, Triple<Long, Int, Int>> {

    var dif = 0L
    var lastIndex = 0
    var maxDif = 0L
    var maxIndex = 0
    var maxLength = 0
    for (i in 0 until a.size - 1 step 2) {
        dif += a[i + 1] - a[i]
        if (dif <= 0) {
            dif = 0
            lastIndex = i + 2
            continue
        }
        if (dif > maxDif) {
            maxDif = dif
            maxIndex = lastIndex
            maxLength = i + 2 - lastIndex
        }
    }

    var dif1 = 0L
    var lastIndex1 = 1
    var maxDif1 = 0L
    var maxIndex1 = 0
    var maxLength1 = 0
    for (i in 1 until a.size - 1 step 2) {
        dif1 += a[i + 1] - a[i]
        if (dif1 >= 0) {
            dif1 = 0
            lastIndex1 = i + 2
            continue
        }
        if (dif1 < maxDif1) {
            maxDif1 = dif1
            maxIndex1 = lastIndex1
            maxLength1 = i + 2 - lastIndex1
        }
    }

    return Pair(Triple(maxDif, maxIndex, maxLength), Triple(-maxDif1, maxIndex1, maxLength1))
}

data class MyPair(var first: Int, var second: Int) : Comparable<MyPair> {
    override fun compareTo(other: MyPair): Int {
        return this.first - other.first
    }

}

fun d() {
    val n = readInt()
    val a = readInts()

    var oddSum = 0L
    var evenSum = 0L

    for (i in 0 until n) {
        if (i % 2 == 0) {
            evenSum += a[i]
        } else {
            oddSum += a[i]
        }
    }

//    val maxOdd = oddSum + maxOf()
}

fun f() {
    val (n, m, q) = readInts()
    val a = Array(n) { IntArray(m) }

    val rows = LongArray(n)
    val columns = LongArray(m)

    for (i in 0 until n) {
        a[i] = readInts().toIntArray()

        for (j in 0 until m) {
            rows[i] = rows[i] + a[i][j]
            columns[j] = columns[j] + a[i][j]
        }
    }

    val rowsP = LongArray(n)
    val rowsS = LongArray(n)

    val rowsPM = LongArray(n)
    val rowsSM = LongArray(n)

    val columnsP = LongArray(m)
    val columnsS = LongArray(m)

    val columnsPM = LongArray(m)
    val columnsSM = LongArray(m)

    for (i in 0 until q + 1) {
        if (i != 0) {
            val (x, y, z) = readInts()
            val diff = z - a[x - 1][y - 1]
            rows[x - 1] = rows[x - 1] + diff
            columns[y - 1] = columns[y - 1] + diff
            a[x - 1][y - 1] = z
        }

        rowsP[0] = rows[0]
        for (j in 1 until n) {
            rowsP[j] = rowsP[j - 1] + rows[j]
            rowsPM[j] = rowsP[j - 1] + rowsPM[j - 1]
        }

        rowsS[n - 1] = rows[n - 1]
        for (j in n - 2 downTo 0) {
            rowsS[j] = rowsS[j + 1] + rows[j]
            rowsSM[j] = rowsS[j + 1] + rowsSM[j + 1]
        }

        columnsP[0] = columns[0]
        for (j in 1 until m) {
            columnsP[j] = columnsP[j - 1] + columns[j]
            columnsPM[j] = columnsP[j - 1] + columnsPM[j - 1]
        }

        columnsS[m - 1] = columns[m - 1]
        for (j in m - 2 downTo 0) {
            columnsS[j] = columnsS[j + 1] + columns[j]
            columnsSM[j] = columnsS[j + 1] + columnsSM[j + 1]
        }

        var minRow = minOf(rowsSM[0], rowsPM[n - 1])
        for (j in 1 until n - 1) {
            minRow = minOf(minRow, rowsSM[j] + rowsPM[j])
        }

        var minColumn = minOf(columnsSM[0], columnsPM[m - 1])
        for (j in 1 until m - 1) {
            minColumn = minOf(minColumn, columnsSM[j] + columnsPM[j])
        }

        print("${minRow + minColumn}\n")
    }
}

private inline fun sqr(x: Int) = 1L * x * x

val t = IntArray(2_200_000)

fun build(a: IntArray, v: Int, tl: Int, tr: Int) {
    if (tl == tr) {
        t[v] = a[tl]
    } else {
        val tm = (tl + tr) / 2
        build(a, v * 2, tl, tm)
        build(a, v * 2 + 1, tm + 1, tr)
        t[v] = t[v * 2] + t[v * 2 + 1]
    }

//    println("$v [$tl, $tr] = ${t[v]}")
}

fun update(v: Int, tl: Int, tr: Int, pos: Int): Int {
    if (tl == tr) {
        t[v]++
        return t[v]
    } else {
        val tm = (tl + tr) / 2
        val res = if (pos <= tm) {
            update(v * 2, tl, tm, pos)
        } else {
            update(v * 2 + 1, tm + 1, tr, pos)
        }
        t[v] = t[v * 2] + t[v * 2 + 1]
        return res
    }
}

fun delete(v: Int, tl: Int, tr: Int, pos: Int): Int {
//    println("$v [$tl, $tr] = ${t[v]}, pos = $pos")
    if (tl == tr) {
        t[v]--
        return tl
    } else {
        val tm = (tl + tr) / 2
        val res = if (pos <= t[v * 2]) {
            delete(v * 2, tl, tm, pos)
        } else {
            delete(v * 2 + 1, tm + 1, tr, pos - t[v * 2])
        }
        t[v] = t[v * 2] + t[v * 2 + 1]
        return res
    }
}

fun e() {
    val N = 1_00_000
    val f = IntArray(N)
    for (i in 0 until N) {
        f[i] = f[i / 10] + i % 10
    }

    val max = f.max()!!

//    println(max)

    repeat(readInt()) {
        val (n, k) = readInts()

        if (max * (k + 1) >= n) {
            var sum = 0
            for (i in 0 until k + 1) {
                sum += f[i]
            }

            if (n == sum) {
                println(0)
                return@repeat
            }

            for (i in 1 until N - k) {
                sum -= f[i - 1]
                sum += f[i + k]

                if (n == sum) {
                    println(i)
                    return@repeat
                }
            }
        }

        val res = StringBuilder()
        res.append('9')
        var sum = (9 - k..9).sum()

        println("$res $sum")

        while (sum < n) {
            res.append('9')
            sum += 9 * (k + 1)

            println("$res $sum")

            if (sum == n) {
                res[res.length - 1] = '9' - k
                println(res)
                return@repeat
            }
            if (sum > n) {
                sum -= 9 * (k + 1)
                for (i in 1 until 9) {
                    if (sum + i * (k + 1) == n) {
                        res[0] = '0' + i
                        res[res.length - 1] = '9' - k
                        println(res)
                        return@repeat
                    }
                }
                break
            }
        }

        println(-1)
    }
}

internal class FastScanner {
    var br: BufferedReader = BufferedReader(InputStreamReader(System.`in`))
    var st: StringTokenizer? = null

    operator fun next(): String {
        while (st == null || !st!!.hasMoreElements()) {
            try {
                st = StringTokenizer(br.readLine())
            } catch (e: IOException) {
                e.printStackTrace()
            }
        }
        return st!!.nextToken()
    }

    fun nextInt(): Int {
        return next().toInt()
    }
}

fun Int.isEven(): Boolean = this % 2 == 0
fun Int.isOdd(): Boolean = this % 2 == 1

public operator fun <T> List<T>.component6(): T {
    return get(5)
}

fun allPrimesUpTo(n: Int): List<Int> {
    val isPrime = BooleanArray(n + 1) { true }
    val primes = mutableListOf<Int>()

    isPrime[0] = false
    isPrime[1] = false
    for (i in 2 until n + 1) {
        if (isPrime[i]) {
            primes.add(i)

            if (i.toLong() * i > n)
                continue

            for (j in i * i until n + 1 step i) {
                isPrime[j] = false
            }
        }
    }

    return primes
}

fun leastDivisor(n: Int): Int {
    if (n % 2 == 0) return 2
    if (n % 3 == 0) return 3
    if (n % 5 == 0) return 5

    for (i in 7 until n) {
        if (i * i > n) break

        if (n % i == 0) {
            return i
        }
    }

    return 1
}

import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val t = sc.nextInt()
    for (_i in 0 until t) {
        val n = sc.nextInt()
        var p = -1
        var d = 2
        while (d * d <= n) {
            if (n % d == 0) {
                p = d
                break
            }
            d++
        }
        if (p == -1) p = n
        val v = n / p
        println("$v ${n - v}")
    }
}

fun main() {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

import java.util.*
import kotlin.math.*

fun main() {
    val scanner = Scanner(System.`in`)
    val n = scanner.nextInt()
    for (i in 0 until n) {
        val total = scanner.nextInt().toDouble()
        if (total.toInt() % 2 == 0) {
            println("${total.toInt() / 2} ${total.toInt() / 2}")
        } else {
            val x = floor(sqrt(total)).toInt()
            var flag = false
            for (j in 3..x) {
                if (total.toInt() % j == 0) {
                    flag = true
                    println("${total.toInt() / j} ${total.toInt() - (total.toInt() / j)}")
                    break;
                }
            }
            if (!flag) {
                println("1 ${total.toInt() - 1}")
            }
        }
    }
}

import java.io.BufferedReader

fun main() {
    val br = System.`in`.bufferedReader()
    val sb = StringBuilder()
    val t = br.readInt()
    repeat(t) {
        val n = br.readInt()
        var i = 2
        var found = false
        while (i * i <= n) {
            if (n % i == 0) {
                found = true
                sb.append(n / i).append(' ').append(n - (n / i)).append('\n')
                break
            }
            i++
        }
        if (!found) {
            sb.append(1).append(' ').append(n - 1).append('\n')
        }
    }
    print(sb)
}

private const val SPACE_INT = ' '.toInt()
private const val ZERO_INT = '0'.toInt()
private const val NL_INT = '\n'.toInt()

private fun BufferedReader.readInt(): Int {
    var ret = read()
    while (ret <= SPACE_INT) {
        ret = read()
    }
    val neg = ret == '-'.toInt()
    if (neg) {
        ret = read()
    }
    ret -= ZERO_INT
    var read = read()
    while (read >= ZERO_INT) {
        ret *= 10
        ret += read - ZERO_INT
        read = read()
    }

    while (read <= SPACE_INT && read != -1 && read != NL_INT) {
        mark(1)
        read = read()
    }
    if (read > SPACE_INT) {
        reset()
    }
    return if (neg) -ret else ret
}

import java.lang.Integer.max
import kotlin.math.sqrt

fun main() {
    val t= readInt()
    repeat(t){
        val n = readInt()
        if(n%2==0){
            println("${n/2} ${n/2}")
        }
        else{
            val firstPrimeMultiple = findFirstPrimeMultiple(n)
            if(firstPrimeMultiple == n) println("${n-1} 1")
            else {
                val number = (n.div(firstPrimeMultiple))
                println("$number ${n-number}")
            }
        }
    }
}

fun findFirstPrimeMultiple(n: Int): Int{
    repeat(sqrt(n.toDouble()).toInt()+10){
        if(it >1) {
            val remaining = (n / it).toInt()
            if (remaining * it == n) return it
        }
    }
    return n
}

fun getNumber(row: Int, col: Int, n: Int, m: Int, cell: Int): Int {
    var number = 0
    if(row+1<n) number = number +1
    if (col+1<m) number = number +1
    if (row-1>=0) number = number +1
    if (col-1>=0) number = number +1
    return number
}

private fun isValid(row: Int, col: Int, n: Int, m: Int, cell: Int): Boolean {
    var number = 0
    if(row+1<n) number = number +1
    if (col+1<m) number = number +1
    if (row-1>=0) number = number +1
    if (col-1>=0) number = number +1
    return cell <=number
}

private fun readLn() = readLine()!!
private fun readInt() = readLn().toInt()
private fun readStrings() = readLn().split(" ")
private fun readInts() = readStrings().map { it.toInt() }
private fun readLongs() = readStrings().map { it.toLong() }

import java.util.*

fun main(args: Array<String>) {
    val scan = Scanner(System.`in`)
    val count = scan.nextInt()
    for (i in 0 until count) {
        val n = scan.nextLong()
        var divider = 2
        while (n % divider != 0L && divider <= n / divider.toFloat()) divider++
        val a = if (n % divider == 0L) n / divider else 1
        println("$a ${n - a}")
    }
}

//package cf1372

import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.StringTokenizer

class B {
    private val input: BufferedReader = BufferedReader(InputStreamReader(System.`in`))
    private val output: PrintWriter = PrintWriter(System.out)

    var st: StringTokenizer? = null

    private fun closeAfter() {
        input.close()
        output.close()
    }

    private fun next(): String {
        if (st == null || !st!!.hasMoreElements()) {
            st = StringTokenizer(input.readLine())
        }

        return st!!.nextToken()
    }

    private fun nextInt(): Int {
        return next().toInt()
    }

    private fun nextDouble(): Double {
        return next().toDouble()
    }

    fun solve() {
        innerSolve()
        closeAfter()
    }

    private fun innerSolve() {
        val tt = nextInt()
        for (t in 0 until tt) {
            val n = nextInt()
            if (n % 2 == 0) {
                output.println("${n / 2} ${n / 2}")
            } else {
                var a = 1
                var b = n - 1

                var i = 3

                while (i <= Math.sqrt(1.0 * n).toInt()) {

                    if (n % i == 0) {
                        a = n / i
                        b = n - a
                        break
                    }
                    i += 2
                }

                output.println("$a $b")
            }
        }
    }
}

fun main(args: Array<String>) {
    B().solve()
}

fun main() {
    repeat(readInt()) {
        val n = readInt()
        var ans = 1
        var minLcm = n - 1

        var i = 2
        while (i * i <= n) {
            if (n % i == 0) {
                val curLcm = lcm(i, n - i)
                if (curLcm < minLcm) {
                    minLcm = curLcm
                    ans = i
                }

                val curLcm2 = lcm(n / i, n - n / i)
                if (curLcm2 < minLcm) {
                    minLcm = curLcm2
                    ans = n / i
                }
            }

            i++
        }

        val second = n - ans
        print("$ans $second\n")

    }
}

fun readInt(): Int = readLine()!!.toInt()

fun gcd(a: Int, b: Int): Int {
    if (a == 0 || b == 0)
        return a + b

    return if (a > b) gcd(a % b, b) else gcd(a, b % a)
}

fun lcm(a: Int, b: Int): Int = a / gcd(a, b) * b

import java.io.File
import java.util.*

fun readInt(): Int {
    return sc.nextInt()
}

fun readInts(): IntArray {
    var line = sc.nextLine()
    if (line.trim().isEmpty()) {
        line = sc.nextLine()
    }
    return line.split(" ").map { it.toInt() }.toIntArray()
}

var debug = false
var sc = Scanner(System.`in`)
fun main(args: Array<String>) {
    val input = File("input.in")
    if (input.exists()) {
        debug = true
        sc = Scanner(input)
    }
    val testCount = readInt()
    for (i in 1..testCount) {
        val n = readInt()
        var answerFound = false
        for (x in 2..Math.sqrt(n.toDouble()).toInt()) {
            if (n % x == 0) {
                answerFound = true
                println((n / x).toString() + " " + (n / x) * (x - 1))
                break
            }
        }
        if (!answerFound) {
            println(1.toString() + " " + (n - 1))
        }
    }
}

fun readInt() = readLine()!!.toInt()

fun main() {
    repeat(readInt()) {
        val n = readInt()
        println(solve(n))
    }
}

fun solve(n: Int): String {
    var i = 2
    while (i*i <= n) {
        if (n % i == 0) {
            val d = n / i
            return "$d ${n-d}"
        }
        i++
    }
    return "1 ${n-1}"
}

import java.util.*
import kotlin.math.sqrt

private inline fun debug(str: () -> Any?) = println(str().toString()) //{}
private inline fun readInt() = reader.nextInt()
private inline fun readLong() = reader.nextLong()
private inline fun readDouble() = reader.nextDouble()
private inline fun readArr() = readLine()!!.split(" ").map { it.toInt() }
private inline fun readArr(n: Int) = List<Int>(n) { reader.nextInt() }
private inline fun readArrLong() = readLine()!!.split(" ").map { it.toLong() }
private inline fun readArrLong(n: Int) = List<Long>(n) { reader.nextLong() }
private inline fun readArrDouble() = readLine()!!.split(" ").map { it.toDouble() }
private inline fun readArrDouble(n: Int) = List<Double>(n) { reader.nextDouble() }
private inline fun readLineAsCharList() = reader.nextLine().asSequence().toList()
private inline fun readAndSolve(f: () -> Unit): Unit {
    val n = readInt()
    // usually n is the only value in string
    reader.nextLine()
    repeat(n) { f() }
}

private fun Boolean.yn() = if (this) "YES" else "NO"
private fun <T> Iterable<T>.out() = this.joinToString(" ")
private val reader = Scanner(System.`in`.bufferedReader()).apply { useLocale(Locale.US) }

@ExperimentalStdlibApi
fun main() = solve1372B()

@ExperimentalStdlibApi
private fun solve1372B() {

    val n = readInt()
    val arr = readArr(n)
    val max = arr.max() ?: 5
    val sqrtMax = sqrt(max.toDouble()).toInt() + 1

    val primes = mutableListOf<Int>()
    val sieve = BitSet(sqrtMax) // false - простое, true - не простое
    fun fillSieve() {
        sieve[0] = true
        sieve[1] = true
        var i = 2
        while (i * i < sqrtMax) {
            if (!sieve[i]) {
                primes.add(i)
                var j = i * i
                while (j < sqrtMax) {
                    sieve[j] = true
                    j += i
                }
            }
            i++
        }
        while (i < sqrtMax) {
            val nextPrime = sieve.nextClearBit(i)
            primes.add(nextPrime)
            i = nextPrime + 1
        }
    }
    fillSieve()
    //println(primes)

    for (a in arr) {
        var ans1 = 0
        var ans2 = 0
        var found = false
        for (p in primes) {
            if (a % p == 0) {
                found = true
                ans1 = a / p
                break
            }
        }
        if (!found) {
            ans1 = 1
        }
        ans2 = a - ans1
        println("$ans1 $ans2")
    }

}

import kotlin.math.sqrt

/**
 * Euler's totient function  */

fun main() {

    repeat(readLine()!!.toInt()) {
        val num = readLine()!!.toInt()
        val leastPrime = leastPrime(num)
        println("${num / leastPrime} ${num / leastPrime * (leastPrime - 1)}")
    }

}

fun leastPrime(n: Int): Int {
    var num = 2
    if (n % 2 == 0)
        return 2
    num += 1
    while (n % num != 0 && num < sqrt(n.toDouble())) {
        num += 2
    }
    return num
}

import java.util.*
import kotlin.collections.*
import kotlin.math.*

fun readInts() = readLine()!!.split(" ").map{i -> i.toInt()}.toMutableList()
fun readInt() = readLine()!!.toInt()
fun readLongs() = readLine()!!.split(" ").map{i -> i.toLong()}.toMutableList()

fun main() {
    val t = readInt()
    repeat(t) {
        val n = readInt()
        if (n % 2 == 0) {
            println("${n / 2} ${n / 2}")
        } else {
            var a = sqrt(n.toDouble()).toInt()
            var b = n - a
            while(b % a != 0) {
                a--
                b++
            }
            println("$a $b")
        }
    }
}

import java.lang.Math.*

private fun readLn() = readLine()!! // string line
private fun readStrings() = readLn().split(" ") // list of strings
private fun readLong() = readLn().toLong()
private fun readLongs() = readStrings().map { it.toLong() } // list of ints
private fun readInt() = readLn().toInt() // single int
private fun readInts() = readStrings().map { it.toInt() } // list of ints

//var n = 0
//var ar = listOf<Int>()
val visited = mutableSetOf<Char>()
val graph = mutableMapOf<Char, MutableList<Char>>()

fun main() {
    val t = readInt()
    for (cases in 0 until t) {
        solve()
    }

//    solve()
}

fun solve() {
    val n = readInt()

    var ans1 = 1
    var ans2 = n - 1
    for (i in 2 until sqrt(n.toDouble()).toInt() + 1) {
        if (n % i == 0) {
            val d = n / i
            ans1 = d
            ans2 = (i - 1) * d
        }
    }

    println("$ans1 $ans2")
}

fun main() {
    val t = readInt()
    fun findOther(x: Int, n: Int): Int {
        val a = n/x - 1
        return a * x
    }

    repeat(t) {
        val n = readInt()
        if (n % 2 == 0) println("${n/2} ${n/2}")
        else {
            var divisor = 1
            val candidates = mutableListOf<Int>()
            while (divisor * divisor <= n) {
                if (n % divisor == 0) candidates.add(divisor)

                divisor += 2
            }

            val ans = candidates.map { Pair(it, findOther(it, n)) }.minBy { it.second }!!
            println("${ans.first} ${ans.second}")
        }
    }
}

// Input Reader
private fun readLn() = readLine()!!

private fun readStrings() = readLn().trim().split(" ")
private fun readInt() = readLn().toInt()
private fun readInts() = readStrings().map { it.toInt() }

import java.io.BufferedReader
import java.io.IOException
import java.io.InputStreamReader
import java.util.*

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong() // single int
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map { it.toInt() } // list of ints
private fun readLongs() = readStrings().map { it.toLong() } // list of longs

fun main(args: Array<String>) {
    b()
}

fun divisor(n: Int): Int {
    var i = 2
    while (i * i <= n) {
        if (n % i == 0) return i
        i++
    }
    return n
}

fun a() {
    repeat(readInt()) {
        val n = readInt()
        val a = List<Int>(n) { 1 }
        println(a.joinToString(separator = " "))
    }
}

fun pow(a: Int, b: Int): Long {
    var res = 1L
    repeat(b) { res *= a }
    return res
}

fun adj(i: Int, j: Int, n: Int, m: Int): Int {
    var adj = 4
    if (i == 0) adj--
    if (j == 0) adj--
    if (i == n - 1) adj--
    if (j == m - 1) adj--
    return adj
}

fun activeAdj(i: Int, j: Int, n: Int, m: Int, a: Array<IntArray>): Int {
    var activeAdj = 0
    if (i - 1 >= 0 && a[i - 1][j] > 0) activeAdj++
    if (j - 1 >= 0 && a[i][j - 1] > 0) activeAdj++
    if (i + 1 < n && a[i + 1][j] > 0) activeAdj++
    if (j + 1 < m && a[i][j + 1] > 0) activeAdj++
    return activeAdj
}

fun b() {
    repeat(readInt()) {
        val n = readInt()
        val divisor = leastDivisor(n)

        println("${n / divisor} ${n - n / divisor}")
    }
}

fun c() {
    repeat(readInt()) {
        val n = readInt()
        val a = readInts()

        val mins = mutableListOf(a[0])
        val maxs = mutableListOf(a[n - 1])

        for (i in 1 until n) {
//            println(a[i])
            while (mins.size > 1 && mins[mins.lastIndex] < a[i]) {
                mins.removeAt(mins.lastIndex)
            }
            if (mins.last() > a[i]) {
                mins.add(a[i])
            }

//            println(mins)
        }

        if (mins.size == 1) {
            println("YES")
            return@repeat
        }

        for (i in n - 2 downTo 0) {
//            println(a[i])
            while (maxs.size > 1 && maxs[maxs.lastIndex] > a[i]) {
                maxs.removeAt(maxs.lastIndex)
            }
            if (maxs.last() < a[i]) {
                maxs.add(a[i])
            }
//            println(maxs)
        }

        if (maxs.size == 1) {
            println("YES")
            return@repeat
        }

        println("NO")

//        println(if (a.indexOf(mins[1]) > a.indexOf(maxs[1])) "YES" else "NO")
    }
}

fun df(a: IntArray): Pair<Triple<Long, Int, Int>, Triple<Long, Int, Int>> {

    var dif = 0L
    var lastIndex = 0
    var maxDif = 0L
    var maxIndex = 0
    var maxLength = 0
    for (i in 0 until a.size - 1 step 2) {
        dif += a[i + 1] - a[i]
        if (dif <= 0) {
            dif = 0
            lastIndex = i + 2
            continue
        }
        if (dif > maxDif) {
            maxDif = dif
            maxIndex = lastIndex
            maxLength = i + 2 - lastIndex
        }
    }

    var dif1 = 0L
    var lastIndex1 = 1
    var maxDif1 = 0L
    var maxIndex1 = 0
    var maxLength1 = 0
    for (i in 1 until a.size - 1 step 2) {
        dif1 += a[i + 1] - a[i]
        if (dif1 >= 0) {
            dif1 = 0
            lastIndex1 = i + 2
            continue
        }
        if (dif1 < maxDif1) {
            maxDif1 = dif1
            maxIndex1 = lastIndex1
            maxLength1 = i + 2 - lastIndex1
        }
    }

    return Pair(Triple(maxDif, maxIndex, maxLength), Triple(-maxDif1, maxIndex1, maxLength1))
}

data class MyPair(var first: Int, var second: Int) : Comparable<MyPair> {
    override fun compareTo(other: MyPair): Int {
        return this.first - other.first
    }

}

fun d() {
    repeat(readInt()) {
        val n = readInt()
        val a = readInts().toIntArray()

        val f = IntArray(n + 1)
        val id = List(n + 1) { mutableListOf<Int>() }
        val q = PriorityQueue<Int>()

        for (i in 0 until n) {
            id[ a[i] ].add(i)
            f[a[i]]++
        }

        for (i in 0 until n + 1) {
            if (f[i] == 0) {
                q.add(i)
            }
        }

        val ans = mutableListOf<Int>()

        var pref = 0

        repeat(n) {
            val element = q.poll()

            if (element == n) {
                ans.add(pref)
                q.poll()
                q.add(a[pref])
                a[pref] = n
            }

            ans.add(element)
            f[a[element]]--
            if (f[a[element]] == 0) {
                q.add(a[element])
            }
            a[element] = element
        }
/*
        for (i in 0 until n) {
//            println(i)
//            println(q.peek())
//            println(a.contentToString())
            if (a[i] == i) continue
            if (q.peek() == i) {
                ans.add(i)

                val element = a[i]
                a[i] = q.poll() // i
                f[a[i]]++
                f[element]--
                if (f[element] == 0) {
                    q.add(element)
                }
            } else {
                for (idx in id[i]) {
                    ans.add(idx)
                }
                val index = id[i]
                ans.add(index)
                ans.add(i)

                id[q.peek()] = index
                f[q.peek()]++
                a[index] = q.poll()

                val element = a[i]
                a[i] = i
                f[a[i]]++
                f[element]--
                if (f[element] == 0) {
                    q.add(element)
                }
            }
        }
        */

        println(ans.size)
        println(ans.joinToString(separator = " ", transform = { (it + 1).toString() }))
    }
}

fun f() {
    val (n, m, q) = readInts()
    val a = Array(n) { IntArray(m) }

    val rows = LongArray(n)
    val columns = LongArray(m)

    for (i in 0 until n) {
        a[i] = readInts().toIntArray()

        for (j in 0 until m) {
            rows[i] = rows[i] + a[i][j]
            columns[j] = columns[j] + a[i][j]
        }
    }

    val rowsP = LongArray(n)
    val rowsS = LongArray(n)

    val rowsPM = LongArray(n)
    val rowsSM = LongArray(n)

    val columnsP = LongArray(m)
    val columnsS = LongArray(m)

    val columnsPM = LongArray(m)
    val columnsSM = LongArray(m)

    for (i in 0 until q + 1) {
        if (i != 0) {
            val (x, y, z) = readInts()
            val diff = z - a[x - 1][y - 1]
            rows[x - 1] = rows[x - 1] + diff
            columns[y - 1] = columns[y - 1] + diff
            a[x - 1][y - 1] = z
        }

        rowsP[0] = rows[0]
        for (j in 1 until n) {
            rowsP[j] = rowsP[j - 1] + rows[j]
            rowsPM[j] = rowsP[j - 1] + rowsPM[j - 1]
        }

        rowsS[n - 1] = rows[n - 1]
        for (j in n - 2 downTo 0) {
            rowsS[j] = rowsS[j + 1] + rows[j]
            rowsSM[j] = rowsS[j + 1] + rowsSM[j + 1]
        }

        columnsP[0] = columns[0]
        for (j in 1 until m) {
            columnsP[j] = columnsP[j - 1] + columns[j]
            columnsPM[j] = columnsP[j - 1] + columnsPM[j - 1]
        }

        columnsS[m - 1] = columns[m - 1]
        for (j in m - 2 downTo 0) {
            columnsS[j] = columnsS[j + 1] + columns[j]
            columnsSM[j] = columnsS[j + 1] + columnsSM[j + 1]
        }

        var minRow = minOf(rowsSM[0], rowsPM[n - 1])
        for (j in 1 until n - 1) {
            minRow = minOf(minRow, rowsSM[j] + rowsPM[j])
        }

        var minColumn = minOf(columnsSM[0], columnsPM[m - 1])
        for (j in 1 until m - 1) {
            minColumn = minOf(minColumn, columnsSM[j] + columnsPM[j])
        }

        print("${minRow + minColumn}\n")
    }
}

private inline fun sqr(x: Int) = 1L * x * x

val t = IntArray(2_200_000)

fun build(a: IntArray, v: Int, tl: Int, tr: Int) {
    if (tl == tr) {
        t[v] = a[tl]
    } else {
        val tm = (tl + tr) / 2
        build(a, v * 2, tl, tm)
        build(a, v * 2 + 1, tm + 1, tr)
        t[v] = t[v * 2] + t[v * 2 + 1]
    }

//    println("$v [$tl, $tr] = ${t[v]}")
}

fun update(v: Int, tl: Int, tr: Int, pos: Int): Int {
    if (tl == tr) {
        t[v]++
        return t[v]
    } else {
        val tm = (tl + tr) / 2
        val res = if (pos <= tm) {
            update(v * 2, tl, tm, pos)
        } else {
            update(v * 2 + 1, tm + 1, tr, pos)
        }
        t[v] = t[v * 2] + t[v * 2 + 1]
        return res
    }
}

fun delete(v: Int, tl: Int, tr: Int, pos: Int): Int {
//    println("$v [$tl, $tr] = ${t[v]}, pos = $pos")
    if (tl == tr) {
        t[v]--
        return tl
    } else {
        val tm = (tl + tr) / 2
        val res = if (pos <= t[v * 2]) {
            delete(v * 2, tl, tm, pos)
        } else {
            delete(v * 2 + 1, tm + 1, tr, pos - t[v * 2])
        }
        t[v] = t[v * 2] + t[v * 2 + 1]
        return res
    }
}

fun e() {
    val N = 1_00_000
    val f = IntArray(N)
    for (i in 0 until N) {
        f[i] = f[i / 10] + i % 10
    }

    val max = f.max()!!

//    println(max)

    repeat(readInt()) {
        val (n, k) = readInts()

        if (max * (k + 1) >= n) {
            var sum = 0
            for (i in 0 until k + 1) {
                sum += f[i]
            }

            if (n == sum) {
                println(0)
                return@repeat
            }

            for (i in 1 until N - k) {
                sum -= f[i - 1]
                sum += f[i + k]

                if (n == sum) {
                    println(i)
                    return@repeat
                }
            }
        }

        val res = StringBuilder()
        res.append('9')
        var sum = (9 - k..9).sum()

        println("$res $sum")

        while (sum < n) {
            res.append('9')
            sum += 9 * (k + 1)

            println("$res $sum")

            if (sum == n) {
                res[res.length - 1] = '9' - k
                println(res)
                return@repeat
            }
            if (sum > n) {
                sum -= 9 * (k + 1)
                for (i in 1 until 9) {
                    if (sum + i * (k + 1) == n) {
                        res[0] = '0' + i
                        res[res.length - 1] = '9' - k
                        println(res)
                        return@repeat
                    }
                }
                break
            }
        }

        println(-1)
    }
}

internal class FastScanner {
    var br: BufferedReader = BufferedReader(InputStreamReader(System.`in`))
    var st: StringTokenizer? = null

    operator fun next(): String {
        while (st == null || !st!!.hasMoreElements()) {
            try {
                st = StringTokenizer(br.readLine())
            } catch (e: IOException) {
                e.printStackTrace()
            }
        }
        return st!!.nextToken()
    }

    fun nextInt(): Int {
        return next().toInt()
    }
}

fun Int.isEven(): Boolean = this % 2 == 0
fun Int.isOdd(): Boolean = this % 2 == 1

public operator fun <T> List<T>.component6(): T {
    return get(5)
}

fun allPrimesUpTo(n: Int): List<Int> {
    val isPrime = BooleanArray(n + 1) { true }
    val primes = mutableListOf<Int>()

    isPrime[0] = false
    isPrime[1] = false
    for (i in 2 until n + 1) {
        if (isPrime[i]) {
            primes.add(i)

            if (i.toLong() * i > n)
                continue

            for (j in i * i until n + 1 step i) {
                isPrime[j] = false
            }
        }
    }

    return primes
}

fun leastDivisor(n: Int): Int {
    if (n % 2 == 0) return 2
    if (n % 3 == 0) return 3
    if (n % 5 == 0) return 5

    for (i in 7 until n) {
        if (i * i > n) return 1

        if (n % i == 0) {
            return i
        }
    }

    return 1
}

import java.util.*
import kotlin.math.ceil
import kotlin.math.floor
import kotlin.math.max
import kotlin.math.round

fun main() {
    val scanner = Scanner(System.`in`)
    val n = scanner.nextInt()
    for (i in 0 until n) {
        val total = scanner.nextInt().toDouble()
        if (total.toInt() % 2 == 0) {
            println("${total.toInt() / 2} ${total.toInt() / 2}")
        } else {
            val x = ceil(total / 2).toInt()
            for (j in x downTo 1 step 2) {
                if(total.toInt() % j == 0){
                    println("$j ${total.toInt() - j}")
                    break;
                }
            }
        }
    }
}

import java.util.*
import kotlin.math.*

fun main() {
    val scanner = Scanner(System.`in`)
    val n = scanner.nextInt()
    for (i in 0 until n) {
        val total = scanner.nextInt().toDouble()
        if (total.toInt() % 2 == 0) {
            println("${total.toInt() / 2} ${total.toInt() / 2}")
        } else {
            val x = floor(sqrt(total)).toInt()
            var flag = false
            for (j in 3..x) {
                if (total.toInt() % j == 0) {
                    flag = true
                    println("${total.toInt() / j} ${total.toInt() - (total.toInt() / j)}")
                    break;
                }
            }
            if (flag) {
                println("1 ${total.toInt() - 1}")
            }
        }
    }
}

import java.io.BufferedReader

fun main() {
    val br = System.`in`.bufferedReader()
    val sb = StringBuilder()
    val t = br.readInt()
    repeat(t) {
        val n = br.readInt()
        var i = 2
        var found = false
        while (i * i <= n) {
            if (n % i == 0) {
                found = true
                sb.append(n / i).append(' ').append(n - (n / i)).append('\n')
            }
            i++
        }
        if (!found) {
            sb.append(1).append(' ').append(n - 1).append('\n')
        }
    }
    print(sb)
}

private const val SPACE_INT = ' '.toInt()
private const val ZERO_INT = '0'.toInt()
private const val NL_INT = '\n'.toInt()

private fun BufferedReader.readInt(): Int {
    var ret = read()
    while (ret <= SPACE_INT) {
        ret = read()
    }
    val neg = ret == '-'.toInt()
    if (neg) {
        ret = read()
    }
    ret -= ZERO_INT
    var read = read()
    while (read >= ZERO_INT) {
        ret *= 10
        ret += read - ZERO_INT
        read = read()
    }

    while (read <= SPACE_INT && read != -1 && read != NL_INT) {
        mark(1)
        read = read()
    }
    if (read > SPACE_INT) {
        reset()
    }
    return if (neg) -ret else ret
}

import java.io.BufferedReader

fun main() {
    val br = System.`in`.bufferedReader()
    val sb = StringBuilder()
    val t = br.readInt()
    repeat(t) {
        val n = br.readInt()
        var i = 2
        var found = false
        while (i * i <= n) {
            if (n % i == 0) {
                found = true
                sb.append(n / i).append(' ').append(n - (n / i)).append('\n')
            }
            i++
        }
        if (!found) {
            sb.append(1).append(' ').append(n - 1)
        }
    }
    print(sb)
}

private const val SPACE_INT = ' '.toInt()
private const val ZERO_INT = '0'.toInt()
private const val NL_INT = '\n'.toInt()

private fun BufferedReader.readInt(): Int {
    var ret = read()
    while (ret <= SPACE_INT) {
        ret = read()
    }
    val neg = ret == '-'.toInt()
    if (neg) {
        ret = read()
    }
    ret -= ZERO_INT
    var read = read()
    while (read >= ZERO_INT) {
        ret *= 10
        ret += read - ZERO_INT
        read = read()
    }

    while (read <= SPACE_INT && read != -1 && read != NL_INT) {
        mark(1)
        read = read()
    }
    if (read > SPACE_INT) {
        reset()
    }
    return if (neg) -ret else ret
}

import java.lang.Integer.max

fun main() {
    val t= readInt()
    repeat(t){
        val n = readInt()
        if(n%2==0){
            println("${n/2} ${n/2}")
        }
        else{
            val lower = if(n/2-1 != 0) n/2-1 else n/2
            val higher = n-lower
            println("$lower $higher")
        }
    }
}

fun getNumber(row: Int, col: Int, n: Int, m: Int, cell: Int): Int {
    var number = 0
    if(row+1<n) number = number +1
    if (col+1<m) number = number +1
    if (row-1>=0) number = number +1
    if (col-1>=0) number = number +1
    return number
}

private fun isValid(row: Int, col: Int, n: Int, m: Int, cell: Int): Boolean {
    var number = 0
    if(row+1<n) number = number +1
    if (col+1<m) number = number +1
    if (row-1>=0) number = number +1
    if (col-1>=0) number = number +1
    return cell <=number
}

private fun readLn() = readLine()!!
private fun readInt() = readLn().toInt()
private fun readStrings() = readLn().split(" ")
private fun readInts() = readStrings().map { it.toInt() }
private fun readLongs() = readStrings().map { it.toLong() }

//package cf1372

import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.StringTokenizer

class B {
    private val input: BufferedReader = BufferedReader(InputStreamReader(System.`in`))
    private val output: PrintWriter = PrintWriter(System.out)

    var st: StringTokenizer? = null

    private fun closeAfter() {
        input.close()
        output.close()
    }

    private fun next(): String {
        if (st == null || !st!!.hasMoreElements()) {
            st = StringTokenizer(input.readLine())
        }

        return st!!.nextToken()
    }

    private fun nextInt(): Int {
        return next().toInt()
    }

    private fun nextDouble(): Double {
        return next().toDouble()
    }

    fun solve() {
        innerSolve()
        closeAfter()
    }

    private fun innerSolve() {
        val tt = nextInt()
        for (t in 0 until tt) {
            val n = nextInt()
            if (n % 2 == 0) {
                output.println("${n / 2} ${n / 2}")
            } else {
                var a = 1
                var b = 1
                var cur = n

                for (i in 3..(Math.sqrt(1.0 * n).toInt())) {
                    if (cur % i == 0) {

                        if (cur == n) {
                            a = i / 2
                            b = i - a
                            cur /= i
                        }

                        while (cur % i == 0) {
                            cur /= i
                            a *= i
                            b *= i
                        }

                        if (cur == 1) {
                            break;
                        }
                    }
                }
                output.println("$a $b")
            }
        }
    }
}

fun main(args: Array<String>) {
    B().solve()
}

//package cf1372

import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.StringTokenizer

class B {
    private val input: BufferedReader = BufferedReader(InputStreamReader(System.`in`))
    private val output: PrintWriter = PrintWriter(System.out)

    var st: StringTokenizer? = null

    private fun closeAfter() {
        input.close()
        output.close()
    }

    private fun next(): String {
        if (st == null || !st!!.hasMoreElements()) {
            st = StringTokenizer(input.readLine())
        }

        return st!!.nextToken()
    }

    private fun nextInt(): Int {
        return next().toInt()
    }

    private fun nextDouble(): Double {
        return next().toDouble()
    }

    fun solve() {
        innerSolve()
        closeAfter()
    }

    private fun innerSolve() {
        val tt = nextInt()
        for (t in 0 until tt) {
            val n = nextInt()
            if (n % 2 == 0) {
                output.println("${n / 2} ${n / 2}")
            } else {
                var a = 1
                var b = n - 1
                var cur = n

                for (i in 3..(Math.sqrt(1.0 * n).toInt())) {
                    if (cur % i == 0) {

                        if (cur == n) {
                            a = i / 2
                            b = i - a
                            cur /= i
                        }

                        while (cur % i == 0) {
                            cur /= i
                            a *= i
                            b *= i
                        }

                        if (cur == 1) {
                            break;
                        }
                    }
                }
                output.println("$a $b")
            }
        }
    }
}

fun main(args: Array<String>) {
    B().solve()
}

//package cf1372

import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.StringTokenizer

class B {
    private val input: BufferedReader = BufferedReader(InputStreamReader(System.`in`))
    private val output: PrintWriter = PrintWriter(System.out)

    var st: StringTokenizer? = null

    private fun closeAfter() {
        input.close()
        output.close()
    }

    private fun next(): String {
        if (st == null || !st!!.hasMoreElements()) {
            st = StringTokenizer(input.readLine())
        }

        return st!!.nextToken()
    }

    private fun nextInt(): Int {
        return next().toInt()
    }

    private fun nextDouble(): Double {
        return next().toDouble()
    }

    fun solve() {
        innerSolve()
        closeAfter()
    }

    private fun innerSolve() {
        val tt = nextInt()
        for (t in 0 until tt) {
            val n = nextInt()
            if (n % 2 == 0) {
                output.println("${n / 2} ${n / 2}")
            } else {
                var a = 1
                var b = n - 1

                var i = 3

                while (i < Math.sqrt(1.0 * n).toInt()) {

                    if (n % i == 0) {
                        a = n / i
                        b = n - a
                    }
                    i += 2
                }

                output.println("$a $b")
            }
        }
    }
}

fun main(args: Array<String>) {
    B().solve()
}

//package cf1372

import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.StringTokenizer

class B {
    private val input: BufferedReader = BufferedReader(InputStreamReader(System.`in`))
    private val output: PrintWriter = PrintWriter(System.out)

    var st: StringTokenizer? = null

    private fun closeAfter() {
        input.close()
        output.close()
    }

    private fun next(): String {
        if (st == null || !st!!.hasMoreElements()) {
            st = StringTokenizer(input.readLine())
        }

        return st!!.nextToken()
    }

    private fun nextInt(): Int {
        return next().toInt()
    }

    private fun nextDouble(): Double {
        return next().toDouble()
    }

    fun solve() {
        innerSolve()
        closeAfter()
    }

    private fun innerSolve() {
        val tt = nextInt()
        for (t in 0 until tt) {
            val n = nextInt()
            if (n % 2 == 0) {
                output.println("${n / 2} ${n / 2}")
            } else {
                var a = 1
                var b = n - 1
                var cur = n

                for (i in 3..(Math.sqrt(1.0 * n).toInt())) {
                    if (cur % i == 0) {

                        if (cur == n) {
                            a = i / 2
                            b = i - a
                            cur /= i
                        }

                        while (cur % i == 0) {
                            cur /= i
                            a *= i
                            b *= i
                        }

                        if (cur == 1) {
                            break;
                        }
                    }
                }

                if (cur != n && cur != 1) {
                    a *= cur
                    b *= cur
                }
                output.println("$a $b")
            }
        }
    }
}

fun main(args: Array<String>) {
    B().solve()
}

fun main() {
    repeat(readInt()) {
        val n = readInt()
        var ans = 1
        var i = 2
        while (i * i <= n) {
            if (n % i == 0) {
                ans = i
            }
            i++
        }

        val second = n - ans
        print("$ans $second\n")
    }
}

fun readInt(): Int = readLine()!!.toInt()

import kotlin.math.roundToInt
import kotlin.math.sqrt

fun readInt() = readLine()!!.toInt()

fun main() {
    repeat(readInt()) {
        val n = readInt()
        println(solve(n))
    }
}

fun solve(n: Int): String {
    for (i in sqrt(n.toDouble()).roundToInt() + 1 downTo 1) {
        if (n % i == 0) {
            return "$i ${n-i}"
        }
    }
    return "$1 ${n-1}"
}

import kotlin.math.roundToInt
import kotlin.math.sqrt

fun readInt() = readLine()!!.toInt()

fun main() {
    repeat(readInt()) {
        val n = readInt()
        println(solve(n))
    }
}

fun solve(n: Int): String {
    var i = 2
    while (i*i <= n) {
        if (n % i == 0) {
            val d = n / i
            return "$d ${n-d}"
        }
        i++
    }
    return "$1 ${n-1}"
}


So nearly half of the winter is over and Maria is dreaming about summer. She's fed up with skates and sleds, she was dreaming about Hopscotch all night long. It's a very popular children's game. The game field, the court, looks as is shown in the figure (all blocks are square and are numbered from bottom to top, blocks in the same row are numbered from left to right). Let us describe the hopscotch with numbers that denote the number of squares in the row, staring from the lowest one: 1-1-2-1-2-1-2-(1-2)..., where then the period is repeated (1-2).  The coordinate system is defined as shown in the figure. Side of all the squares are equal and have length a.Maria is a very smart and clever girl, and she is concerned with quite serious issues: if she throws a stone into a point with coordinates (x, y), then will she hit some square? If the answer is positive, you are also required to determine the number of the square.It is believed that the stone has fallen into the square if it is located strictly inside it. In other words a stone that has fallen on the square border is not considered a to hit a square.

The only input line contains three integers: a, x, y, where a (1 ≤ a ≤ 100) is the side of the square, x and y ( - 106 ≤ x ≤ 106, 0 ≤ y ≤ 106) are coordinates of the stone.

Print the number of the square, inside which the stone fell. If the stone is on a border of some stone or outside the court, print "-1" without the quotes.

import java.util.*
import kotlin.system.exitProcess
import kotlin.math.*

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map { it.toInt() } // list of ints
private fun readLongs() = readStrings().map { it.toLong() } // list of longs
private fun exit() : Nothing = exitProcess(0)

inline fun <T : Comparable<T> > min(x : T, y : T): T{
    if(x < y){return x;}
    else{return y;}
}

inline fun <T : Comparable<T> > max(x : T, y : T): T{
    if(x > y){return x;}
    else{return y;}
}

fun getid(row : Int): Int{
    val kek = (row - 1)/2;
    return 2 + 3 * kek;
}

fun main(){
    var (a, x, y) = readInts();
    a = a * 2;
    x = x * 2;
    y = y * 2;
    if(y%a == 0){
        println(-1);
        return;
    }
    val row = y/a;
    if(row <= 1){
        if(abs(x) >= a/2){println(-1);}
        else{println(row + 1);}
        return;
    }
    if(row%2 == 0){
        if(x != 0 && abs(x) < a){
            if(x < 0)println(getid(row - 1) + 1);
            else println(getid(row - 1) + 2);
        }
        else{println(-1);}
    }
    else{
        if(abs(x) < a/2){println(getid(row));}
        else{println(-1);}
    }
}


You are given two squares, one with sides parallel to the coordinate axes, and another one with sides at 45 degrees to the coordinate axes. Find whether the two squares intersect.The interior of the square is considered to be part of the square, i.e. if one square is completely inside another, they intersect. If the two squares only share one common point, they are also considered to intersect.

The input data consists of two lines, one for each square, both containing 4 pairs of integers. Each pair represents coordinates of one vertex of the square. Coordinates within each line are either in clockwise or counterclockwise order. The first line contains the coordinates of the square with sides parallel to the coordinate axes, the second line contains the coordinates of the square at 45 degrees. All the values are integer and between $$$-100$$$ and $$$100$$$.

Print "Yes" if squares intersect, otherwise print "No". You can print each letter in any case (upper or lower).

NoteIn the first example the second square lies entirely within the first square, so they do intersect.In the second sample squares do not have any points in common.Here are images corresponding to the samples:

import org.w3c.dom.css.Rect
import java.awt.Rectangle
import java.awt.geom.Rectangle2D
import java.io.BufferedReader
import java.io.IOException
import java.io.InputStream
import java.io.InputStreamReader
import java.util.*
import kotlin.math.max
import kotlin.math.min

fun pos(x1: Int, y1: Int, x2: Int, y2: Int, x3: Int, y3: Int): Boolean {
    return (x2 - x1) * (y3 - y1) - (y2 - y1) * (x3 - x1) > 0
}

fun main(args: Array<String>) {

    val scanner = Scanner(System.`in`)
    val rect1 = Array(4) { Pair(scanner.nextInt(), scanner.nextInt()) }
    val rect2 = Array(4) { Pair(scanner.nextInt(), scanner.nextInt()) }
    var flag = false
    val positive = pos(rect1[0].first, rect1[0].second, rect1[1].first,
            rect1[1].second, rect2[0].first, rect2[0].second)
    for (i in 0..3) {
        for (j in 0..3) {
            if (pos(rect1[i].first, rect1[i].second, rect1[(i + 1) % 4].first, rect1[(i + 1) % 4].second,
                            rect2[j].first, rect2[j].second) != positive) {
                flag = true
                break
            }
        }
    }
    if (!flag) {
        println("YES")
        return
    }
    flag = false
    val positive1 = pos(rect2[0].first, rect2[0].second, rect2[1].first,
            rect2[1].second, rect1[0].first, rect1[0].second)
    for (i in 0..3) {
        for (j in 0..3) {
            if (pos(rect2[i].first, rect2[i].second, rect2[(i + 1) % 4].first, rect2[(i + 1) % 4].second,
                            rect1[j].first, rect1[j].second) != positive1) {
                flag = true
                break
            }
        }
    }
    if (!flag) {
        println("YES")
        return
    }
    for (i in 0..3) {
        if (rect1[i].second == rect1[(i + 1) % 4].second) {
            for (j in 0..3) {
                if (cross1(rect1[i].first, rect1[(i + 1) % 4].first, rect1[i].second,
                                rect2[j].first, rect2[j].second, rect2[(j + 1) % 4].first, rect2[(j + 1) % 4].second)) {
                    println("YES")
                    return
                }
            }
        }
        else {
            for (j in 0..3) {
                if (cross2(rect1[i].second, rect1[(i + 1) % 4].second, rect1[i].first,
                                rect2[j].first, rect2[j].second, rect2[(j + 1) % 4].first, rect2[(j + 1) % 4].second)) {
                    println("YES")
                    return
                }
            }
        }
    }
    println("NO")
}

fun cross1(x1: Int, x2: Int, y: Int, x3: Int, y3: Int, x4: Int, y4: Int): Boolean {
    val a = (y4 - y3) / (x4 - x3)
    val b = y3 - a * x3
    return (((y - b) / a) in min(x1, x2)..max(x1, x2)) && (((y - b) / a) in min(x3, x4)..max(x3, x4))
}

fun cross2(y1: Int, y2: Int, x: Int, x3: Int, y3: Int, x4: Int, y4: Int): Boolean {
    val a = (y4 - y3).toDouble() / (x4 - x3)
    val b = y3 - a * x3
    return (a * x + b) in min(y1, y2)..max(y1, y2) && (a * x + b) in min(y3, y4)..max(y3, y4)
}

class Scanner(s: InputStream) {
    var st: StringTokenizer? = null
    var br: BufferedReader = BufferedReader(InputStreamReader(s))
    @Throws(IOException::class)
    operator fun next(): String {
        while (st == null || !st!!.hasMoreTokens())
            st = StringTokenizer(br.readLine())
        return st!!.nextToken()
    }
    @Throws(IOException::class)
    fun nextInt(): Int {
        return Integer.parseInt(next())
    }
    @Throws(IOException::class)
    fun nextLong(): Long {
        return java.lang.Long.parseLong(next())
    }
    @Throws(IOException::class)
    fun nextLine(): String {
        return br.readLine()
    }
    @Throws(IOException::class)
    fun nextDouble(): Double {
        return java.lang.Double.parseDouble(next())
    }
    @Throws(IOException::class)
    fun ready(): Boolean {
        return br.ready()
    }
}
//class Pair(var a: Int, var b: Int): Comparable<Pair> {
//    override fun compareTo(other: Pair): Int {
//        return b - a - other.b + other.a
//    }
//}

import kotlin.math.*

fun main(args: Array<String>) {
    val a = readLine()!!.splitToIntArray().toRect()
    val b = readLine()!!.splitToIntArray().toRect()
    val h = (b.x1 - b.x0) / 2
    val s0 = b.x1 + b.y0 - h
    val s1 = b.x1 + b.y0 + h
    val d0 = b.x0 - b.y0 - h
    val d1 = b.x0 - b.y0 + h
    for (x in a.x0..a.x1) {
        for (y in a.y0..a.y1) {
            if ((x + y) in s0..s1 && (x - y) in d0..d1) {
                println("YES")
                return
            }
        }
    }
    println("NO")
}

fun IntArray.toRect(): Rect {
    var x0 = Int.MAX_VALUE
    var x1 = Int.MIN_VALUE
    var y0 = Int.MAX_VALUE
    var y1 = Int.MIN_VALUE
    for (i in 0..3) {
        x0 = min(get(2 * i), x0)
        x1 = max(get(2 * i), x1)
        y0 = min(get(2 * i + 1), y0)
        y1 = max(get(2 * i + 1), y1)
    }
    return Rect(x0, x1, y0, y1)
}

class Rect(val x0: Int, val x1: Int, val y0: Int, val y1: Int)

private fun String.splitToIntArray(): IntArray {
    val n = length
    if (n == 0) return IntArray(0) // EMPTY
    var res = IntArray(4)
    var m = 0
    var i = 0
    while (true) {
        var cur = 0
        var neg = false
        var c = get(i) // expecting number, IOOB if there is no number
        if (c == '-') {
            neg = true
            i++
            c = get(i) // expecting number, IOOB if there is no number
        }
        while (true) {
            val d = c.toInt() - '0'.toInt()
            require(d >= 0 && d <= 9) { "Unexpected character '$c' at $i" }
            require(cur >= Integer.MIN_VALUE / 10) { "Overflow at $i" }
            cur = cur * 10 - d
            require(cur <= 0) { "Overflow at $i" }
            i++
            if (i >= n) break
            c = get(i)
            if (c == ' ') break
        }
        if (m >= res.size) res = res.copyOf(res.size * 2)
        res[m++] = if (neg) cur else (-cur).also { require(it >= 0) { "Overflow at $i" } }
        if (i >= n) break
        i++
    }
    if (m < res.size) res = res.copyOf(m)
    return res
}


Manao is trying to open a rather challenging lock. The lock has n buttons on it and to open it, you should press the buttons in a certain order to open the lock. When you push some button, it either stays pressed into the lock (that means that you've guessed correctly and pushed the button that goes next in the sequence), or all pressed buttons return to the initial position. When all buttons are pressed into the lock at once, the lock opens.Consider an example with three buttons. Let's say that the opening sequence is: {2, 3, 1}. If you first press buttons 1 or 3, the buttons unpress immediately. If you first press button 2, it stays pressed. If you press 1 after 2, all buttons unpress. If you press 3 after 2, buttons 3 and 2 stay pressed. As soon as you've got two pressed buttons, you only need to press button 1 to open the lock.Manao doesn't know the opening sequence. But he is really smart and he is going to act in the optimal way. Calculate the number of times he's got to push a button in order to open the lock in the worst-case scenario.

A single line contains integer n (1 ≤ n ≤ 2000) — the number of buttons the lock has.

In a single line print the number of times Manao has to push a button in the worst-case scenario.

NoteConsider the first test sample. Manao can fail his first push and push the wrong button. In this case he will already be able to guess the right one with his second push. And his third push will push the second right button. Thus, in the worst-case scenario he will only need 3 pushes.

import java.io.*
import java.util.*

class ProblemIO(val rd: BufferedReader, val wr: PrintWriter) {
    companion object {
        fun console() = ProblemIO(BufferedReader(InputStreamReader(System.`in`)), PrintWriter(System.out))
    }

    var tok = StringTokenizer("")

    fun close() { rd.close(); wr.close() }
    fun <T> print(v: T) = wr.print(v)
    fun <T> println(v: T) = wr.println(v)
    fun readToken(): String {
        while (!tok.hasMoreTokens()) tok = StringTokenizer(rd.readLine())
        return tok.nextToken()
    }
    fun readInt() = readToken().toInt()
    fun readLong() = readToken().toLong()
    fun readLine() : String {
        tok = StringTokenizer("")
        return rd.readLine()
    }
}

fun main(args: Array<String>) {
    Thread({ val io = ProblemIO.console(); solve(io) ; io.close() }).start()
}

fun solve(io: ProblemIO) {
    val n = io.readInt()
    val bad = IntArray(n + 1)
    val good = IntArray(n + 1)
    bad[1] = 0
    good[1] = 1
    for (i in 2 .. n) {
        bad[i] = i - 1 + bad[i - 1]
        good[i] = 1 + bad[i - 1] + good[i - 1]
    }
    io.println(bad[n] + good[n])
}

fun main() {
    val r = System.`in`.bufferedReader()
    val s = StringBuilder()
    val k = r.readLine()!!.toInt()
    //val v = r.readLine()!!.split(" ").map { it.toInt() }.sortedDescending()
    val ans = k+(1..k-1).fold(0L){acc, i -> acc + i*(k-i)}
    println(ans)
}

fun main(){
    var n = readLine()!!.toInt()
    var i=2
    var ans=n
    while (n-- > 1){
        ans+= (n-1)*i +1
        i++
    }
    println(ans)
}

fun main() {
    val input = readLine()!!.toInt()
    var level = 1
    var presses = input
    for (i in input downTo 1) {
        val mistakes = i - 1
        presses += level++ * mistakes
    }
    println(presses)
}

import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextLong()
    print((n * n * (n - 1)) / 2 - (n * (n - 1) * (2 * n - 1)) / 6 + n)
}

fun main(args: Array<String>) {
    val n= readLine()!!.toLong()
    val result=(n-1)*n*(n+1)/6+n
    println(result)
}

fun main() {
    var n = readLine()!!.toInt()
    var ans: Int = 0
    var i: Int = 1
    while (n >= 1) {
        ans += (n * i) - (i - 1)
        n--
        i++
    }
    print(ans)
}

fun main() {
    fun readInt() = readLine()!!.toInt()

    var n = readInt() + 1
    var selecting = 1
    var result = 0
    while (--n > 0) {
        result += 1 + selecting * n - selecting
        selecting++
    }
    print(result)
}

fun main(args : Array<String>) {
    val n_nullable_str = readLine()
    if (n_nullable_str == null) {
        // Do nothing ...
    } else {
        val n_str = n_nullable_str
        val n = n_str.toLong()
        val t_1 = (n * n * (n + 1)) / 2
        val t_2 = (n * (n + 1) * ((2 * n) + 1)) / 6
        val t_3 = n
        val result = t_1 - t_2 + t_3
        println("${result}")
    }
}

fun main(args: Array<String>) {
    readLine()!!.toInt().let {  println((1..it).sumBy { it + (1..it-2).sumBy { it }}) }
}

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    var answer = 0
    var buttons = n
    for (i in 1..n) {
        val errors = buttons - 1
        val correct = 1
        val totalPresses = errors * i + correct
        answer += totalPresses
        buttons--
    }

    println(answer)
}

import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    print((n * n * (n - 1)) / 2 - (n * (n - 1) * (2 * n - 1)) / 6 + n)
}

fun main(args: Array<String>) {
    val n= readLine()!!.toInt()
    val result=(n-1)*(n*(n+1)/6)+n
    println(result)
}

fun main(args: Array<String>) {
    val n= readLine()!!.toInt()
    val result=(n*n-1*n)*(n+1)/6+n
    println(result)
}

fun main() {
    val n = readLine()!!.toInt()
    var ans = 1
    for (i in 2..n){
        ans*=i
    }
    print(ans+1)
}

fun main() {
    val n = readLine()!!.toInt()
    print((n*(n-1))+1)
}

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    println(n * (n + 1) / 2)
}

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    println(n * (n + 1) / 2 + n -2)
}


You have n problems. You have estimated the difficulty of the i-th one as integer ci. Now you want to prepare a problemset for a contest, using some of the problems you've made.A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest must be at least l and at most r. Also, you think that the difference between difficulties of the easiest and the hardest of the chosen problems must be at least x.Find the number of ways to choose a problemset for the contest.

The first line contains four integers n, l, r, x (1 ≤ n ≤ 15, 1 ≤ l ≤ r ≤ 109, 1 ≤ x ≤ 106) — the number of problems you have, the minimum and maximum value of total difficulty of the problemset and the minimum difference in difficulty between the hardest problem in the pack and the easiest one, respectively. The second line contains n integers c1, c2, ..., cn (1 ≤ ci ≤ 106) — the difficulty of each problem.

Print the number of ways to choose a suitable problemset for the contest.

NoteIn the first example two sets are suitable, one consisting of the second and third problem, another one consisting of all three problems.In the second example, two sets of problems are suitable — the set of problems with difficulties 10 and 30 as well as the set of problems with difficulties 20 and 30.In the third example any set consisting of one problem of difficulty 10 and one problem of difficulty 20 is suitable.

import java.io.*
import java.util.*

fun main() {
    val solver = Solver(System.`in`, System.out)
    solver.solve()
    solver.clear()
}

class Solver(input: InputStream, output: OutputStream) {

    companion object {
        private const val MAX_N = (1e6 + 10).toInt()
        private const val INF = (1e9 + 7).toInt()
        private const val MOD = (1e9 + 7).toInt()
        private const val INF_F = 1e-6
    }

    private val reader = Reader(input)
    private val writer = Writer(output)

    fun solve() {
        val n = reader.nextInt()
        val l = reader.nextInt()
        val r = reader.nextInt()
        val x = reader.nextInt()
        val c = reader.nextArrayInt(n).sorted()

        val bins = mutableListOf<String>()
        calcBin(bins, "", n)
        bins.sort()

        var ans = 0
        bins.forEach { bin ->
            if (bin.count { it == '1' } < 2) {
                return@forEach
            }
            val i = bin.indexOfFirst { it == '1' }
            val j = bin.indexOfLast { it == '1' }
            if (c[j] - c[i] < x) {
                return@forEach
            }
            val s = sum(c, i, j, bin)
            if (s in l..r) {
                ans++
            }
        }
        writer.println(ans)
    }

    private fun calcBin(bins: MutableList<String>, s: String, n: Int) {
        if (s.length == n) {
            bins.add(s)
            return
        }
        calcBin(bins, s + "1", n)
        calcBin(bins, s + "0", n)
    }

    private fun sum(c: List<Int>, i: Int, j: Int, bin: String): Int {
        var ans = 0
        for (x in i..j) {
            if (bin[x] == '1') {
                ans += c[x]
            }
        }
        return ans
    }

    fun clear() {
        writer.close()
    }
}

private fun IntArray.gcd(): Int {
    var g = first()
    forEach { g = gcd(g, it) }
    return g
}

private fun LongArray.gcd(): Long {
    var g = first()
    forEach { g = gcd(g, it) }
    return g
}

private fun gcd(a: Int, b: Int): Int {
    return if (b == 0) a else gcd(b, a % b)
}

private fun gcd(a: Long, b: Long): Long {
    return if (b == 0L) a else gcd(b, a % b)
}

class Reader(input: InputStream) {
    private val reader = BufferedReader(InputStreamReader(BufferedInputStream(input)), 32768)
    private var tokenizer: StringTokenizer? = null

    fun next(): String {
        while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {
            try {
                tokenizer = StringTokenizer(reader.readLine())
            } catch (e: IOException) {
                throw RuntimeException(e)
            }
        }
        return tokenizer!!.nextToken()
    }

    fun nextInt() = next().toInt()

    fun nextLong() = next().toLong()

    fun nextStringArray(count: Int): Array<String> {
        return Array<String>(count) { next() }
    }

    fun nextArrayInt(count: Int): IntArray {
        return nextArrayInt(0, count)
    }

    fun nextArrayInt(start: Int, count: Int): IntArray {
        val a = IntArray(start + count)
        for (i in start until start + count) {
            a[i] = nextInt()
        }
        return a
    }

    fun nextArrayLong(count: Int): LongArray {
        val a = LongArray(count)
        for (i in 0 until count) {
            a[i] = nextLong()
        }
        return a
    }

    fun nextIntPair(): Pair<Int, Int> {
        val x = nextInt()
        val y = nextInt()
        return x to y
    }
}

class Writer(output: OutputStream) {
    private val writer = PrintWriter(BufferedOutputStream(output))

    fun <T> print(t: T) = writer.print(t)
    fun println() = writer.println()
    fun <T> println(t: T) = writer.println(t)

    fun printBooleanArray(array: BooleanArray) = printIntArray(array.map { if (it) 1 else 0 }.toIntArray())
    fun printIntArray(array: IntArray) = array.joinToString(" ").let(writer::println)
    fun printLongArray(array: LongArray) = array.joinToString(" ").let(writer::println)
    fun printCharArray(array: CharArray) = array.joinToString("").let(writer::println)

    fun close() = writer.close()
    fun flush() = writer.flush()
}

import kotlin.math.pow

fun main() {
    fun readInts() = readLine()!!.split(" ").map(String::toInt)

    val (numProblems, minTotalDifficult, maxTotalDifficult, minbiggerDiff) = readInts()
    val difficulties = readInts().sorted()
    var sol = 0
    for (candidate in 1 until 2.0.pow(numProblems).toInt()) {
        val bitMask = candidate.toString(radix = 2)
        var min: Int? = null
        var max: Int? = null
        var sum = 0L
        for (pos in bitMask.indices) {
            val realPos = numProblems - bitMask.length + pos
            if (bitMask[pos] == '1') {
                if (min == null) min = difficulties[realPos]
                max = difficulties[realPos]
                sum += difficulties[realPos]
            }
        }
        if (sum in minTotalDifficult..maxTotalDifficult && max!! - min!! >= minbiggerDiff) sol++
    }
    print(sol)
}


Your friend has n cards.You know that each card has a lowercase English letter on one side and a digit on the other.Currently, your friend has laid out the cards on a table so only one side of each card is visible.You would like to know if the following statement is true for cards that your friend owns: "If a card has a vowel on one side, then it has an even digit on the other side." More specifically, a vowel is one of 'a', 'e', 'i', 'o' or 'u', and even digit is one of '0', '2', '4', '6' or '8'.For example, if a card has 'a' on one side, and '6' on the other side, then this statement is true for it. Also, the statement is true, for example, for a card with 'b' and '4', and for a card with 'b' and '3' (since the letter is not a vowel). The statement is false, for example, for card with 'e' and '5'. You are interested if the statement is true for all cards. In particular, if no card has a vowel, the statement is true.To determine this, you can flip over some cards to reveal the other side. You would like to know what is the minimum number of cards you need to flip in the worst case in order to verify that the statement is true.

The first and only line of input will contain a string s (1 ≤ |s| ≤ 50), denoting the sides of the cards that you can see on the table currently. Each character of s is either a lowercase English letter or a digit.

Print a single integer, the minimum number of cards you must turn over to verify your claim.

NoteIn the first sample, we must turn over both cards. Note that even though both cards have the same letter, they could possibly have different numbers on the other side.In the second sample, we don't need to turn over any cards. The statement is vacuously true, since you know your friend has no cards with a vowel on them.In the third sample, we need to flip the second and fourth cards.

fun main(args: Array<String>) {
    var a = readLine()!!
    var ans = 0
    for (c in a){
        if (c.isDigit()){
            var cur = ((c.toInt())%2 == 1)
            if(cur){
                ans+=1
            }
        }else {
            if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u'){
                ans += 1
            }
        }
    }
    println(ans)

}

fun main() {
    //println((4 or 6)xor(4 or 5))
    val r = System.`in`.bufferedReader()
    val s = StringBuilder()
    //val n = r.readLine()!!.toInt()
    val list = listOf("a", "e", "i", "o", "u", "1", "3", "5", "7", "9")
    val v = r.readLine()!!.split("").filter { it.isNotEmpty() }.count { it in list }
    println(v)
}

fun main(args: Array<String>) {
    val a = readLine()!!.trim()
    val voewels = arrayOf('a','e','i','o','u')
    val odds = arrayOf('1','3','5','7','9')
    val r = a.count { it in voewels || it in odds }
    println(r)
}

import java.util.*

fun main(args: Array<String>) {
    val vowels = listOf('a', 'e', 'i', 'o', 'u')
    val digits = "1234567890".toList()
    val s = Scanner(System.`in`)
    with(s) {
        var total = 0
        nextLine()
            .forEach {
                when (it) {
                    in vowels -> {
                        total++
                    }

                    in digits -> {
                        if (it.toInt() % 2 == 1) {
                            total++
                        }
                    }
                }
            }
        println(total)
    }
}

import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*

private val reader = BufferedReader(InputStreamReader(System.`in`))
private val out = PrintWriter(System.out)
private var st = StringTokenizer("")

fun next(): String {
    while (!st.hasMoreTokens())
        st = StringTokenizer(reader.readLine())
    return st.nextToken()
}

fun ni() = next().toInt()
fun nl() = next().toLong()
fun nd() = next().toDouble()
fun print(obj: Any) = out.print(obj)
fun close() = out.close()

fun main(args: Array<String>) {
    val text = next()
    val v = setOf('a', 'e', 'i', 'o', 'u')
    val range = 1..10 step 2
    val odd = range.flatMap { n -> listOf(text.filter { (it.toInt()-'0'.toInt()) == n }.count()) }.reduce({ x, y -> x + y });
    print(text.filter { it in v }.count()+odd)
    close()
}

fun main(args: Array<String>) = with(java.util.Scanner(System.`in`)) {
    var s = readLine()!!
    var (res, entahapa) = s.partition { (it.isDigit() && it.toInt()%2==1) || it == 'a' || it == 'u' || it == 'o' || it == 'i' || it == 'e' }
    println(res.count())
}

fun main() = println(readLine()!!.count { it in "aeiou13579" })

import java.util.*

fun main(args: Array<String>) = with(Scanner(System.`in`)) {
    val res = next().toCharArray()
            .filter { c -> arrayListOf('a', 'e', 'i', 'o', 'u', '1', '3', '5', '7', '9')
                    .filter { it == c }.any() }.size
    print(res)
}

import java.util.*

fun main(args: Array<String>) = with(Scanner(System.`in`)) {
    val arr = next().toCharArray().filter { it.vowel() }
    print("${arr.size}")
}

fun Char.vowel(): Boolean {
    val v = arrayListOf('a', 'e', 'i', 'o', 'u', '1', '3', '5', '7', '9')
    return v.filter { it == this }.any()
}

import kotlin.*

fun main(args: Array<String>) {
    var vowelsAndEvens = setOf(
            'a', 'o', 'e', 'u', 'i',
            '1', '3', '5', '7', '9'
    )

    var string = readLine() ?: ""
    println(string.count { it in vowelsAndEvens })

}

fun parse_int(): MutableList<Int> {
    return readLine()!!.split(' ').map {x: String -> x.toInt()}.toMutableList()
}

fun main(args: Array<String>) {
    val inp  = readLine()!!.trim()
    var odds = 0
    var vowels = 0

    for (c in inp) {
        if (c.isDigit()) {
            odds += c.toInt() % 2
        } else {
            if (c in "aeiou") vowels += 1
        }
    }

    println(odds + vowels)

}

fun main(args: Array<String>) {
    val a = readLine()!!.trim()
    val voewels = arrayOf('a','e','i','o','u')
    val evens = arrayOf('0','2','4','6','8')
    val r = a.count { it in voewels || it in evens }
    println(r)
}

import java.util.*

fun main(args: Array<String>) {
    val vowels = listOf('a', 'e', 'i', 'o', 'u')
    val digits = "1234567890".toList()
    val s = Scanner(System.`in`)
    with(s) {
        var total = 0
        nextLine()
            .forEach {
                when (it) {
                    in vowels -> {
                        total++
                    }

                    in digits -> {
                        if (it.toInt() % 2 == 0) {
                            total++
                        }
                    }
                }
            }
        println(total)
    }
}

import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*

private val reader = BufferedReader(InputStreamReader(System.`in`))
private val out = PrintWriter(System.out)
private var st = StringTokenizer("")

fun next(): String {
    while (!st.hasMoreTokens())
        st = StringTokenizer(reader.readLine())
    return st.nextToken()
}

fun ni() = next().toInt()
fun nl() = next().toLong()
fun nd() = next().toDouble()
fun print(obj: Any) = out.print(obj)
fun close() = out.close()

fun main(args: Array<String>) {
    val text = next()
    val v = setOf('a', 'e', 'i', 'o', 'u', '0', '2', '4', '6', '8')
    print(text.filter { it in v }.count())
    close()
}

import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*

private val reader = BufferedReader(InputStreamReader(System.`in`))
private val out = PrintWriter(System.out)
private var st = StringTokenizer("")

fun next(): String {
    while (!st.hasMoreTokens())
        st = StringTokenizer(reader.readLine())
    return st.nextToken()
}

fun ni() = next().toInt()
fun nl() = next().toLong()
fun nd() = next().toDouble()
fun print(obj: Any) = out.print(obj)
fun close() = out.close()

fun main(args: Array<String>) {
    val text = next()
    val v = setOf('a', 'e', 'i', 'o', 'u', '0', '2', '4', '6', '8')
    print(text.toSet().filter { it in v }.count())
    close()
}

import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*

private val reader = BufferedReader(InputStreamReader(System.`in`))
private val out = PrintWriter(System.out)
private var st = StringTokenizer("")

fun next(): String {
    while (!st.hasMoreTokens())
        st = StringTokenizer(reader.readLine())
    return st.nextToken()
}

fun ni() = next().toInt()
fun nl() = next().toLong()
fun nd() = next().toDouble()
fun print(obj: Any) = out.print(obj)
fun close() = out.close()

fun main(args: Array<String>) {
    val text = next()
    val v = setOf('a', 'e', 'i', 'o', 'u')
    var range = 1..10 step 2
    print(text.filter { it in v }.count()+range.filter { (it+'0'.toInt()).toChar() in text.toSet() }.count())
    close()
}

fun main(args: Array<String>) = with(java.util.Scanner(System.`in`)) {
    var s = readLine()!!
    var (res, entahapa) = s.partition { (it.isDigit() && it.toInt()%2==0) || it == 'a' || it == 'u' || it == 'o' || it == 'i' || it == 'e' }
    println(res.count())
}

import java.util.*

fun main(args: Array<String>) = with(Scanner(System.`in`)) {
    val arr = next().toCharArray().filter { it.vowel() }
    print("${arr.size}")
}

fun Char.vowel(): Boolean = this == 'a' || this == 'e' || this == 'i' || this == 'o' || this == 'u' || this == 'y'

import java.util.*

fun main(args: Array<String>) = with(Scanner(System.`in`)) {
    val arr = next().toCharArray().filter { it.vowel() }
    print("${arr.size}")
}

fun Char.vowel(): Boolean {
    val v = arrayListOf('a', 'e', 'i', 'o', 'u', '0', '2', '4', '6', '8')
    return v.filter { it == this }.any()
}

import kotlin.*

fun main(args: Array<String>) {
    var vowelsAndEvens = setOf(
            'a', 'o', 'e', 'u', 'i',
            '0', '2', '4', '6', '8')

    var string = readLine() ?: ""
    println(string.count { it in vowelsAndEvens })

}