Ivan has an array consisting of n different integers. He decided to reorder all elements in increasing order. Ivan loves merge sort so he decided to represent his array with one or several increasing sequences which he then plans to merge into one sorted array.

Ivan represent his array with increasing sequences with help of the following algorithm.

While there is at least one unused number in array Ivan repeats the following procedure:  iterate through array from the left to the right;  Ivan only looks at unused numbers on current iteration;  if current number is the first unused number on this iteration or this number is greater than previous unused number on current iteration, then Ivan marks the number as used and writes it down. 

For example, if Ivan's array looks like [1, 3, 2, 5, 4] then he will perform two iterations. On first iteration Ivan will use and write numbers [1, 3, 5], and on second one — [2, 4].

Write a program which helps Ivan and finds representation of the given array with one or several increasing sequences in accordance with algorithm described above.


-----Input-----

The first line contains a single integer n (1 ≤ n ≤ 2·10^5) — the number of elements in Ivan's array.

The second line contains a sequence consisting of distinct integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 10^9) — Ivan's array.


-----Output-----

Print representation of the given array in the form of one or more increasing sequences in accordance with the algorithm described above. Each sequence must be printed on a new line.


-----Examples-----
Input
5
1 3 2 5 4

Output
1 3 5 
2 4 

Input
4
4 3 2 1

Output
4 
3 
2 
1 

Input
4
10 30 50 101

Output
10 30 50 101

```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 = 'class CodeforcesTask847BSolution:\n    def __init__(self):\n        self.result = \'\'\n        self.n = 0\n        self.sequence = []\n\n    def read_input(self):\n        self.n = int(input())\n        self.sequence = [int(x) for x in input().split(" ")]\n\n    def process_task(self):\n        mx = 2000001\n        ans = [[] for x in range(mx)]\n        crf = [0] * mx\n        cnt = 0\n        id = 0\n        for x in range(self.n):\n            if not x:\n                ans[cnt].append(self.sequence[x])\n                crf[cnt] = self.sequence[x]\n            else:\n                if self.sequence[x] <= crf[cnt]:\n                    cnt += 1\n                    id = cnt\n                else:\n                    l = 0\n                    r = cnt\n                    while l < r:\n                        mid = (l + r) // 2\n                        if crf[mid] >= self.sequence[x]:\n                            l = mid + 1\n                        else:\n                            r = mid\n                    id = r\n                ans[id].append(self.sequence[x])\n                crf[id] = self.sequence[x]\n        self.result = "\\n".join([" ".join([str(x) for x in row]) for row in ans[:cnt + 1]])\n\n\n    def get_result(self):\n        return self.result\n\n\ndef __starting_point():\n    Solution = CodeforcesTask847BSolution()\n    Solution.read_input()\n    Solution.process_task()\n    print(Solution.get_result())\n\n__starting_point()'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 145139211