After completing some serious investigation, Watson and Holmes are now chilling themselves in the Shimla hills. Very soon Holmes became bored. Holmes lived entirely for his profession. We know he is a workaholic. So Holmes wants to stop his vacation and get back to work. But after a tiresome season, Watson is in no mood to return soon. So to keep Holmes engaged, he decided to give Holmes one math problem. And Holmes agreed to solve the problem and said as soon as he solves the problem, they should return back to work. Watson too agreed. 
The problem was as follows. Watson knows Holmes’ favorite numbers are 6 and 5. So he decided to give Holmes N  single digit numbers. Watson asked Holmes to form a new number with the given N numbers in such a way that the newly formed number should be completely divisible by 5 and 6. Watson told Holmes that he should also form the number from these digits in such a way that the formed number is maximum. He may or may not use all the given numbers. But he is not allowed to use leading zeros. Though he is allowed to leave out some of the numbers, he is not allowed to add any extra numbers, which means the maximum count of each digit in the newly formed number, is the same as the number of times that number is present in those given N digits.

-----Input-----
The first line of input contains one integers T denoting the number of test cases.
Each test case consists of one integer N, number of numbers.
Next line contains contains N single digit integers 

-----Output-----
For each test case output a single number, where the above said conditions are satisfied. If it is not possible to create such a number with the given constraints print -1.If there exists a solution, the maximised number should be greater than or equal to 0. 

-----Constraints-----
- 1 ≤ T ≤ 100
- 1 ≤ N ≤ 10000
- 0 ≤ Each digit ≤ 9

-----Subtasks-----
Subtask #1 : (90 points)
- 1 ≤ T ≤ 100
- 1 ≤ N ≤ 10000

Subtask 2 : (10 points) 

- 1 ≤ T ≤ 10
- 1 ≤ N≤ 10

-----Example-----
Input:
2
12
3 1 2 3 2 0 2 2 2 0 2 3
11
3 9 9 6 4 3 6 4 9 6 0

Output:
33322222200
999666330

```python

USER_FILENAME = "<user_code>"
import sys, json, builtins
import math, heapq, bisect, itertools, functools, collections, statistics, fractions, decimal, operator, array, random, re, string, os, pathlib
try:
    import resource as _res
except Exception:
    _res = None
from collections import Counter, defaultdict, deque, OrderedDict
from functools import lru_cache, reduce
from itertools import accumulate, permutations, combinations, product
from math import gcd, ceil, floor, sqrt
from decimal import Decimal
try:
    from typing import *
except Exception:
    pass
try:
    sys.setrecursionlimit(1_000_000)
except Exception:
    pass
try:
    import site as _site
    try:
        _sys_sites = _site.getsitepackages() if hasattr(_site, "getsitepackages") else []
        for _p in _sys_sites:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
    try:
        _usp = _site.getusersitepackages()
        if isinstance(_usp, str):
            _usp = [_usp]
        for _p in _usp:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
except Exception:
    pass

ns = {"__name__": "__main__"}
for _k, _v in list(globals().items()):
    if not _k.startswith("_"):
        ns[_k] = _v
_CODE = "t = eval(input())\nwhile t:\n n = eval(input())\n z = list(map(int,input().split()))\n a = [0]*10\n for i in z:\n  a[i] += 1\n if a[0] == 0:\n  print(-1)\n \n else:\n  no_1 = a[1] + a[4] + a[7]\n  no_2 = a[2] + a[5] + a[8]\n  s = ''\n  if (no_1 + no_2*2)%3 == 0:\n   s = ''\n  elif no_2 > no_1:\n   no = (no_2 - no_1)%3\n   if no_2 == 1 and no_1 == 0:\n    a[2],a[5],a[8],a[1],a[4],a[7] = 0,0,0,0,0,0\n   elif no == 1:\n    for k in range(2,9,3):\n     if a[k] != 0:\n      a[k] -= 1\n      break \n   elif no == 2:\n    if no_1 > 0:\n     for k in range(1,9,3):\n      if a[k] != 0:\n       a[k] -= 1\n       break\n    else:\n     j = 2\n     i = 2\n     while j > 0:\n      if a[i] >= j:\n       a[i] -= j\n       j = 0\n      else:\n       j -= a[i]\n       a[i] = 0\n       i+= 3\n       \n  elif no_2 < no_1:\n   no = (no_1 - no_2)%3\n   if no_1 == 1 and no_2 == 0:\n    a[2],a[5],a[8],a[1],a[4],a[7] = 0,0,0,0,0,0\n   elif no == 1:\n    for k in range(1,9,3):\n     if a[k] != 0:\n      a[k] -= 1\n      break \n   elif no == 2:\n    if no_2 > 0:\n     for k in range(2,9,3):\n      if a[k] != 0:\n       a[k] -= 1\n       break\n    else:\n     j = 2\n     i = 1\n     while j > 0:\n      if a[i] >= j:\n       a[i] -= j\n       j = 0\n      else:\n       j -= a[i]\n       a[i] = 0\n       i+= 3\n  \n  for i in range(9,-1,-1):\n   s += str(i)*a[i]\n  \n  if len(s) == 0:\n   print(-1)\n  else:\n   print(int(s))\n t -= 1"
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 19136