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

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() {
    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)}")
    }
}

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

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
}

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

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


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
}


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

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


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

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

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

}


fun main(){
    var set = readLine()!!.split(" ").toSet()
    println(4 - set.size)
}

fun main()
{
    val has = readLine()!!.split(" ").map { it.toInt() }.toSet().size
    println( 4 - has)

}

import java.util.*

fun main() {
    val sc = Scanner(System.`in`)
    var set = HashSet<Int>()
    for(i in 0..3)
        set.add(sc.nextInt())
    print(4 - set.size)
}

fun main() = (4 - hashSetOf<String>().apply { addAll(readLine()!!.split(" ")) }.size).run(::println)

    fun main(args: Array<String>) {
        readLine()!!.split(" ").map { it.toInt()}.let {
            println(it.size - it.toSet().size)}

    }

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

fun main(args: Array<String>) {
    val inputStream = System.`in`
    val outputStream = System.out
    val input = InputReader(inputStream)
    val output = PrintWriter(outputStream)
    val solver = Task()
    solver.solve(input, output)
    output.close()
}

private class Task {
    fun solve(input: InputReader, output: PrintWriter) {
        readLine()!!.split(" ").map { it.toInt() }.toSet().count().let { output.println(4 - it) }
    }
}

private class InputReader(stream: InputStream) {
    private var reader: BufferedReader = BufferedReader(InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer? = null

    operator fun next(): String {
        while (tokenizer == null || tokenizer?.hasMoreTokens()?.not() == true) {
            try {
                tokenizer = StringTokenizer(reader.readLine())
            } catch (e: IOException) {
                throw RuntimeException(e)
            }

        }
        return tokenizer!!.nextToken()
    }

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

}

/* https://codeforces.com/problemset/problem/228/A */

fun main() {
    println(4 - readLine()!!.split(" ").toSet().size)
}

fun main() {
    val count = readLine()!!.split(" ")
        .map(Integer::parseInt)
        .distinct()
        .count()

    println(4 - count)
}

import java.util.*

fun main(args: Array<String>) {
    val shoes = Scanner(System.`in`).nextLine().split(" ").map{it.toInt()}
    val distinct = HashSet<Int>()
    var ans = 0

    for(i in shoes.indices) {
        if(distinct.contains(shoes[i])) {
            ans++
        }
        else {
            distinct.add(shoes[i])
        }
    }

    println(ans)
}

fun main(args: Array<String>) {
    val shoes = HashSet<Int>(readLine()?.split(" ")?.map{it.toInt()})
    println(4 - shoes.size)
}

import java.util.*

fun main(args: Array<String>) {
    val shoes = Scanner(System.`in`).nextLine().split(" ").map{it.toInt()}
    val distinct = HashSet<Int>()

    for(i in shoes.indices) {
        distinct.add(shoes[i])
    }

    println(4 - distinct.size)
}

fun main(args: Array<String>) {
    val a = readInts().toSet().size
    print("${4 - a}")
}

private fun readInts() = readLine()!!.split(" ").map { it.toInt() }

import java.io.BufferedReader
import java.io.InputStreamReader

fun main() {
    val br = BufferedReader(InputStreamReader(System.`in`))
    val s = br.readLine().split(" ").map { it.toInt() }
    println(s.size - s.toSet().size)
}

import java.util.*

fun main() {
    val reader = Scanner(System.`in`)
    val t = reader.nextLine().split(" ").toSet()
    println(4-t.size)
}

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

fun findMinNumberOfShoes(): Int {

    val colorsHas = readInts().toSet()
    return 4 - colorsHas.size
}

fun main() {
    print(findMinNumberOfShoes())
}

fun main(args: Array<String>) {
    val p = readLine()!!.split(' ').map { it.toInt() }
    println(4 - p.toSet().size)
}

import java.util.*

fun main(){

    val scan = Scanner(System.`in`)
    val arr = Array<Int>(4){ _ -> scan.nextInt()}
    var count = 1

    for (i in 0 until 3){
        var isUnique = true

        for (j in i+1 until 4){
            if (arr[i] == arr[j]){
                isUnique = false
                break
            }
        }

        if (isUnique) count++
    }

    print(4-count)

}

fun main() {
 var colors : Set<Int> = readLine()!!.split(' ').map { it.toInt() }.toSet();
    println(4 - colors.size)
}

fun main() {
    println(4 - readLine()!!.split(" ").map { it.toInt() }.toSet().size)
}

import java.lang.AssertionError
import java.util.*

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong() // single long
private fun readDouble() = readLn().toDouble() // single double
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 readDoubles() = readStrings().map { it.toDouble() } // list of doubles

private fun myAssert(x: Boolean) {
    if (!x) {
        throw AssertionError()
    }
}

fun main(args: Array<String>) {
//  var s = Scanner(System.`in`)
  var lst = readInts().sorted()
  var ans = 0
  for (i in 1 until lst.size) {
    if (lst[i - 1] == lst[i])
      ans++
  }
  println(ans)
}

fun main() {
    println(4 - readLine()!!.split(" ").toMutableSet().size)
}

import kotlin.math.abs

fun main() {
    val read = readLine()!!.split(" ").map { it.toInt() }
    val distinct  = read.distinct()
    print(abs(distinct.size-read.size))
}

fun main(args: Array<String>) {
    val S: MutableSet<Int> = mutableSetOf()
    readLine()!!.split(' ').map(String::toInt).forEach {
        S.add(it)
    }
    val ans = 4 - S.size.toInt()
    print("$ans\n")
}

fun main(args: Array<String>) {
    println(4 - readLine()!!.split(' ').toSet().size)
}

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong() // single long
private fun readDouble() = readLn().toDouble() // single double
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 readDoubles() = readStrings().map { it.toDouble() } // list of doubles

fun main() {
    val shoes = readInts()

    println(4 - shoes.distinct().size)
}

fun main(args: Array<String>) {
    println(4 - readLine()!!.split(' ').map { it.toInt() }.toSet().size)
}

/* template start */
// input
private fun readString() = readLine()!!
private fun readStrings() = readString().split(" ")
private fun readInt() = readString().toInt()
private fun readDigits() = readString().map { it - '0' }
private fun readInts() = readStrings().map { it.toInt() }
private fun readLongs() = readStrings().map { it.toLong() }

// output
private fun <T> T.print(map: (T) -> String = { it.toString() }) = println(map(this))
private fun <T> Iterable<T>.print(sep: String? = null, map: ((T) -> String)? = null) = asSequence().print(sep, map)
private fun <T> Array<T>.print(sep: String? = null, map: ((T) -> String)? = null) = asSequence().print(sep, map)
private fun IntArray.print(sep: String? = null, map: ((Int) -> String)? = null) = asSequence().print(sep, map)
private fun <T> Sequence<T>.print(sep: String? = null, map: ((T) -> String)? = null) =
    println(joinToString(sep ?: "", transform = map ?: { it.toString() }))

// others
private val Int.isEven: Boolean get() = this % 2 == 0
private val Int.isOdd: Boolean get() = !this.isEven
private fun queries(block: (Int) -> Unit) = repeat(readInt(), block)

/* template end */

fun main() {
    val n = readInts()
    println(n.size - n.toSet().size)
}

fun main() {
    val set = HashSet<Int>()
    val arr = readLine()?.split(" ")?.forEach {
        set.add(it.toInt())
    }

    print(4 - set.size)

}

fun main() {
    val r = System.`in`.bufferedReader()
    val s = StringBuilder()

    val l = r.readLine()!!.split(" ").map { it.toInt() }.toSet()
    println(4-l.size)

}

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

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

val out=mutableListOf<String>()
fun printLine(s:String){out.add(s)}
fun output(){println(out.joinToString("\n"))}

fun main(){
    var col=readInts().toIntArray()
    col.sort()
    var ans=0
    for(i in 1 until 4)if(col[i]==col[i-1])ans++
    printLine("$ans")
    output()
}

fun main() {
    val arr = readLine()!!.split(" ").distinct()
    print(4 - arr.size)
}

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

class ProblemIO(val rd: BufferedReader, val wr: PrintWriter) {
    var tok = StringTokenizer("")

