There is only little time left until the New Year! For that reason, Chef decided to make a present for his best friend. He made a connected and undirected simple graph with N$N$ vertices and M$M$ edges.
Since Chef does not like odd numbers and his friend does not like undirected graphs, Chef decided to direct each edge in one of two possible directions in such a way that the indegrees of all vertices of the resulting graph are even. The indegree of a vertex is the number of edges directed to that vertex from another vertex. As usual, Chef is busy in the kitchen, so you need to help him with directing the edges. Find one possible way to direct them or determine that it is impossible under the given conditions, so that Chef could bake a cake as a present instead.

-----Input-----
- The first line of the input contains a single integer T$T$ denoting the number of test cases. The description of T$T$ test cases follows.
- The first line of each test case contains two space-separated integers N$N$ and M$M$.
- M$M$ lines follow. For each i$i$ (1≤i≤M$1 \le i \le M$), the i$i$-th of these lines contains two space-separated integers ui$u_i$ and vi$v_i$ denoting an edge between vertices ui$u_i$ and vi$v_i$.

-----Output-----
For each test case:
- If a valid way to direct the edges does not exist, print a single line containing one integer −1$-1$.
- Otherwise, print a single line containing M$M$ space-separated integers. For each valid i$i$, the i$i$-th of these integers should be 0$0$ if edge i$i$ is directed from ui$u_i$ to vi$v_i$ or 1$1$ if it is directed from vi$v_i$ to ui$u_i$.

-----Constraints-----
- 1≤T≤5$1 \le T \le 5$
- 1≤N,M≤105$1 \le N, M \le 10^5$
- 1≤ui,vi≤N$1 \le u_i, v_i \le N$ for each valid i$i$
- the graph on the input is connected, does not contain multiple edges or self-loops

-----Subtasks-----
Subtask #1 (30 points): 1≤N,M≤1,000$1 \le N, M \le 1,000$
Subtask #2 (70 points): original constraints

-----Example Input-----
2
4 4
1 2
1 3
2 4
3 4
3 3
1 2
2 3
1 3

-----Example Output-----
0 0 1 1
-1

```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 = 'for _ in range(int(input())):\r\n    N, M = [int(x) for x in input().split()]\r\n    edges = [0]*M\r\n    dir = {}\r\n    nodes = [[] for j in range(N+1)]\r\n    ind = [0]*(N+1)\r\n    graph = {}\r\n    final_edges = []\r\n    for i in range(M):\r\n        u, v = [int(x) for x in input().split()]\r\n        nodes[u].append(v)\r\n        nodes[v].append(u)\r\n        dir[(u,v)]=1\r\n        dir[(v,u)] = 0\r\n        ind[v] += 1\r\n        graph[(u,v)] = graph[(v,u)] = i\r\n        final_edges.append([u,v])\r\n    if M%2!=0:\r\n        print(-1)\r\n        continue\r\n    for i in range(M):\r\n        u, v = final_edges[i]\r\n        if ind[u]%2!=0 and ind[v]%2!=0:\r\n            d = dir[(u,v)]\r\n            if d:\r\n                ind[u] += 1\r\n                ind[v] -= 1\r\n                dir[(u,v)] = 0\r\n                dir[(v,u)] = 1\r\n                edges[i] = abs(edges[i]-1)\r\n            else:\r\n                ind[u] -= 1\r\n                ind[v] += 1\r\n                dir[(u, v)] = 1\r\n                dir[(v, u)] = 0\r\n                edges[i] = abs(edges[i]-1)\r\n    s = []\r\n    for i in range(1, N+1):\r\n        if ind[i]%2:\r\n            s.append(i)\r\n    while s:\r\n        set1 = set()\r\n        for u in s:\r\n            if ind[u]%2:\r\n                v = nodes[u][0]\r\n                d = dir[(u,v)]\r\n                index = graph[(u, v)]\r\n                set1.add(v)\r\n                if d:\r\n                    ind[u] += 1\r\n                    ind[v] -= 1\r\n                    dir[(u, v)] = 0\r\n                    dir[(v, u)] = 1\r\n                    edges[index] = abs(edges[index]-1)\r\n                else:\r\n                    ind[u] -= 1\r\n                    ind[v] += 1\r\n                    dir[(u, v)] = 1\r\n                    dir[(v, u)] = 0\r\n                    edges[index] = abs(edges[index]-1)\r\n\r\n        s = set1\r\n    print(*edges)'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 14347