看板子学会的求欧拉回路 :)
#include <bits/stdc++.h>
/*
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/hash_policy.hpp>
*/
using namespace std;
const double eps = 1e-10;
const double pi = 3.1415926535897932384626433832795;
const double eln = 2.718281828459045235360287471352;
#define f(i, a, b) for (int i = a; i <= b; i++)
#define scan(x) scanf("%d", &x)
#define mp make_pair
#define pb push_back
#define lowbit(x) (x&(-x))
#define fi first
#define se second
#define SZ(x) int((x).size())
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define summ(a) (accumulate(all(a), 0ll))
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
using ll=long long;
int tt,n,m,tot,hd[(int)2e5+9],deg[(int)2e5+9],mk[(int)4e6+9];
bitset<(int)2e6+9> res;
bitset<(int)2e6+9> vis;
struct edge{
int to,nxt;
}e[(int)4e6+9];
inline void add(int u,int v){
e[++tot]={v,hd[u]},hd[u]=tot;
e[++tot]={u,hd[v]},hd[v]=tot;
}
void dfs(int u){
for(int &eg=hd[u];eg;){
if(vis[eg]){eg=e[eg].nxt;continue;}
vis[eg]=vis[eg^1]=1;
res[eg>>1]=eg&1;
dfs(e[eg].to);
}
}
int main()
{
int size(512<<20); // 512M
__asm__ ( "movq %0, %%rsp\n"::"r"((char*)malloc(size)+size));
ios::sync_with_stdio(false);
cin.tie(0);
cin>>tt;
f(sb,1,tt){
tot=1;
vis.reset(),res.reset();
cin>>n>>m;
for(int i=1;i<=n+1;++i)hd[i]=deg[i]=0;
for(int i=1,x,y;i<=m;++i){
cin>>x>>y;
deg[x]+=1,deg[y]+=1;
add(x,y);
}
for(int i=1;i<=n;++i)if(deg[i]&1)add(i,n+1);
for(int i=1;i<=n;++i)dfs(i);
for(int i=1;i<=m;++i)cout<<res[i];
cout<<"\n";
}
exit(0);
}