    companion object {
        fun console() = ProblemIO(BufferedReader(InputStreamReader(System.`in`)), PrintWriter(System.out))
        fun files(inputFilename: String, outputFilename: String) =
                ProblemIO(BufferedReader(FileReader(File(inputFilename))), PrintWriter(File(outputFilename)))
    }

    fun readToken(): String {
        while (!tok.hasMoreTokens()) {
            tok = StringTokenizer(rd.readLine())
        }
        return tok.nextToken()
    }

    fun readInt(): Int = readToken().toInt()
    fun <T> print(v: T) = wr.print(v)
    fun <T> println(v: T) = wr.println(v)
    fun close() {
        rd.close()
        wr.close()
    }
}

fun solve() {
    val io = ProblemIO.console()
    val a = IntArray(4)
    for (i in a.indices) {
        a[i] = io.readInt()
    }
    val res = 4 - a.toSet().size
    io.println(res)
    io.close()
}

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


fun main() {
    val scale = readLine()!!
    val middle = scale.indexOf('|')
    val left = scale.substring(0, middle)
    val right = scale.substring(middle + 1)
    val (smaller, bigger) = if (left.length <= right.length) left to right else right to left
    val other = readLine()!!
    if ((smaller.length + bigger.length + other.length) and (1) == 1) return print("Impossible")
    val half = (smaller.length + bigger.length + other.length) / 2
    if (smaller.length + other.length < half) return print("Impossible")
    val newSmaller = smaller + other.substring(0, half - smaller.length)
    val newBigger = bigger + other.substring(half - smaller.length)
    print(if (left.length <= right.length) "$newSmaller|$newBigger" else "$newBigger|$newSmaller")
}

import java.io.BufferedReader
import java.io.InputStreamReader
import java.lang.StringBuilder
import kotlin.math.abs

fun main() {
    val br = BufferedReader(InputStreamReader(System.`in`))
    val scales = br.readLine().split("|")
    val notUsed = br.readLine()
    val left = scales[0].length
    val right = scales[1].length
    val missing = abs(left - right)
    if (notUsed.length >= missing && (notUsed.length - missing) % 2 == 0) {
        val useToComplete = notUsed.substring(0 until missing)
        val rest = notUsed.substring(missing)
        val rest1 = rest.substring(0 until rest.length/2)
        val rest2 = rest.substring(rest.length/2)
        val newLeft = StringBuilder(scales[0])
        val newRight = StringBuilder(scales[1])
        if (left < right) {
            newLeft.append(useToComplete + rest1)
            newRight.append(rest2)
        } else {
            newLeft.append(rest1)
            newRight.append(useToComplete + rest2)
        }
        println("$newLeft|$newRight")
    } else {
        println("Impossible")
    }
}