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 t in range(int(input())):\r\n    n,m=map(int,input().split())\r\n    g=[[]for _ in range(n+1)]\r\n    long=[]\r\n    di={}\r\n    stable=[0]*(n+1)\r\n    edges=[0]*(m)\r\n    for i in range(m):\r\n        x,y=map(int,input().split())\r\n        g[x].append(y)\r\n        g[y].append(x)\r\n        stable[y]+=1\r\n        long.append([x,y])\r\n        di[(x,y)]=i\r\n        di[(y,x)]=i\r\n    f=1\r\n    if m%2:\r\n        f=0\r\n    for i in range(m):\r\n        c,d=long[i][0],long[i][1]\r\n        if stable[c]%2==1 and stable[d]%2==1:\r\n            stable[c]+=1\r\n            stable[d]-=1\r\n            edges[i]=1\r\n    s=[]\r\n    for i in range(1,n+1):\r\n        if stable[i]%2==1:\r\n            s.append(i)\r\n    while s and f:\r\n        set1=set()\r\n        for i in s:\r\n            if stable[i]%2:\r\n                y=g[i][0]\r\n                w=di[(i,y)]\r\n                if edges[x]:\r\n                    stable[y]+=1\r\n                    stable[i]-=1\r\n                else:\r\n                    stable[i]+=1\r\n                    stable[y]-=1\r\n                set1.add(y)\r\n                edges[w]=abs(edges[w]-1)\r\n        s=set1\r\n    if(f):\r\n        print(*edges)\r\n    else:\r\n        print(-1)'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 14033