I Love Factorials

3

2 votes
Medium
Problem

One day AK doing Programming Contest and he is not able to solve the last problem because his program gives same output again and again. After Some time he get to know that Program has some Bug. To fix this Bug he need to represent the number into sum of other numbers factorials. Now AK is need your help and your task is to represent the number into sum of other numbers factorials. If you can't then print "-1"


N = X1! + X2! + ... + Xn!
(Xi < Xjfor all i < j)

Constraint:
1 < T < 105
1 <= N <= 1018

Input :
2
5
9
Output :
-1
1!+2!+3!

NOTE :- There can be multiple solution but you have to print which has larger number
Example
(1) 7 = 0!+3!
(2) 7 = 1!+3!
but second solution is correct.

Time Limit: 1
Memory Limit: 256
Source Limit:
Editor Image

?