B. Everyone Loves Tres
Problem
There are 3 heroes and 3 villains, so 6 people in total.
Given a positive integer
n
n
n. Find the smallest integer whose decimal representation has length
n
n
n and consists only of
3
3
3s and
6
6
6s such that it is divisible by both
33
33
33 and
66
66
66. If no such integer exists, print
−
1
-1
−1.
Input
The first line contains a single integer
t
t
t (
1
≤
t
≤
500
1\le t\le 500
1≤t≤500) — the number of test cases.
The only line of each test case contains a single integer
n
n
n (
1
≤
n
≤
500
1\le n\le 500
1≤n≤500) — the length of the decimal representation.
Output
For each test case, output the smallest required integer if such an integer exists and
−
1
-1
−1 otherwise.
Example
Input
6
1
2
3
4
5
7
Output
-1
66
-1
3366
36366
3336366
Note
For
n
=
1
n=1
n=1, no such integer exists as neither
3
3
3 nor
6
6
6 is divisible by
33
33
33.
For
n
=
2
n=2
n=2,
66
66
66 consists only of
6
6
6s and it is divisible by both
33
33
33 and
66
66
66.
For
n
=
3
n=3
n=3, no such integer exists. Only
363
363
363 is divisible by
33
33
33, but it is not divisible by
66
66
66.
For
n
=
4
n=4
n=4,
3366
3366
3366 and
6666
6666
6666 are divisible by both
33
33
33 and
66
66
66, and
3366
3366
3366 is the smallest.
Code
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
string a="66",b="36366";
string c="33";
void solve()
{
ll n;
cin>>n;
if(n==1||n==3)
{
cout<<-1<<endl;
return;
}
string x,y;
if(n&1)
{
for(ll i=0;i<n-5;i++)
x+='3';
cout<<x+b<<endl;
}
else
{
for(ll i=0;i<n-2;i++)
y+='3';
cout<<y+a<<endl;
}
}
int main()
{
ll t;
cin>>t;
while(t--) solve();
return 0;
}