#K60842. Factor Pair Finder

    ID: 31176 Type: Default 1000ms 256MiB

Factor Pair Finder

Factor Pair Finder

Given a positive integer \(n\), your task is to find all pairs of positive integers \((k, m)\) such that \(k \times m = n\). The pairs should be sorted in ascending order (first by \(k\) then by \(m\)).

For example, if \(n = 12\), the valid pairs are: (1, 12), (2, 6), (3, 4), (4, 3), (6, 2), (12, 1). If no such pairs exist, output -1. Note that this scenario may not occur if \(n\) is a positive integer.

Note: All formulas are written in \(\LaTeX\) format.

inputFormat

The input is given from standard input (stdin). The first line contains an integer (T), denoting the number of test cases. Each of the following (T) lines contains a single positive integer (n).

outputFormat

For each test case, output a single line containing all valid pairs ((k, m)) separated by a comma and a space. Each pair should be printed as two integers separated by a space. If no valid pair exists for a test case, output -1.## sample

3
12
15
1
1 12, 2 6, 3 4, 4 3, 6 2, 12 1

1 15, 3 5, 5 3, 15 1 1 1

</p>