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

```

Measured memory_bytes: 14347