LearnToCP
Sign in

Navigation

HomeRoadmapProblemsAbout Us

Theory

Contest Knowledge
Selecting an IDE
Basics
Your First ProgramData types and IOC++ syntaxModuloFunctionsVectorsMatricesTime Complexity
Sorting
SortingCounting sortRadix Sort
Optimization Techniques
Two PointersSum of numbers 1 to nPrefix sumBinary SearchGreedyBinary Search FunctionsBinary Search by AnswerDivide and Conquer
Binary Numbers
Binary NumbersNumbers in codeBitwise OperationsBitmasks
Math
Binary ExponentiationPrime NumbersPrime FactorizationGCD and LCMSieve of EratosthenesModified Sieve
Data Structures
StringsStackQueueMapsSetsPriority QueueCustom Criteria for FunctionsSegment TreesFenwick TreesSparse TablesUnion Find
Combinatorics
Addition PrincipleMultiplication PrincipleCombinatoric ObjectsInclusion Exclusion Principle
Geometry
Geometry BasicsVectorsCross and Dot ProductLinesPolygonsAnglesPoint in PolygonDistances and Intersection PointsConvex HullCircles
Recursion
PointersRecursionGenerating Combinatoric Objects
Dynamic Programming
About DPTree DPBitmask DPDigit DP
Graph Theory
GraphsDFS and BFSShortest PathsTreesTopological SortingDijkstra's AlgorithmMinimum Spanning TreesShortest Path Algorithms
Advanced Graph Theory
BiconnectivityStrongly Connected ComponentsBipartite GraphGraph FlowAugmenting PathsFlow - Minimum Cut DualityHeavy-Light DecompositionCentroid Decomposition
Advanced Data Structures
2D and 3D Segment TreesLazy PropagationImplicit Segment TreesPersistent Segment TreesLowest Common AncestorTrieBalanced Binary Search TreesMo's Algorithm

Prime Factorization

EasyProblem #23
Time LimitMemoryInputOutputTAGS
1 s64 MBstdinstdout
#math

The numbers do not fit in an int.

If a few prime numbers are given, their product is easy to compute. The reverse direction is much harder: given the product, find the primes that make it up. Your task is to print the prime factorization of each given number.

Input

First line of input will be a single integer t - the number of testcases.
Each of the next t lines contains a single integer n.

Output

For every testcase print a single line with the prime factors of n in increasing order, separated by single spaces. Every prime appears as many times as it divides n.

Example

Input
2
900
97
Output
2 2 3 3 5 5
97

900=2⋅2⋅3⋅3⋅5⋅5, and 97 is prime, so it is its own entire factorization.

Constraints

1≤t≤100
2≤n≤2⋅109


This problem was adapted, with permission, from Rastavljanje na proste činioce, authored by Društvo matematičara Srbije and Fondacija Petlja.

Submit your solution

Sign in to submit your solution and track your progress.

Sign in