#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i , j , n) for(long long i = j ; i <= n ; i++)
#define per(i , j , n) for(long long i = j ; i >= n ; i--)
#define mp make_pair
#define pb push_back
#define MOD 1000000007
#define endl '\n'
ll getsum(string n) {
	ll ans = 0;
	for (ll i = 0; i < n.length(); i++) {
		ans += n[i] - '0';
	}
	return ans;
}
ll power(ll x, ll y, ll mod) {
	ll res = 1;
	x = x % mod;
	while (y > 0) {
		if (y & 1)
			res = (res * x);
		y = y >> 1;
		x = (x * x) % mod;
	}
	return res;
}
ll power(ll x, ll y) {
	ll res = 1;
	while (y > 0) {
		if (y & 1)
			res = (res * x);
		y = y >> 1;
		x = (x * x);
	}
	return res;
}
string CONVERT_TO_BINARY(ll s) {
	string res = "";
	while (s != 0) {
		res += (char)('0' + s % 2);
		s /= 2;
	}
	reverse(res.begin() , res.end());
	return res;
}
bool PALIN(string s) {
	ll i = 0;
	ll j = s.length() - 1;
	while (i <= j) {
		if (s[i] != s[j]) return false;
		j-- , i++;
	}
	return true;
}
ll modInverse(ll a, ll m) {
	return power(a, m - 2);
}
ll findLongestSub(string bin) {
	ll n = bin.length(), i;
	ll sum = 0;
	unordered_map<ll, ll> prevSum;
	ll maxlen = 0;
	ll currlen;
	for (i = 0; i < n; i++) {
		if (bin[i] == '1')
			sum++;
		else sum--;
		if (sum > 0) {
			maxlen = i + 1;
		}
		else if (sum <= 0) {
			if (prevSum.find(sum - 1) != prevSum.end()) {
				currlen = i - prevSum[sum - 1];
				maxlen = max(maxlen, currlen);
			}
		}
		if (prevSum.find(sum) == prevSum.end())
			prevSum[sum] = i;
	}
	return maxlen;
}
ll binaryToDecimal(string n) {
	string num = n;
	ll dec_value = 0;
	ll base = 1;
	ll len = num.length();
	for (ll i = len - 1; i >= 0; i--) {
		if (num[i] == '1')
			dec_value += base;
		base = base * 2;
	}
	return dec_value;
}
ll _gcd(ll a, ll b) {
	if (b > a) return _gcd(b, a);
	if (b == 0) return a;
	else return _gcd(b, a % b);
}
ll digitsum(ll num) {
	ll ans = 0;
	while (num > 0) {
		ans += num % 10;
		num /= 10;
	}
	return ans;
}
ll countbits(ll n) {
	ll cnt = 0;
	while (n > 0) {
		cnt++;
		n /= 2;
	}
	return cnt;
}
/*
bool *isprime = new bool[10000000] {false};
vector<ll> v;
void sieve() {
	isprime[0] = true;
	isprime[1] = true;
	for (ll i = 2; i * i < 10000000; i++) {
		if (isprime[i] == false) {
			for (ll j = i * 2; j < 10000000; j += i) {
				isprime[j] = true;
			}
		}
	}
}
*/
//ll *prime = new ll[10000000] {0};
/*
void sieve() {
	prime[1] = 1;
	for (ll i = 2; i * i < 10000000; i++) {
		if (prime[i] == 0) {
			for (ll j = i; j < 10000000; j += i) {
				prime[j] = i;
			}
		}
	}
}
*/
vector<ll> adj[200001];
ll color[200001];

bool dfs(ll src, ll c) {
	color[src] = c;
	for (auto x : adj[src]) {
		if (color[x] == c) return false;
		if (color[x] == -1) {
			if(!dfs(x, 1 - c)) return false;
		}
	}
	return true;
}

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	ll n, m; cin >> n >> m;
	ll x[n + 1], y[n + 1];
	rep(i, 0, m - 1) {
		cin >> x[i] >> y[i];
		adj[x[i]].push_back(y[i]);
		adj[y[i]].push_back(x[i]);
	}
	memset(color, -1, sizeof(color));
	bool ans = dfs(1, 1);
	if (ans) {
		cout << "YES" << endl;
		for (int i = 0; i < m; i++) {
			cout << color[x[i]];
		}
	} else cout << "NO" << endl;
}


#include "bits/stdc++.h"
#define ll long long
#define ff first
#define ss second
#define pb(a) push_back(a)
#define mpp(a,b) make_pair(a,b)
#define asort(arr,n) sort(arr,arr+n)
#define vsort(v) sort(v.begin(),v,end())
using namespace std;

vector< vector<ll> > v(100005);
ll visit[100005],visit2[100005];
void dfs(ll x,ll *flag)
{
    ll val=visit[x]^1;
    visit2[x]=1;
    for(ll i=0;i<v[x].size();i++)
    {
        if(!visit2[v[x][i]] && (visit[v[x][i]]==val || visit[v[x][i]]==-1))
        {
            // cout<<x<<" "<<visit2[v[x][i]]<<" "<<visit[v[x][i]]<<" "<<val<<endl;
            visit[v[x][i]]=val;
            dfs(v[x][i],flag);
        }
        else if(!visit2[v[x][i]])
        {

            (*flag)=0;
            return;
        }
    }
}
int main()
{
    // freopen("input1.txt","r",stdin);
    // freopen("output1.txt","w",stdout);
    ll i,j,t,k,l,m,n,sum=0,flag=1,so=0,se=0,sum1=0,x,y,a;

    cin>>n>>m;

    vector< pair<ll,ll> > vp;

    for(i=0;i<m;i++)
    {
        cin>>x>>y;
        vp.pb(mpp(x,y));
        v[x].pb(y);
        v[y].pb(x);
    }

    // memset(visit,-1,sizeof(visit));
    // memset(visit2,0,sizeof(visit2));
    for(i=0;i<100005;i++)
    {
        visit[i]=-1;
        visit2[i]=0;
    }
    string ch;

    visit[1]=0;
    visit2[1]=1;
    dfs(1,&flag);
    if(flag==0)
    {
        cout<<"NO";
        return 0;
    }
    cout<<"YES"<<endl;
    for(i=0;i<vp.size();i++)
    {
        a=vp[i].first;
        cout<<(visit[a]^1);
    }

    return 0;
}


#include "bits/stdc++.h"
#define ll long long
#define ff first
#define ss second
#define pb(a) push_back(a)
#define mpp(a,b) make_pair(a,b)
#define asort(arr,n) sort(arr,arr+n)
#define vsort(v) sort(v.begin(),v,end())
using namespace std;

vector< vector<ll> > v(200005);
ll visit[200005],visit2[200005];
void dfs(ll x,ll *flag)
{
    ll val=visit[x]^1;
    visit2[x]=1;
    for(ll i=0;i<v[x].size();i++)
    {
        if(!visit2[v[x][i]] && (visit[v[x][i]]==val || visit[v[x][i]]==-1))
        {
            // cout<<x<<" "<<visit2[v[x][i]]<<" "<<visit[v[x][i]]<<" "<<val<<endl;
            visit[v[x][i]]=val;
            dfs(v[x][i],flag);
        }
        else if(!visit2[v[x][i]])
        {

            (*flag)=0;
            return;
        }
    }
}
int main()
{
    // freopen("input1.txt","r",stdin);
    // freopen("output1.txt","w",stdout);
    ll i,j,t,k,l,m,n,sum=0,flag=1,so=0,se=0,sum1=0,x,y,a;

    cin>>n>>m;

    vector< pair<ll,ll> > vp;

    for(i=0;i<m;i++)
    {
        cin>>x>>y;
        vp.pb(mpp(x,y));
        v[x].pb(y);
        v[y].pb(x);
    }

    // memset(visit,-1,sizeof(visit));
    // memset(visit2,0,sizeof(visit2));
    for(i=0;i<100005;i++)
    {
        visit[i]=-1;
        visit2[i]=0;
    }
    string ch;

    visit[1]=0;
    visit2[1]=1;
    dfs(1,&flag);
    if(flag==0)
    {
        cout<<"NO";
        return 0;
    }
    cout<<"YES"<<endl;
    for(i=0;i<vp.size();i++)
    {
        a=vp[i].first;
        cout<<(visit[a]^1);
    }

    return 0;
}


#include "bits/stdc++.h"
#define ll long long
#define ff first
#define ss second
#define pb(a) push_back(a)
#define mpp(a,b) make_pair(a,b)
#define asort(arr,n) sort(arr,arr+n)
#define vsort(v) sort(v.begin(),v,end())
using namespace std;

vector< vector<ll> > v(200005);
ll visit[200005],visit2[200005];
void dfs(ll x,ll *flag)
{
    ll val=visit[x]^1;
    if(visit2[x]==1)
        return;
    visit2[x]=1;
    for(ll i=0;i<v[x].size();i++)
    {
        if(!visit2[v[x][i]] && (visit[v[x][i]]==val || visit[v[x][i]]==-1))
        {
            // cout<<x<<" "<<visit2[v[x][i]]<<" "<<visit[v[x][i]]<<" "<<val<<endl;
            visit[v[x][i]]=val;

        }
        else if(!visit2[v[x][i]])
        {

            (*flag)=0;
            return;
        }
    }

    for(ll i=0;i<v[x].size();i++)
        dfs(v[x][i],flag);
}
int main()
{
    // freopen("input1.txt","r",stdin);
    // freopen("output1.txt","w",stdout);
    ll i,j,t,k,l,m,n,sum=0,flag=1,so=0,se=0,sum1=0,x,y,a;

    cin>>n>>m;

    // if(n&1)
    // {
    //     cout<<"NO";
    //     return 0;
    // }
    vector< pair<ll,ll> > vp;

    for(i=0;i<m;i++)
    {
        cin>>x>>y;
        vp.pb(mpp(x,y));
        v[x].pb(y);
        v[y].pb(x);
    }

    // memset(visit,-1,sizeof(visit));
    // memset(visit2,0,sizeof(visit2));
    for(i=0;i<100005;i++)
    {
        visit[i]=-1;
        visit2[i]=0;
    }
    string ch;

    visit[1]=0;
    // visit2[1]=1;
    dfs(1,&flag);
    for(i=1;i<=n;i++)
    {
        for(j=0;j<v[i].size();j++)
        {
            if(visit[i]==-1 || visit[i]==visit[v[i][j]])
                flag=0;
        }
    }
    if(flag==0)
    {
        cout<<"NO";
        return 0;
    }
    cout<<"YES"<<endl;
    for(i=0;i<vp.size();i++)
    {
        a=vp[i].first;
        cout<<(visit[a]^1);
    }

    return 0;
}


#include "bits/stdc++.h"
#define ll long long
#define ff first
#define ss second
#define pb(a) push_back(a)
#define mpp(a,b) make_pair(a,b)
#define asort(arr,n) sort(arr,arr+n)
#define vsort(v) sort(v.bevecin(),v,end())
using namespace std;

const ll limited = 200001;

vector<ll> vec[limited];
bool visited[limited];
ll d[limited];

bool find(ll v);
vector<pair<ll, ll> > edges;

int main() {
	// freopen("input1.txt","r",stdin);
    // freopen("output1.txt","w",stdout);
	ll n;
	cin >> n;
	ll m;
	cin >> m;
	for(ll i = 0; i <m; i++) {
		ll a, b;
		cin >> a >> b;
		vec[a].pb(b);
		vec[b].pb(a);
		edges.pb(make_pair(a,b));
	}
	ll s = 1;
	bool ok = find(s);

	if(!ok) {
		cout <<  "NO" << endl;
		return 0;
	}
	cout << "YES" << endl;
	for(auto x : edges)
	{
		if(d[x.second])
		{
			cout <<1;
		}
		else{
			cout<<0;
		}
	}
	cout << endl;
	return 0;
}
bool find(ll v)
{
	visited[v] = 1;
	for(auto x : vec[v])
	{

		if(visited[x])
		{
			if(d[x] == d[v]) return false;
			continue;
		}
		d[x] = d[v] ^ 1;
		if(!find(x)) return false;
	}
	return true;
}


#include "bits/stdc++.h"
#define ll long long
#define ff first
#define ss second
#define pb(a) push_back(a)
#define mpp(a,b) make_pair(a,b)
#define asort(arr,n) sort(arr,arr+n)
#define vsort(v) sort(v.begin(),v,end())
using namespace std;

vector< vector<ll> > v(200005);
ll visit[200005],visit2[200005];
void dfs(ll x,ll *flag)
{
    ll val=visit[x]^1;
    visit2[x]=1;
    for(ll i=0;i<v[x].size();i++)
    {
        if(!visit2[v[x][i]] && (visit[v[x][i]]==val || visit[v[x][i]]==-1))
        {
            // cout<<x<<" "<<visit2[v[x][i]]<<" "<<visit[v[x][i]]<<" "<<val<<endl;
            visit[v[x][i]]=val;
            dfs(v[x][i],flag);
        }
        else if(!visit2[v[x][i]])
        {

            (*flag)=0;
            return;
        }
    }
}
int main()
{
    // freopen("input1.txt","r",stdin);
    // freopen("output1.txt","w",stdout);
    ll i,j,t,k,l,m,n,sum=0,flag=1,so=0,se=0,sum1=0,x,y,a;

    cin>>n>>m;

    if(n&1)
    {
        cout<<"NO";
        return 0;
    }
    vector< pair<ll,ll> > vp;

    for(i=0;i<m;i++)
    {
        cin>>x>>y;
        vp.pb(mpp(x,y));
        v[x].pb(y);
        v[y].pb(x);
    }

    // memset(visit,-1,sizeof(visit));
    // memset(visit2,0,sizeof(visit2));
    for(i=0;i<100005;i++)
    {
        visit[i]=-1;
        visit2[i]=0;
    }
    string ch;

    visit[1]=0;
    visit2[1]=1;
    dfs(1,&flag);
    if(flag==0)
    {
        cout<<"NO";
        return 0;
    }
    cout<<"YES"<<endl;
    for(i=0;i<vp.size();i++)
    {
        a=vp[i].first;
        cout<<(visit[a]^1);
    }

    return 0;
}


#include "bits/stdc++.h"
#define ll long long
#define ff first
#define ss second
#define pb(a) push_back(a)
#define mpp(a,b) make_pair(a,b)
#define asort(arr,n) sort(arr,arr+n)
#define vsort(v) sort(v.begin(),v,end())
using namespace std;

vector< vector<ll> > v(200005);
ll visit[200005],visit2[200005];
void dfs(ll x,ll *flag)
{
    ll val=visit[x]^1;
    if(visit2[x]==1)
        return;
    visit2[x]=1;
    for(ll i=0;i<v[x].size();i++)
    {
        if(!visit2[v[x][i]] && (visit[v[x][i]]==val || visit[v[x][i]]==-1))
        {
            // cout<<x<<" "<<visit2[v[x][i]]<<" "<<visit[v[x][i]]<<" "<<val<<endl;
            visit[v[x][i]]=val;

        }
        else if(!visit2[v[x][i]])
        {

            (*flag)=0;
            return;
        }
    }

    for(ll i=0;i<v[x].size();i++)
        dfs(v[x][i],flag);
}
int main()
{
    // freopen("input1.txt","r",stdin);
    // freopen("output1.txt","w",stdout);
    ll i,j,t,k,l,m,n,sum=0,flag=1,so=0,se=0,sum1=0,x,y,a;

    cin>>n>>m;

    // if(n&1)
    // {
    //     cout<<"NO";
    //     return 0;
    // }
    vector< pair<ll,ll> > vp;

    for(i=0;i<m;i++)
    {
        cin>>x>>y;
        vp.pb(mpp(x,y));
        v[x].pb(y);
        v[y].pb(x);
    }

    // memset(visit,-1,sizeof(visit));
    // memset(visit2,0,sizeof(visit2));
    for(i=0;i<100005;i++)
    {
        visit[i]=-1;
        visit2[i]=0;
    }
    string ch;

    visit[1]=0;
    // visit2[1]=1;
    dfs(1,&flag);
    if(flag==0)
    {
        cout<<"NO";
        return 0;
    }
    cout<<"YES"<<endl;
    for(i=0;i<vp.size();i++)
    {
        a=vp[i].first;
        cout<<(visit[a]^1);
    }

    return 0;
}


#include "bits/stdc++.h"
#define ll long long
#define ff first
#define ss second
#define pb(a) push_back(a)
#define mpp(a,b) make_pair(a,b)
#define asort(arr,n) sort(arr,arr+n)
#define vsort(v) sort(v.begin(),v,end())
using namespace std;

vector< vector<ll> > v(200005);
ll visit[200005],visit2[200005];
void dfs(ll x,ll *flag)
{
    ll val=visit[x]^1;
    if(visit2[x]==1)
        return;
    visit2[x]=1;
    for(ll i=0;i<v[x].size();i++)
    {
        if(!visit2[v[x][i]] && (visit[v[x][i]]==val || visit[v[x][i]]==-1))
        {
            // cout<<x<<" "<<visit2[v[x][i]]<<" "<<visit[v[x][i]]<<" "<<val<<endl;
            visit[v[x][i]]=val;

        }
        else if(!visit2[v[x][i]])
        {
            (*flag)=0;
            return;
        }
        else if(visit[v[x][i]]!=val)
        {
            (*flag)=0;
            return;
        }
    }

    for(ll i=0;i<v[x].size();i++)
        dfs(v[x][i],flag);
}
int main()
{
    // freopen("input1.txt","r",stdin);
    // freopen("output1.txt","w",stdout);
    ll i,j,t,k,l,m,n,sum=0,flag=1,so=0,se=0,sum1=0,x,y,a;

    cin>>n>>m;

    // if(n&1)
    // {
    //     cout<<"NO";
    //     return 0;
    // }
    vector< pair<ll,ll> > vp;

    for(i=0;i<m;i++)
    {
        cin>>x>>y;
        vp.pb(mpp(x,y));
        v[x].pb(y);
        v[y].pb(x);
    }

    // memset(visit,-1,sizeof(visit));
    // memset(visit2,0,sizeof(visit2));
    for(i=0;i<100005;i++)
    {
        visit[i]=-1;
        visit2[i]=0;
    }
    string ch;

    visit[1]=0;
    // visit2[1]=1;
    dfs(1,&flag);
    for(i=1;i<=n;i++)
    {
        for(j=0;j<v[i].size();j++)
        {
            if(visit[i]==-1 || visit[i]==visit[v[i][j]])
                flag=0;
        }
    }
    if(flag==0)
    {
        cout<<"NO";
        return 0;
    }
    cout<<"YES"<<endl;
    for(i=0;i<vp.size();i++)
    {
        a=vp[i].first;
        cout<<(visit[a]^1);
    }

    return 0;
}


#include "bits/stdc++.h"
#define ll long long
#define ff first
#define ss second
#define pb(a) push_back(a)
#define mpp(a,b) make_pair(a,b)
#define asort(arr,n) sort(arr,arr+n)
#define vsort(v) sort(v.begin(),v,end())
using namespace std;

vector< vector<ll> > v(200005);
ll visit[200005],visit2[200005];
void dfs(ll x,ll *flag)
{
    ll val=visit[x]^1;
    if(visit2[x]==1)
        return;
    visit2[x]=1;
    for(ll i=0;i<v[x].size();i++)
    {
        if(!visit2[v[x][i]] && (visit[v[x][i]]==val || visit[v[x][i]]==-1))
        {
            // cout<<x<<" "<<visit2[v[x][i]]<<" "<<visit[v[x][i]]<<" "<<val<<endl;
            visit[v[x][i]]=val;
        }
        else if(!visit2[v[x][i]])
        {
            (*flag)=0;
            return;
        }
        else if(visit[v[x][i]]!=val)
        {
            (*flag)=0;
            return;
        }
    }

    for(ll i=0;i<v[x].size();i++)
        dfs(v[x][i],flag);
}
int main()
{
    // freopen("input1.txt","r",stdin);
    // freopen("output1.txt","w",stdout);
    ll i,j,t,k,l,m,n,sum=0,flag=1,so=0,se=0,sum1=0,x,y,a;

    cin>>n>>m;

    // if(n&1)
    // {
    //     cout<<"NO";
    //     return 0;
    // }
    vector< pair<ll,ll> > vp;

    for(i=0;i<m;i++)
    {
        cin>>x>>y;
        vp.pb(mpp(x,y));
        v[x].pb(y);
        v[y].pb(x);
    }

    // memset(visit,-1,sizeof(visit));
    // memset(visit2,0,sizeof(visit2));
    for(i=0;i<200005;i++)
    {
        visit[i]=-1;
        visit2[i]=0;
    }
    string ch;

    visit[1]=0;
    // visit2[1]=1;
    dfs(1,&flag);
    for(i=1;i<=n;i++)
    {
        for(j=0;j<v[i].size();j++)
        {
            if(visit[i]==-1 || visit[i]==visit[v[i][j]])
                flag=0;
        }
    }
    if(flag==0)
    {
        cout<<"NO";
        return 0;
    }
    cout<<"YES"<<endl;
    for(i=0;i<vp.size();i++)
    {
        a=vp[i].first;
        cout<<(visit[a]^1);
    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define pii pair<int,int>

int m,n;
vector< vector< pii > > adj;
vector<bool> vis;
 vector<int> lev;

void addedge(int u,int v){
	adj[u].pb(mp(v,-1));
	adj[v].pb(mp(u,-1));
}

bool bfs(int src){
	queue<int> q;
	q.push(src);
	vis[src]=true;
	lev[src]=1;
	int fl=0;
	while(!q.empty()){
		int curr=q.front();
		q.pop();
		int level=lev[curr];
		for(int i=0;i<adj[curr].size();i++){
			int node=adj[curr][i].fi;
			if(!vis[node]){
				adj[curr][i].se=fl;
				for(int j=0;j<adj[node].size();j++){
					if(adj[node][j].fi==curr){
						if(fl==1) adj[node][j].se=0;
						else adj[node][j].se=1;
					}
				}
				q.push(node);
				vis[node]=true;
				lev[node]=level+1;
			}
			else{
				if(lev[node]==level) return false;
			}
		}
		if(fl==0) fl=1;
		else fl=0;
	}
	return true;
}

int main(){
	cin>>n>>m;
	vector< pii > edges;
	adj.assign(n,vector<pii>());
	vis.assign(n,false);
	lev.assign(n,0);
	for(int i=0;i<m;i++){
		int u,v;
		cin>>u>>v;
		u--;v--;
		addedge(u,v);
		edges.pb(mp(u,v));
	}
	if(bfs(0)){
		cout<<"YES\n";
		for(int i=0;i<edges.size();i++){
			int u=edges[i].fi,v=edges[i].se;
			for(int j=0;j<adj[u].size();j++){
				if(adj[u][j].fi==v){
					cout<<adj[u][j].se;
					break;
				}
			}
		}
	}
	else cout<<"NO";
}


#include <bits/stdc++.h>
#define int long long int
#define endl "\n"
#define loop(i,n) for(int i=0;i<n;i++)
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fileread freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define pb push_back
#define mp make_pair
#define itr iterator
#define fi first
#define se second
#define pii pair<int,int>
#define pci pair<char,int>
#define u_map unordered_map
#define u_set unordered_set
#define u_mmap unordered_multimap
#define u_mset unordered_multiset
# define pi 3.14159265358979323846
using namespace std;

/*
s.push_back() is used to push_back a character whereas += is used to push_back a string;
    str[i] acts as both string as well as character
    if you want to iterate a string without knowing the size of the string, use '\0' in for loop
    for(int i = 0; str[i] != '\0'; i++)

--------------------------------------------------------------------------------------------------------
    vector<int> v;
    v.assign(n,-2);

    -> way to assign size of vector and fill it the entire vector with num of choice

--------------------------------------------------------------------------------------------------------

    STRING FIND: returns the index of 1st occurence of char or string passed to a string str;
    the optional second argument(0 by default) specifies the initial position from where the string
    search is to begin

    string str="geeks are here!";
    int found =str.find('x');
	if(found!=string::npos) cout<<found;
	else cout<<"not found";

	string::npos has an int value of -1;

--------------------------------------------------------------------------------------------------------

    For LCM:
    int LCM(int a, int b)
    {
        return (b*a)/GCD(a,b);
    }

--------------------------------------------------------------------------------------------------------

    In math problems, if you want to find maximum value in an array of integers,
    initialize "maxx" to -INT_MAX & not to 0 (incase all intergers are negative 0 is not maximum)

--------------------------------------------------------------------------------------------------------

    character arithmetic :
            'a'-'a' = 0
            'b'-'a' = 1
    USE : when you want to store count of characters in specific position in a vector or array,
    EX : store 'a' at 0, store 'b' at 1...

    given : string str= "welcome to codeforces";
            int arr[26];
            for(int i=0;i<26;i++){
                arr[str[i]-'a']++;
            }
    NO NEED TO CONVERT CHAR TO INT

--------------------------------------------------------------------------------------------------------
*/

int n,m;
string ans="YES";
vector< vector< pii > > adj;
vector<bool> vis;
/*
void addedge(int u, int v){
    adj[u].pb(v);
    adj[v].pb(u);
}
*/

void bfs(int src){
    queue< int > q;
    q.push(src);
    vis[src]=true;
    int fl=1;
    while(!q.empty()){
        int curr=q.front();
        q.pop();
        for(int i=0;i<adj[curr].size();i++){
            int node=adj[curr][i].fi;
            if(!vis[node]){
                q.push(node);
                vis[node]=true;
                adj[curr][i].se=fl;
                //cout<<node<<" "<<fl<<"\n";
            }

        }
        if(fl==1) fl=0;
        else fl=1;
    }
}

/*
void printgraph(){
    for(int i=0;i<n;i++){
        cout<<i<<" -> ";
        for(int j=0;j<adj[i].size();j++) cout<<adj[i][j]<<" ";
        cout<<endl;
    }
}
*/

signed main() {
	/*
	----------
	----------
	----------
	----------
	----------
	----------
	----------
	----------
	----------
	----------
	----------
	----------
	----------
	----------
    */

    cin>>n>>m;
    adj.assign(n,vector< pii >());
    vis.assign(n,false);
    vector<pii> edges;
    for(int i=0;i<m;i++){
        int u,v;
        cin>>u>>v;
        u--;v--;
        edges.pb(mp(u,v));
        adj[u].pb(mp(v,0));
        adj[v].pb(mp(u,0));
    }
    /*
    for(int i=0;i<n;i++){
        cout<<i<<" : ";
        for(auto it=adj[i].begin();it!=adj[i].end();it++) cout<<it->fi<<" ";
        cout<<endl;
    }
    */

    bfs(0);
    cout<<"YES"<<endl;
    for(int i=0;i<edges.size();i++){
        int u=edges[i].fi,v=edges[i].se;
        for(int i=0;i<adj[u].size();i++){
            int node=adj[u][i].fi,state=adj[u][i].se;
            if(node==v){
                if(state==-1){
                    for(int j=0;j<adj[v].size();j++){
                        if(adj[v][j].fi==u){
                            if(adj[v][j].se==1) cout<<0;
                            else cout<<1;

                            break;
                        }
                    }
                }
                else{
                    cout<<state;
                    break;
                }

            }
        }
    }

}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define pii pair<int,int>

int m,n;
vector< vector< pii > > adj;
vector<bool> vis;
 vector<int> lev;

void addedge(int u,int v){
	adj[u].pb(mp(v,-1));
	adj[v].pb(mp(u,-1));
}

bool bfs(int src){
	queue<int> q;
	q.push(src);
	vis[src]=true;
	lev[src]=0;
	while(!q.empty()){
		int curr=q.front();
		q.pop();
		int level=lev[curr];
		for(int i=0;i<adj[curr].size();i++){
			int node=adj[curr][i].fi;
			if(!vis[node]){
				q.push(node);
				vis[node]=true;
				lev[node]=level+1;
				int condition=lev[node]%2;
				adj[curr][i].se=condition;
				for(int j=0;j<adj[node].size();j++){
					if(adj[node][j].fi==curr){
						if(condition==1) adj[node][j].se=0;
						else adj[node][j].se=1;
					}
				}
			}
			else{
				if(lev[node]==level) return false;
			}
		}
	}
	return true;
}

int main(){
	cin>>n>>m;
	vector< pii > edges;
	adj.assign(n,vector<pii>());
	vis.assign(n,false);
	lev.assign(n,0);
	for(int i=0;i<m;i++){
		int u,v;
		cin>>u>>v;
		u--;v--;
		addedge(u,v);
		edges.pb(mp(u,v));
	}
	if(bfs(0)){
		cout<<"YES\n";
		for(int i=0;i<edges.size();i++){
			int u=edges[i].fi,v=edges[i].se;
			for(int j=0;j<adj[u].size();j++){
				if(adj[u][j].fi==v){
					if(adj[u][j].se==-1){
						cout<<1;
					}
					else cout<<adj[u][j].se;
					break;
				}
			}
		}
	}
	else cout<<"NO";
}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define pii pair<int,int>

int m,n;
vector< vector< pii > > adj;
vector<bool> vis;
 vector<int> lev;

void addedge(int u,int v){
	adj[u].pb(mp(v,-1));
	adj[v].pb(mp(u,-1));
}

bool bfs(int src){
	queue<int> q;
	q.push(src);
	vis[src]=true;
	lev[src]=0;
	while(!q.empty()){
		int curr=q.front();
		q.pop();
		int level=lev[curr];
		for(int i=0;i<adj[curr].size();i++){
			int node=adj[curr][i].fi;
			if(!vis[node]){
				q.push(node);
				vis[node]=true;
				lev[node]=level+1;
				int condition=lev[node]%2;
				adj[curr][i].se=condition;
				for(int j=0;j<adj[node].size();j++){
					if(adj[node][j].fi==curr){
						if(condition==1) adj[node][j].se=0;
						else adj[node][j].se=1;
					}
				}
			}
			else{
				if(lev[node]==level) return false;
				int condition=lev[node]%2;
				adj[curr][i].se=condition;
				for(int j=0;j<adj[node].size();j++){
					if(adj[node][j].fi==curr){
						if(condition==1) adj[node][j].se=0;
						else adj[node][j].se=1;
					}
				}
			}
		}
	}
	return true;
}

int main(){
	cin>>n>>m;
	vector< pii > edges;
	adj.assign(n,vector<pii>());
	vis.assign(n,false);
	lev.assign(n,0);
	for(int i=0;i<m;i++){
		int u,v;
		cin>>u>>v;
		u--;v--;
		addedge(u,v);
		edges.pb(mp(u,v));
	}
	if(bfs(0)){
		cout<<"YES\n";
		for(int i=0;i<edges.size();i++){
			int u=edges[i].fi,v=edges[i].se;
			for(int j=0;j<adj[u].size();j++){
				if(adj[u][j].fi==v){
					if(adj[u][j].se==-1){
						cout<<1;
					}
					else cout<<adj[u][j].se;
					break;
				}
			}
		}
	}
	else cout<<"NO";
}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define pii pair<int,int>

int m,n;
vector< vector< pii > > adj;
vector<bool> vis;
 vector<int> lev;

void addedge(int u,int v){
	adj[u].pb(mp(v,-1));
	adj[v].pb(mp(u,-1));
}

bool bfs(int src){
	queue<int> q;
	q.push(src);
	vis[src]=true;
	lev[src]=1;
	int fl=0;
	while(!q.empty()){
		int curr=q.front();
		q.pop();
		int level=lev[curr];
		for(int i=0;i<adj[curr].size();i++){
			int node=adj[curr][i].fi;
			if(!vis[node]){
				adj[curr][i].se=fl;
				for(int j=0;j<adj[node].size();j++){
					if(adj[node][j].fi==curr){
						if(fl==1) adj[node][j].se=0;
						else adj[node][j].se=1;
					}
				}
				q.push(node);
				vis[node]=true;
				lev[node]=level+1;
			}
			else{
				if(lev[node]==level) return false;
			}
		}
		if(fl==0) fl=1;
		else fl=0;
	}
	return true;
}

int main(){
	cin>>n>>m;
	vector< pii > edges;
	adj.assign(n,vector<pii>());
	vis.assign(n,false);
	lev.assign(n,0);
	for(int i=0;i<m;i++){
		int u,v;
		cin>>u>>v;
		u--;v--;
		addedge(u,v);
		edges.pb(mp(u,v));
	}
	if(bfs(0)){
		cout<<"YES\n";
		for(int i=0;i<edges.size();i=++){
			int u=edges[i].fi,v=edges[i].se;
			for(int j=0;j<adj[u].size();j++){
				if(adj[u][j]==v){
					cout<<adj[u][j].se;
					break;
				}
			}
		}
	}
	else cout<<"NO";
}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define pii pair<int,int>

int m,n;
vector< vector< pii > > adj;
vector<bool> vis;
 vector<int> lev;

void addedge(int u,int v){
	adj[u].pb(mp(v,-1));
	adj[v].pb(mp(u,-1));
}

bool bfs(int src){
	queue<int> q;
	q.push(src);
	vis[src]=true;
	lev[src]=1;
	while(!q.empty()){
		int curr=q.front();
		q.pop();
		int level=lev[curr];
		for(int i=0;i<adj[curr].size();i++){
			int node=adj[curr][i].fi;
			if(!vis[node]){
				q.push(node);
				vis[node]=true;
				lev[node]=level+1;
				int condition=lev[node]%2;
				adj[curr][i].se=condition;
				for(int j=0;j<adj[node].size();j++){
					if(adj[node][j].fi==curr){
						if(condition==1) adj[node][j].se=0;
						else adj[node][j].se=1;
					}
				}
			}
			else{
				if(lev[node]==level) return false;
			}
		}
	}
	return true;
}

int main(){
	cin>>n>>m;
	vector< pii > edges;
	adj.assign(n,vector<pii>());
	vis.assign(n,false);
	lev.assign(n,0);
	for(int i=0;i<m;i++){
		int u,v;
		cin>>u>>v;
		u--;v--;
		addedge(u,v);
		edges.pb(mp(u,v));
	}
	if(bfs(0)){
		cout<<"YES\n";
		for(int i=0;i<edges.size();i++){
			int u=edges[i].fi,v=edges[i].se;
			for(int j=0;j<adj[u].size();j++){
				if(adj[u][j].fi==v){
					cout<<adj[u][j].se;
					break;
				}
			}
		}
	}
	else cout<<"NO";
}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define pii pair<int,int>

int m,n;
vector< map<int,int> > adj;
vector<bool> vis;
vector<int> lev;

void addedge(int u,int v){
	adj[u].insert(mp(v,-1));
	adj[v].insert(mp(u,-1));
}

bool bfs(int src){
	queue<int> q;
	q.push(src);
	vis[src]=true;
	lev[src]=0;
	while(!q.empty()){
		int curr=q.front();
		q.pop();
		int level=lev[curr];
		for(auto it=adj[curr].begin();it!=adj[curr].end();it++){
			int node=it->first;
			if(!vis[node]){
				q.push(node);
				vis[node]=true;
				lev[node]=level+1;
				int condition=lev[node]%2;
				it->se=condition;

				auto it1=adj[node].find(curr);
				if(condition==1) it1->se=0;
				else it1->se=1;

			}
			else{
				if(lev[node]==level) return false;
				int condition=lev[node]%2;
				it->se=condition;
				auto it1=adj[node].find(curr);
				if(condition==1) it1->se=0;
				else it1->se=1;
			}
		}
	}
	return true;
}

int main(){
	cin>>n>>m;
	vector< pii > edges;
	adj.assign(n,map<int,int>());
	vis.assign(n,false);
	lev.assign(n,0);
	for(int i=0;i<m;i++){
		int u,v;
		cin>>u>>v;
		u--;v--;
		addedge(u,v);
		edges.pb(mp(u,v));
	}

	if(bfs(0)){
		cout<<"YES\n";
		for(int i=0;i<edges.size();i++){
			int u=edges[i].fi,v=edges[i].se;
			map<int,int>::iterator it=adj[u].find(v);
			cout<<it->se;

		}
	}
	else cout<<"NO";
}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define pii pair<int,int>

int m,n;
vector< vector< pii > > adj;
vector<bool> vis;
 vector<int> lev;

void addedge(int u,int v){
	adj[u].pb(mp(v,-1));
	adj[v].pb(mp(u,-1));
}

bool bfs(int src){
	queue<int> q;
	q.push(src);
	vis[src]=true;
	lev[src]=0;
	while(!q.empty()){
		int curr=q.front();
		q.pop();
		int level=lev[curr];
		for(int i=0;i<adj[curr].size();i++){
			int node=adj[curr][i].fi;
			if(!vis[node]){
				q.push(node);
				vis[node]=true;
				lev[node]=level+1;
				int condition=lev[node]%2;
				adj[curr][i].se=condition;
				for(int j=0;j<adj[node].size();j++){
					if(adj[node][j].fi==curr){
						if(condition==1) adj[node][j].se=0;
						else adj[node][j].se=1;
					}
				}
			}
			else{
				if(lev[node]==level) return false;
			}
		}
	}
	return true;
}

int main(){
	cin>>n>>m;
	vector< pii > edges;
	adj.assign(n,vector<pii>());
	vis.assign(n,false);
	lev.assign(n,0);
	for(int i=0;i<m;i++){
		int u,v;
		cin>>u>>v;
		u--;v--;
		addedge(u,v);
		edges.pb(mp(u,v));
	}
	if(bfs(0)){
		cout<<"YES\n";
		for(int i=0;i<edges.size();i++){
			int u=edges[i].fi,v=edges[i].se;
			for(int j=0;j<adj[u].size();j++){
				if(adj[u][j].fi==v){
					cout<<adj[u][j].se;
					break;
				}
			}
		}
	}
	else cout<<"NO";
}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define pii pair<int,int>

int m,n;
vector< vector< pii > > adj;
vector<bool> vis;
 vector<int> lev;

void addedge(int u,int v){
	adj[u].pb(mp(v,-1));
	adj[v].pb(mp(u,-1));
}

bool bfs(int src){
	queue<int> q;
	q.push(src);
	vis[src]=true;
	lev[src]=0;
	while(!q.empty()){
		int curr=q.front();
		q.pop();
		int level=lev[curr];
		//cout<<curr<<" "<<level<<"\n";
		for(int i=0;i<adj[curr].size();i++){
			int node=adj[curr][i].fi;
			if(!vis[node]){
				q.push(node);
				vis[node]=true;
				lev[node]=level+1;
				int condition=lev[node]%2;
				adj[curr][i].se=condition;
				for(int j=0;j<adj[node].size();j++){
					if(adj[node][j].fi==curr){
						if(condition==1) adj[node][j].se=0;
						else adj[node][j].se=1;
					}
				}
				//cout<<curr<<" "<<adj[curr][i].fi<<" "<<adj[curr][i].se<<endl;
			}
			else{
			    if(lev[node]==level) return false;

			    int condition=lev[node]%2;
				adj[curr][i].se=condition;
				for(int j=0;j<adj[node].size();j++){
					if(adj[node][j].fi==curr){
						if(condition==1) adj[node][j].se=0;
						else adj[node][j].se=1;
					}
				}

			}
		}
	}
	return true;
}

int main(){
	cin>>n>>m;
	vector< pii > edges;
	adj.assign(n,vector<pii>());
	vis.assign(n,false);
	lev.assign(n,0);
	for(int i=0;i<m;i++){
		int u,v;
		cin>>u>>v;
		u--;v--;
		addedge(u,v);
		edges.pb(mp(u,v));
	}
	if(bfs(0)){

		cout<<"YES\n";
		for(int i=0;i<edges.size();i++){
			int u=edges[i].fi,v=edges[i].se;
			for(int j=0;j<adj[u].size();j++){
				if(adj[u][j].fi==v){
					cout<<adj[u][j].se;
					break;
				}
			}
		}

		/*
		for(int i=0;i<n;i++){
		    cout<<i<<" : \n";
		    for(int j=0;j<adj[i].size();j++){
		        cout<<adj[i][j].fi<<" "<<adj[i][j].se<<"\n";
		    }
		    cout<<endl;
		}
		*/
		//cout<<"\nends\n";
	}
	else cout<<"NO";

}


#include <bits/stdc++.h>
//#define int long long int
#define lli long long int
#define endl "\n"
#define loop(i,n) for(int i=0;i<n;i++)
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fileread freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define pb push_back
#define mp make_pair
#define itr iterator
#define fi first
#define se second
#define pii pair<int,int>
#define pci pair<char,int>
#define u_map unordered_map
#define u_set unordered_set
#define u_mmap unordered_multimap
#define u_mset unordered_multiset
# define pi 3.14159265358979323846
using namespace std;

/*
s.push_back() is used to push_back a character whereas += is used to push_back a string;
    str[i] acts as both string as well as character
    if you want to iterate a string without knowing the size of the string, use '\0' in for loop
    for(int i = 0; str[i] != '\0'; i++)

--------------------------------------------------------------------------------------------------------
    vector<int> v;
    v.assign(n,-2);

    -> way to assign size of vector and fill it the entire vector with num of choice

--------------------------------------------------------------------------------------------------------

    STRING FIND: returns the index of 1st occurence of char or string passed to a string str;
    the optional second argument(0 by default) specifies the initial position from where the string
    search is to begin

    string str="geeks are here!";
    int found =str.find('x');
	if(found!=string::npos) cout<<found;
	else cout<<"not found";

	string::npos has an int value of -1;

--------------------------------------------------------------------------------------------------------

    For LCM:
    int LCM(int a, int b)
    {
        return (b*a)/GCD(a,b);
    }

--------------------------------------------------------------------------------------------------------

    In math problems, if you want to find maximum value in an array of integers,
    initialize "maxx" to -INT_MAX & not to 0 (incase all intergers are negative 0 is not maximum)

--------------------------------------------------------------------------------------------------------

    character arithmetic :
            'a'-'a' = 0
            'b'-'a' = 1
    USE : when you want to store count of characters in specific position in a vector or array,
    EX : store 'a' at 0, store 'b' at 1...

    given : string str= "welcome to codeforces";
            int arr[26];
            for(int i=0;i<26;i++){
                arr[str[i]-'a']++;
            }
    NO NEED TO CONVERT CHAR TO INT

--------------------------------------------------------------------------------------------------------
*/

int n,m;
vector< vector < pii > > adj;
vector<bool> vis;
vector<int> lev;

void addedge(int u, int v){
    adj[u].pb(mp(v,-1));
    adj[v].pb(mp(u,-1));
}

bool bfs(int src){
    queue<int> q;
    q.push(src);
    vis[src]=true;
    lev[src]=1;
    int fl=0;
    while(!q.empty()){
        int curr=q.front();
        q.pop();
        int level=lev[curr];
        for(int i=0;i<adj[curr].size();i++){
            int node=adj[curr][i].fi;
            if(!vis[node]){
                adj[curr][i].se=fl;

                for(int j=0;j<adj[node].size();j++){
                    if(adj[node][j].fi==curr){
                        if(fl==1) adj[node][j].se=0;
                        else adj[node][j].se=1;
                    }
                }

                q.push(node);
                vis[node]=true;
                lev[node]=level+1;
            }
            else{
                if(lev[node]==level) return false;
            }
        }
        if(fl==0) fl=1;
        else fl=0;
    }
    return true;
}

/*
void printgraph(){
    for(int i=0;i<n;i++){
        cout<<i<<" -> ";
        for(int j=0;j<adj[i].size();j++) cout<<adj[i][j].fi<<" ";
        cout<<endl;
    }
}

*/

signed main() {
	/*
	----------
	----------
	----------
	----------
	----------
	----------
	----------
	----------
	----------
	----------
	----------
	----------
	----------
	----------
    */

    cin>>n>>m;
    vector< pii > edges;
    adj.assign(n,vector< pii >());
    vis.assign(n,false);
    lev.assign(n,0);

    for(int i=0;i<m;i++){
        int u,v;
        cin>>u>>v;
        u--;v--;
        addedge(u,v);
        edges.pb(mp(u,v));
    }
    //printgraph();
    if(bfs(0)){
        /*
        for(int i=0;i<n;i++){
            cout<<i<<" : ";
            for(int j=0;j<adj[i].size();j++) cout<<adj[i][j].fi<<" "<<adj[i][j].se<<"\n";
            cout<<"\n";
        }
        */
        //cout<<"\nwin\n";

        cout<<"YES\n";
        for(int i=0;i<edges.size();i++){
            int u=edges[i].fi,v=edges[i].se;
            cout<<adj[u][v].se;
        }

    }
    else{
        cout<<"NO";
    }

}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define pii pair<int,int>

int m,n;
vector< vector< pii > > adj;
vector<bool> vis;
 vector<int> lev;

void addedge(int u,int v){
	adj[u].pb(mp(v,-1));
	adj[v].pb(mp(u,-1));
}

bool bfs(int src){
	queue<int> q;
	q.push(src);
	vis[src]=true;
	lev[src]=0;
	while(!q.empty()){
		int curr=q.front();
		q.pop();
		int level=lev[curr];
		for(int i=0;i<adj[curr].size();i++){
			int node=adj[curr][i].fi;
			if(!vis[node]){
				q.push(node);
				vis[node]=true;
				lev[node]=level+1;
				int condition=lev[node]%2;
				adj[curr][i].se=condition;
				for(int j=0;j<adj[node].size();j++){
					if(adj[node][j].fi==curr){
						if(condition==1) adj[node][j].se=0;
						else adj[node][j].se=1;
					}
				}
			}
			else{
				if(lev[node]==level) return false;
			}
		}
	}
	return true;
}

int main(){
	cin>>n>>m;
	vector< pii > edges;
	adj.assign(n,vector<pii>());
	vis.assign(n,false);
	lev.assign(n,0);
	for(int i=0;i<m;i++){
		int u,v;
		cin>>u>>v;
		u--;v--;
		addedge(u,v);
		edges.pb(mp(u,v));
	}
	if(bfs(0)){
		cout<<"YES\n";
		for(int i=0;i<edges.size();i++){
			int u=edges[i].fi,v=edges[i].se;
			for(int j=0;j<adj[u].size();j++){
				if(adj[u][j].fi==v){
					if(adj[u][j].se==-1){
						cout<<0;
					}
					else cout<<adj[u][j].se;
					break;
				}
			}
		}
	}
	else cout<<"NO";
}


#include <iostream>
#include <vector>
#include <list>
#include <map>

int main() {
    int32_t n, m, check_vertix_map_full, current_vertix, run_status;
    std::list<std::pair<int32_t, int32_t>> input_edges;
    std::map<int32_t, int32_t> map_vertix, map_colour;
    std::map<std::pair<int32_t, int32_t>, int32_t> map_edge;
    std::vector<int32_t> run_vertix_vector;

    std::cin >> n >> m;

    for (int32_t i = 1; i < n + 1; i++) {
        map_vertix[i] = 0;
    }
    for (int32_t i = 1; i < m + 1; i++) {
        int32_t src, dst;
        std::cin >> src >> dst;
        input_edges.push_back(std::make_pair(src, dst));
    }

    current_vertix = 1;
    run_status = 0;
    map_vertix[1] = 1;
    map_colour[1] = 1;

    while (run_status != n) {
        for (auto& edge : input_edges) {
            if (edge.first == current_vertix && map_vertix[edge.second] == 0) {
                run_vertix_vector.push_back(edge.second);
                map_vertix[edge.second] = 1;
                map_colour[edge.second] = (1 + map_colour[current_vertix]) % 2;
            }
            if (edge.second == current_vertix && map_vertix[edge.first] == 0) {
                run_vertix_vector.push_back(edge.first);
                map_vertix[edge.first] = 1;
                map_colour[edge.first] = (1 + map_colour[current_vertix]) % 2;
            }
        }
        run_status = run_status + 1;
        if (run_status != n) {
            current_vertix = run_vertix_vector[run_status];
        }
    }

    // for (auto& index : map_colour) {
    //     std::cout << index.first << " " << index.second << std::endl;
    // }

    for (auto& index : input_edges) {
        if (map_colour[index.first] == 1) {
            std::cout << 1;
        } else {
            std::cout << 0;
        }
    }
   return 0;
}


#include <iostream>
#include <vector>
#include <list>
#include <map>

int main() {
    int32_t n, m, check_vertix_map_full, current_vertix, run_status, bad_status = 0;
    std::list<std::pair<int32_t, int32_t>> input_edges;
    std::map<int32_t, int32_t> map_vertix, map_colour;
    std::map<std::pair<int32_t, int32_t>, int32_t> map_edge;
    std::vector<int32_t> run_vertix_vector;

    std::cin >> n >> m;

    for (int32_t i = 1; i < n + 1; i++) {
        map_vertix[i] = 0;
    }
    for (int32_t i = 1; i < m + 1; i++) {
        int32_t src, dst;
        std::cin >> src >> dst;
        input_edges.push_back(std::make_pair(src, dst));
    }

    current_vertix = 1;
    run_status = 0;
    map_vertix[1] = 1;
    map_colour[1] = 1;
    run_vertix_vector.push_back(1);

    while (run_status != n) {
        for (auto& edge : input_edges) {
            if (edge.first == current_vertix && map_vertix[edge.second] == 0) {
                run_vertix_vector.push_back(edge.second);
                map_vertix[edge.second] = 1;
                map_colour[edge.second] = (1 + map_colour[current_vertix]) % 2;
            }
            if (edge.second == current_vertix && map_vertix[edge.first] == 0) {
                run_vertix_vector.push_back(edge.first);
                map_vertix[edge.first] = 1;
                map_colour[edge.first] = (1 + map_colour[current_vertix]) % 2;
            }
        }
        run_status = run_status + 1;

        if (run_status != n) {
            current_vertix = run_vertix_vector[run_status];
        }
    }

    // for (auto& index : map_colour) {
    //     std::cout << index.first << " " << index.second << std::endl;
    // }

    std::cout << "Yes" << std::endl;

    for (auto& index : input_edges) {
        if (map_colour[index.first] == 1) {
            std::cout << 1;
        } else {
            std::cout << 0;
        }
    }
   return 0;
}


#include <iostream>
#include <vector>
#include <list>
#include <map>

int main() {
    int32_t n, m, check_vertix_map_full, current_vertix, run_status, bad_status = 0;
    std::list<std::pair<int32_t, int32_t>> input_edges;
    std::map<int32_t, int32_t> map_vertix, map_colour;
    std::map<std::pair<int32_t, int32_t>, int32_t> map_edge;
    std::vector<int32_t> run_vertix_vector;
    std::map<int32_t, std::vector<int32_t>> vertix_neighbors;

    std::cin >> n >> m;

    for (int32_t i = 1; i < n + 1; i++) {
        map_vertix[i] = 0;
    }
    for (int32_t i = 1; i < m + 1; i++) {
        int32_t src, dst;
        std::cin >> src >> dst;
        input_edges.push_back(std::make_pair(src, dst));
        vertix_neighbors[src] = std::vector<int32_t>();
    }

    for (auto& edge : input_edges) {
        vertix_neighbors[edge.first].push_back(edge.second);
        vertix_neighbors[edge.second].push_back(edge.first);
    }

    // for (auto& edge : vertix_neighbors) {
    //     std::cout << edge.first << " ";
    //     for (int32_t i = 0; i < edge.second.size(); i++) {
    //         std::cout << edge.second[i];
    //     }
    //     std::cout << std::endl;
    // }

    current_vertix = 1;
    run_status = 0;
    map_vertix[1] = 1;
    map_colour[1] = 1;
    run_vertix_vector.push_back(1);

    for (int32_t i = 1; i < n + 1; i++) {
        current_vertix = run_vertix_vector[i - 1];
        for (int32_t j = 0; j < vertix_neighbors[i].size(); j++) {
            if (map_vertix[vertix_neighbors[current_vertix][j]] == 0) {
                run_vertix_vector.push_back(vertix_neighbors[i][j]);
                map_vertix[vertix_neighbors[current_vertix][j]] = 1;
                map_colour[vertix_neighbors[current_vertix][j]] = (1 + map_colour[current_vertix]) % 2;
            }
        }
    }

    // while (run_status != n) {
    //     for (auto& edge : vertix_neighbors) {

    //         if (edge.first == current_vertix && map_vertix[edge.second] == 0) {
    //             run_vertix_vector.push_back(edge.second);
    //             map_vertix[edge.second] = 1;
    //             map_colour[edge.second] = (1 + map_colour[current_vertix]) % 2;
    //         }
    //         if (edge.second == current_vertix && map_vertix[edge.first] == 0) {
    //             run_vertix_vector.push_back(edge.first);
    //             map_vertix[edge.first] = 1;
    //             map_colour[edge.first] = (1 + map_colour[current_vertix]) % 2;
    //         }
    //     }
    //     run_status = run_status + 1;

    //     if (run_status != n) {
    //         current_vertix = run_vertix_vector[run_status];
    //     }

    // }

    // for (auto& index : map_colour) {
    //     std::cout << index.first << " " << index.second << std::endl;
    // }

    for (auto& index : input_edges) {
        if (map_colour[index.first] == map_colour[index.second]) {
            bad_status = 1;
        }
    }

    if (bad_status == 1) {
        std::cout << "No";
    } else {
        std::cout << "Yes" << std::endl;

        for (auto& index : input_edges) {
            if (map_colour[index.first] == 1) {
                std::cout << 1;
            } else {
                std::cout << 0;
            }
        }
    }
   return 0;
}


#include <iostream>
#include <vector>
#include <list>
#include <map>

int main() {
    int32_t n, m, check_vertix_map_full, current_vertix, run_status, bad_status = 0;
    std::list<std::pair<int32_t, int32_t>> input_edges;
    std::map<int32_t, int32_t> map_vertix, map_colour;
    std::map<std::pair<int32_t, int32_t>, int32_t> map_edge;
    std::vector<int32_t> run_vertix_vector;
    std::map<int32_t, std::vector<int32_t>> vertix_neighbors;

    std::cin >> n >> m;

    for (int32_t i = 1; i < n + 1; i++) {
        map_vertix[i] = 0;
    }
    for (int32_t i = 1; i < m + 1; i++) {
        int32_t src, dst;
        std::cin >> src >> dst;
        input_edges.push_back(std::make_pair(src, dst));
        vertix_neighbors[src] = std::vector<int32_t>();
    }

    for (auto& edge : input_edges) {
        vertix_neighbors[edge.first].push_back(edge.second);
        vertix_neighbors[edge.second].push_back(edge.first);
    }

    // for (auto& edge : vertix_neighbors) {
    //     std::cout << edge.first << " ";
    //     for (int32_t i = 0; i < edge.second.size(); i++) {
    //         std::cout << edge.second[i];
    //     }
    //     std::cout << std::endl;
    // }

    current_vertix = 1;
    run_status = 0;
    map_vertix[1] = 1;
    map_colour[1] = 1;
    run_vertix_vector.push_back(1);

    for (int32_t i = 1; i < n + 1; i++) {
        for (int32_t j = 0; j < vertix_neighbors[i].size(); j++) {
            if (map_vertix[vertix_neighbors[i][j]] == 0) {
                run_vertix_vector.push_back(vertix_neighbors[i][j]);
                map_vertix[vertix_neighbors[i][j]] = 1;
                map_colour[vertix_neighbors[i][j]] = (1 + map_colour[i]) % 2;
            }
        }
    }

    // while (run_status != n) {
    //     for (auto& edge : vertix_neighbors) {

    //         if (edge.first == current_vertix && map_vertix[edge.second] == 0) {
    //             run_vertix_vector.push_back(edge.second);
    //             map_vertix[edge.second] = 1;
    //             map_colour[edge.second] = (1 + map_colour[current_vertix]) % 2;
    //         }
    //         if (edge.second == current_vertix && map_vertix[edge.first] == 0) {
    //             run_vertix_vector.push_back(edge.first);
    //             map_vertix[edge.first] = 1;
    //             map_colour[edge.first] = (1 + map_colour[current_vertix]) % 2;
    //         }
    //     }
    //     run_status = run_status + 1;

    //     if (run_status != n) {
    //         current_vertix = run_vertix_vector[run_status];
    //     }

    // }

    // for (auto& index : map_colour) {
    //     std::cout << index.first << " " << index.second << std::endl;
    // }

    for (auto& index : input_edges) {
        if (map_colour[index.first] == map_colour[index.second]) {
            bad_status = 1;
        }
    }

    if (bad_status == 1) {
        std::cout << "No";
    } else {
        std::cout << "Yes" << std::endl;

        for (auto& index : input_edges) {
            if (map_colour[index.first] == 1) {
                std::cout << 1;
            } else {
                std::cout << 0;
            }
        }
    }
   return 0;
}


#include <iostream>
#include <vector>
#include <list>
#include <map>

int main() {
    int32_t n, m, check_vertix_map_full, current_vertix, run_status;
    std::list<std::pair<int32_t, int32_t>> input_edges;
    std::map<int32_t, int32_t> map_vertix, map_colour;
    std::map<std::pair<int32_t, int32_t>, int32_t> map_edge;
    std::vector<int32_t> run_vertix_vector;

    std::cin >> n >> m;

    for (int32_t i = 1; i < n + 1; i++) {
        map_vertix[i] = 0;
    }
    for (int32_t i = 1; i < m + 1; i++) {
        int32_t src, dst;
        std::cin >> src >> dst;
        input_edges.push_back(std::make_pair(src, dst));
    }

    current_vertix = 1;
    run_status = 0;
    map_vertix[1] = 1;
    map_colour[1] = 1;

    while (run_status != n) {
        for (auto& edge : input_edges) {
            if (edge.first == current_vertix && map_vertix[edge.second] == 0) {
                run_vertix_vector.push_back(edge.second);
                map_vertix[edge.second] = 1;
                map_colour[edge.second] = (1 + map_colour[current_vertix]) % 2;
            }
            if (edge.second == current_vertix && map_vertix[edge.first] == 0) {
                run_vertix_vector.push_back(edge.first);
                map_vertix[edge.first] = 1;
                map_colour[edge.first] = (1 + map_colour[current_vertix]) % 2;
            }
        }
        run_status = run_status + 1;
        current_vertix = run_vertix_vector[run_status];
    }

    // for (auto& index : map_colour) {
    //     std::cout << index.first << " " << index.second << std::endl;
    // }

    for (auto& index : input_edges) {
        if (map_colour[index.first] == 1) {
            std::cout << 1;
        } else {
            std::cout << 0;
        }
    }
   return 0;
}


#include <iostream>
#include <vector>
#include <list>
#include <map>

int main() {
    int32_t n, m, check_vertix_map_full, current_vertix, run_status;
    std::list<std::pair<int32_t, int32_t>> input_edges;
    std::map<int32_t, int32_t> map_vertix, map_colour;
    std::map<std::pair<int32_t, int32_t>, int32_t> map_edge;
    std::vector<int32_t> run_vertix_vector;

    std::cin >> n >> m;

    for (int32_t i = 1; i < n + 1; i++) {
        map_vertix[i] = 0;
    }
    for (int32_t i = 1; i < m + 1; i++) {
        int32_t src, dst;
        std::cin >> src >> dst;
        input_edges.push_back(std::make_pair(src, dst));
    }

    current_vertix = 1;
    run_status = 0;
    map_vertix[1] = 1;
    map_colour[1] = 1;

    while (run_status != n) {
        for (auto& edge : input_edges) {
            if (edge.first == current_vertix && map_vertix[edge.second] == 0) {
                run_vertix_vector.push_back(edge.second);
                map_vertix[edge.second] = 1;
                map_colour[edge.second] = (1 + map_colour[current_vertix]) % 2;
            }
            if (edge.second == current_vertix && map_vertix[edge.first] == 0) {
                run_vertix_vector.push_back(edge.first);
                map_vertix[edge.first] = 1;
                map_colour[edge.first] = (1 + map_colour[current_vertix]) % 2;
            }
        }
        run_status = run_status + 1;
        if (run_status != n) {
            current_vertix = run_vertix_vector[run_status];
        }
    }

    // for (auto& index : map_colour) {
    //     std::cout << index.first << " " << index.second << std::endl;
    // }

    std::cout << "Yes" << std::endl;

    for (auto& index : input_edges) {
        if (map_colour[index.first] == 1) {
            std::cout << 1;
        } else {
            std::cout << 0;
        }
    }
   return 0;
}


#include <iostream>
#include <vector>
#include <list>
#include <map>

int main() {
    int32_t n, m, check_vertix_map_full, current_vertix, run_status, bad_status = 0;
    std::list<std::pair<int32_t, int32_t>> input_edges;
    std::map<int32_t, int32_t> map_vertix, map_colour;
    std::map<std::pair<int32_t, int32_t>, int32_t> map_edge;
    std::vector<int32_t> run_vertix_vector;
    std::map<int32_t, std::vector<int32_t>> vertix_neighbors;

    std::cin >> n >> m;

    for (int32_t i = 1; i < n + 1; i++) {
        map_vertix[i] = 0;
    }
    for (int32_t i = 1; i < m + 1; i++) {
        int32_t src, dst;
        std::cin >> src >> dst;
        input_edges.push_back(std::make_pair(src, dst));
        vertix_neighbors[src] = std::vector<int32_t>();
    }

    for (auto& edge : input_edges) {
        vertix_neighbors[edge.first].push_back(edge.second);
        vertix_neighbors[edge.second].push_back(edge.first);
    }

    // for (auto& edge : vertix_neighbors) {
    //     std::cout << edge.first << " ";
    //     for (int32_t i = 0; i < edge.second.size(); i++) {
    //         std::cout << edge.second[i];
    //     }
    //     std::cout << std::endl;
    // }

    current_vertix = 1;
    run_status = 0;
    map_vertix[1] = 1;
    map_colour[1] = 1;
    run_vertix_vector.push_back(1);

    for (int32_t i = 1; i < n + 1; i++) {
        current_vertix = run_vertix_vector[i - 1];
        for (int32_t j = 0; j < vertix_neighbors[current_vertix].size(); j++) {
            if (map_vertix[vertix_neighbors[current_vertix][j]] == 0) {
                run_vertix_vector.push_back(vertix_neighbors[current_vertix][j]);
                map_vertix[vertix_neighbors[current_vertix][j]] = 1;
                map_colour[vertix_neighbors[current_vertix][j]] = (1 + map_colour[current_vertix]) % 2;
            }
        }
    }

    // while (run_status != n) {
    //     for (auto& edge : vertix_neighbors) {

    //         if (edge.first == current_vertix && map_vertix[edge.second] == 0) {
    //             run_vertix_vector.push_back(edge.second);
    //             map_vertix[edge.second] = 1;
    //             map_colour[edge.second] = (1 + map_colour[current_vertix]) % 2;
    //         }
    //         if (edge.second == current_vertix && map_vertix[edge.first] == 0) {
    //             run_vertix_vector.push_back(edge.first);
    //             map_vertix[edge.first] = 1;
    //             map_colour[edge.first] = (1 + map_colour[current_vertix]) % 2;
    //         }
    //     }
    //     run_status = run_status + 1;

    //     if (run_status != n) {
    //         current_vertix = run_vertix_vector[run_status];
    //     }

    // }

    // for (auto& index : map_colour) {
    //     std::cout << index.first << " " << index.second << std::endl;
    // }

    for (auto& index : input_edges) {
        if (map_colour[index.first] == map_colour[index.second]) {
            bad_status = 1;
        }
    }

    if (bad_status == 1) {
        std::cout << "No";
    } else {
        std::cout << "Yes" << std::endl;

        for (auto& index : input_edges) {
            if (map_colour[index.first] == 1) {
                std::cout << 1;
            } else {
                std::cout << 0;
            }
        }
    }
   return 0;
}


#include <iostream>
#include <vector>
#include <list>
#include <map>

int main() {
    int32_t n, m, check_vertix_map_full, current_vertix, run_status, bad_status = 0;
    std::list<std::pair<int32_t, int32_t>> input_edges;
    std::map<int32_t, int32_t> map_vertix, map_colour;
    std::map<std::pair<int32_t, int32_t>, int32_t> map_edge;
    std::vector<int32_t> run_vertix_vector;
    std::map<int32_t, std::vector<int32_t>> vertix_neighbors;

    std::cin >> n >> m;

    for (int32_t i = 1; i < n + 1; i++) {
        map_vertix[i] = 0;
    }
    for (int32_t i = 1; i < m + 1; i++) {
        int32_t src, dst;
        std::cin >> src >> dst;
        input_edges.push_back(std::make_pair(src, dst));
        vertix_neighbors[src] = std::vector<int32_t>();
    }

    for (auto& edge : input_edges) {
        vertix_neighbors[edge.first].push_back(edge.second);
        vertix_neighbors[edge.second].push_back(edge.first);
    }

    // for (auto& edge : vertix_neighbors) {
    //     std::cout << edge.first << " ";
    //     for (int32_t i = 0; i < edge.second.size(); i++) {
    //         std::cout << edge.second[i];
    //     }
    //     std::cout << std::endl;
    // }

    current_vertix = 1;
    run_status = 0;
    map_vertix[1] = 1;
    map_colour[1] = 1;
    run_vertix_vector.push_back(1);

    for (int32_t i = 1; i < n + 1; i++) {
        current_vertix = run_vertix_vector[i - 1];
        for (int32_t j = 0; j < vertix_neighbors[i].size(); j++) {
            if (map_vertix[vertix_neighbors[i][j]] == 0) {
                run_vertix_vector.push_back(vertix_neighbors[i][j]);
                map_vertix[vertix_neighbors[i][j]] = 1;
                map_colour[vertix_neighbors[i][j]] = (1 + map_colour[i]) % 2;
            }
        }
    }

    // while (run_status != n) {
    //     for (auto& edge : vertix_neighbors) {

    //         if (edge.first == current_vertix && map_vertix[edge.second] == 0) {
    //             run_vertix_vector.push_back(edge.second);
    //             map_vertix[edge.second] = 1;
    //             map_colour[edge.second] = (1 + map_colour[current_vertix]) % 2;
    //         }
    //         if (edge.second == current_vertix && map_vertix[edge.first] == 0) {
    //             run_vertix_vector.push_back(edge.first);
    //             map_vertix[edge.first] = 1;
    //             map_colour[edge.first] = (1 + map_colour[current_vertix]) % 2;
    //         }
    //     }
    //     run_status = run_status + 1;

    //     if (run_status != n) {
    //         current_vertix = run_vertix_vector[run_status];
    //     }

    // }

    // for (auto& index : map_colour) {
    //     std::cout << index.first << " " << index.second << std::endl;
    // }

    for (auto& index : input_edges) {
        if (map_colour[index.first] == map_colour[index.second]) {
            bad_status = 1;
        }
    }

    if (bad_status == 1) {
        std::cout << "No";
    } else {
        std::cout << "Yes" << std::endl;

        for (auto& index : input_edges) {
            if (map_colour[index.first] == 1) {
                std::cout << 1;
            } else {
                std::cout << 0;
            }
        }
    }
   return 0;
}


#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
using namespace __gnu_pbds;
 	// find_by_order()  // order_of_key
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fi(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inff (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define flush fflush(stdout)
#define primeDEN 727999983
#define SPEED ios_base::sync_with_stdio(false) ;cin.tie(NULL) ;cout.tie(NULL) ;
#define fp(i,a,n) for(ll i=n-1; i>a ;i--)
#define deb(x) cout << #x << " ---> " << x << endl;
#define X first
#define Y second
#define pia 3.1415926536
#define mod 1000000007
#define mod2 998244353

#define ml map<ll,ll>
#define mll map<pll,ll>
#define vvl vector<vl>
#define vvi vector<vi>
#define letsh(a,b) a<<b
vector<int>vec[200010];
#define ll long long
unordered_map<int,int>mp;
bool flag;
vector<bool>vis(200020);
void dfs(int curr,int val,int par){
    if(!mp[curr])
    mp[curr]=val;
    vis[curr]=1;
    for(auto i:vec[curr]){
        if(i!= par){
                if(vis[i]){
                    if(abs(mp[i]-val)%2==0){
                        flag=1;
                    }
                }
                if(!vis[i]){
                vis[i]=1;
            dfs(i,val+1,curr);
                }
        }
    }
}
int main()
{
   int n,m;
   cin>>n>>m;
   int arr[n][2];
   for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    arr[i][0]=a;
    arr[i][1]=b;
    vec[a].push_back(b);
    vec[b].push_back(a);
   }

   mp[1]=1;
   dfs(1,1,-1);
   if(flag){
    cout<<"NO\n";
    return 0;
   }
   cout<<"YES\n";
   for(int i=0;i<m;i++){
    if(mp[arr[i][1]]&1){
        cout<<0;
    }
    else
        cout<<1;
   }
}


#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
using namespace __gnu_pbds;
 	// find_by_order()  // order_of_key
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fi(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inff (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define flush fflush(stdout)
#define primeDEN 727999983
#define SPEED ios_base::sync_with_stdio(false) ;cin.tie(NULL) ;cout.tie(NULL) ;
#define fp(i,a,n) for(ll i=n-1; i>a ;i--)
#define deb(x) cout << #x << " ---> " << x << endl;
#define X first
#define Y second
#define pia 3.1415926536
#define mod 1000000007
#define mod2 998244353

#define ml map<ll,ll>
#define mll map<pll,ll>
#define vvl vector<vl>
#define vvi vector<vi>
#define letsh(a,b) a<<b
vector<int>vec[200010];
#define ll long long
unordered_map<int,int>mp;
bool flag;
vector<bool>vis(200020);
void dfs(int curr,int val){
                if(vis[curr] && mp[curr] != val){
                    flag=1;
                }
                if(vis[curr])return;
                vis[curr]=1;
                mp[curr]=val;
                val=!val;
                for(int a:vec[curr]){
                    dfs(a,val);
                }
    }
int main()
{
   int n,m;
   cin>>n>>m;
   int arr[n][2];
   for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    arr[i][0]=a;
    arr[i][1]=b;
    vec[a].push_back(b);
    vec[b].push_back(a);
   }
   dfs(1,0);
   if(flag){
    cout<<"NO\n";
    return 0;
   }
   cout<<"YES\n";
   for(int i=0;i<m;i++){
    if(mp[arr[i][1]]&1){
        cout<<0;
    }
    else
        cout<<1;
   }
}


#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
using namespace __gnu_pbds;
 	// find_by_order()  // order_of_key
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fi(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inff (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define flush fflush(stdout)
#define primeDEN 727999983
#define SPEED ios_base::sync_with_stdio(false) ;cin.tie(NULL) ;cout.tie(NULL) ;
#define fp(i,a,n) for(ll i=n-1; i>a ;i--)
#define deb(x) cout << #x << " ---> " << x << endl;
#define X first
#define Y second
#define pia 3.1415926536
#define mod 1000000007
#define mod2 998244353

#define ml map<ll,ll>
#define mll map<pll,ll>
#define vvl vector<vl>
#define vvi vector<vi>
#define letsh(a,b) a<<b
vector<int>vec[200010];
#define ll long long
unordered_map<int,int>mp;
bool flag;
vector<bool>vis(200020);
void dfs(int curr,int val,int par){
    if(!mp[curr])
    mp[curr]=val;
    vis[curr]=1;
    for(auto i:vec[curr]){
        if(i!= par){
                if(vis[i]){
                    if(abs(mp[i]-val)%2==0){
                        flag=1;
                    }
                }
                if(!vis[i]){
                vis[i]=1;
            dfs(i,val+1,curr);
                }
        }
    }
}
int main()
{
   int n,m;
   cin>>n>>m;
   int arr[m][2];
   for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    arr[i][0]=a;
    arr[i][1]=b;
    vec[a].push_back(b);
    vec[b].push_back(a);
   }

   mp[1]=1;
   dfs(1,1,-1);
   if(flag){
    cout<<"NO\n";
    return 0;
   }
   cout<<"YES\n";
   for(int i=0;i<m;i++){
    if(mp[arr[i][1]]&1){
        cout<<0;
    }
    else
        cout<<1;
   }
}


#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
using namespace __gnu_pbds;
 	// find_by_order()  // order_of_key
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fi(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inff (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define flush fflush(stdout)
#define primeDEN 727999983
#define SPEED ios_base::sync_with_stdio(false) ;cin.tie(NULL) ;cout.tie(NULL) ;
#define fp(i,a,n) for(ll i=n-1; i>a ;i--)
#define deb(x) cout << #x << " ---> " << x << endl;
#define X first
#define Y second
#define pia 3.1415926536
#define mod 1000000007
#define mod2 998244353

#define ml map<ll,ll>
#define mll map<pll,ll>
#define vvl vector<vl>
#define vvi vector<vi>
#define letsh(a,b) a<<b
vector<int>vec[200010];
#define ll long long
unordered_map<int,int>mp;
bool flag;
vector<bool>vis(200020);
void dfs(int curr,int val,int par){
    if(!mp[curr])
    mp[curr]=val;
    vis[curr]=1;
    for(auto i:vec[curr]){
        if(i!= par){
                if(vis[i]){
                    if(abs(mp[i]-val)%2==val%2){
                        flag=1;
                    }
                }
                if(!vis[i]){
                vis[i]=1;
            dfs(i,val+1,curr);
                }
        }
    }
}
int main()
{
   int n,m;
   cin>>n>>m;
   int arr[n][2];
   for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    arr[i][0]=a;
    arr[i][1]=b;
    vec[a].push_back(b);
    vec[b].push_back(a);
   }

   mp[1]=1;
   dfs(1,1,-1);
   if(flag){
    cout<<"NO\n";
    return 0;
   }
   cout<<"YES\n";
   for(int i=0;i<m;i++){
    if(mp[arr[i][1]]&1){
        cout<<0;
    }
    else
        cout<<1;
   }
}


#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
using namespace __gnu_pbds;
 	// find_by_order()  // order_of_key
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fi(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inff (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define flush fflush(stdout)
#define primeDEN 727999983
#define SPEED ios_base::sync_with_stdio(false) ;cin.tie(NULL) ;cout.tie(NULL) ;
#define fp(i,a,n) for(ll i=n-1; i>a ;i--)
#define deb(x) cout << #x << " ---> " << x << endl;
#define X first
#define Y second
#define pia 3.1415926536
#define mod 1000000007
#define mod2 998244353

#define ml map<ll,ll>
#define mll map<pll,ll>
#define vvl vector<vl>
#define vvi vector<vi>
#define letsh(a,b) a<<b
vector<int>vec[200010];
#define ll long long
bool flag;
vector<bool>vis(200020);
vector<int>mp(200020);
void dfs(int curr,int val){
                if(vis[curr] && mp[curr] != val){
                    flag=1;
                }
                if(vis[curr])return;
                vis[curr]=1;
                mp[curr]=val;
                val=val^1;
                for(int a:vec[curr]){
                    dfs(a,val);
                }
    }
int main()
{
   int n,m;
   cin>>n>>m;
   int arr[m][2];
   for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    arr[i][0]=a;
    arr[i][1]=b;
    vec[a].push_back(b);
    vec[b].push_back(a);
   }
   dfs(1,0);
   if(flag){
    cout<<"NO\n";
    return 0;
   }
   cout<<"YES\n";
   for(int i=0;i<m;i++){
    if(mp[arr[i][1]]&1){
        cout<<0;
    }
    else
        cout<<1;
   }
}


#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
using namespace __gnu_pbds;
 	// find_by_order()  // order_of_key
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fi(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inff (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define flush fflush(stdout)
#define primeDEN 727999983
#define SPEED ios_base::sync_with_stdio(false) ;cin.tie(NULL) ;cout.tie(NULL) ;
#define fp(i,a,n) for(ll i=n-1; i>a ;i--)
#define deb(x) cout << #x << " ---> " << x << endl;
#define X first
#define Y second
#define pia 3.1415926536
#define mod 1000000007
#define mod2 998244353

#define ml map<ll,ll>
#define mll map<pll,ll>
#define vvl vector<vl>
#define vvi vector<vi>
#define letsh(a,b) a<<b
vector<int>vec[200010];
#define ll long long
unordered_map<int,int>mp;
bool flag;
vector<bool>vis(200020);
void dfs(int curr,int val,int par){
    if(!mp[curr])
    mp[curr]=val;
    for(auto i:vec[curr]){
        if(i!= par){
                if(vis[i]){
                    if(abs(mp[i]-val)%2==0){
                        flag=1;
                    }
                }
                if(!vis[i]){
                vis[i]=1;
            dfs(i,val+1,curr);
                }
        }
    }
}
int main()
{
   int n,m;
   cin>>n>>m;
   int arr[n][2];
   for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    arr[i][0]=a;
    arr[i][1]=b;
    vec[a].push_back(b);
    vec[b].push_back(a);
   }

   mp[1]=1;
   dfs(1,1,-1);
   if(flag){
    cout<<"NO\n";
    return 0;
   }
   cout<<"YES\n";
   for(int i=0;i<m;i++){
    if(mp[arr[i][1]]&1){
        cout<<0;
    }
    else
        cout<<1;
   }
}


#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
using namespace __gnu_pbds;
 	// find_by_order()  // order_of_key
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fi(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inff (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define flush fflush(stdout)
#define primeDEN 727999983
#define SPEED ios_base::sync_with_stdio(false) ;cin.tie(NULL) ;cout.tie(NULL) ;
#define fp(i,a,n) for(ll i=n-1; i>a ;i--)
#define deb(x) cout << #x << " ---> " << x << endl;
#define X first
#define Y second
#define pia 3.1415926536
#define mod 1000000007
#define mod2 998244353

#define ml map<ll,ll>
#define mll map<pll,ll>
#define vvl vector<vl>
#define vvi vector<vi>
#define letsh(a,b) a<<b
vector<int>vec[200010];
#define ll long long
unordered_map<int,int>mp;
bool flag;
vector<bool>vis(200020);
void dfs(int curr,int val,int par){
    if(!mp[curr])
    mp[curr]=val;
    vis[curr]=1;
    for(auto i:vec[curr]){
        if(i!= par){
                if(vis[i]){
                    if(abs(mp[i]-val)%2!=val%2){
                        flag=1;
                    }
                }
                if(!vis[i]){
                vis[i]=1;
            dfs(i,val+1,curr);
                }
        }
    }
}
int main()
{
   int n,m;
   cin>>n>>m;
   int arr[n][2];
   for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    arr[i][0]=a;
    arr[i][1]=b;
    vec[a].push_back(b);
    vec[b].push_back(a);
   }

   mp[1]=1;
   dfs(1,1,-1);
   if(flag){
    cout<<"NO\n";
    return 0;
   }
   cout<<"YES\n";
   for(int i=0;i<m;i++){
    if(mp[arr[i][1]]&1){
        cout<<0;
    }
    else
        cout<<1;
   }
}


#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<unordered_map>
#define x first
#define y second
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
using namespace std;
// #define int long long
vector<vector<int> >g;
vector<pair<int,int> >kek;
vector<int>color;
void dfs(int u,bool naob){
  color[u] = naob;
  for(int i = 0;i < g[u].size();i++){
  	if(color[g[u][i]] == -1){
  	  dfs(g[u][i],naob ^ 1);
  	}
  	if(color[g[u][i]] == color[u]){
  	  puts("NO"),0;
  	}
  }
}
signed main(){
  int n,m;
  cin >> n >> m;
  g.resize(n);
  color.resize(n,-1);
  int gl, hf;
  for(int i = 0;i < m;i++){
    cin >> gl >> hf;
    gl--;
    hf--;
    g[gl].pb(hf);
    g[hf].pb(gl);
    kek.pb(mp(gl,hf));
  }
  puts("YES");
  for(int i = 0;i < kek.size();i++){
    cout << (kek[i].x > kek[i].y);
  }
  return 0;
}


#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<unordered_map>
#define x first
#define y second
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
using namespace std;
// #define int long long
vector<vector<int> >g;
vector<pair<int,int> >kek;
vector<int>color;
void dfs(int u,bool naob){
  color[u] = naob;
  for(int i = 0;i < g[u].size();i++){
  	if(color[g[u][i]] == -1){
  	  dfs(g[u][i],naob ^ 1);
  	}
  	if(color[g[u][i]] == color[u]){
  	  cout << "NO";
  	  exit(0);
  	}
  }
}
signed main(){
  int n,m;
  cin >> n >> m;
  g.resize(n);
  color.resize(n,-1);
  int gl, hf;
  for(int i = 0;i < m;i++){
    cin >> gl >> hf;
    gl--;
    hf--;
    g[gl].pb(hf);
    g[hf].pb(gl);
    kek.pb(mp(gl,hf));
  }
  dfs(0,0);
  puts("YES");
  for(int i = 0;i < kek.size();i++){
    cout << (color[kek[i].x] > color[kek[i].y]);
  }
  return 0;
}


#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<unordered_map>
#define x first
#define y second
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
using namespace std;
// #define int long long
vector<vector<int> >g,gr;
vector<bool>kek;
map<int,pair<int, int> >gg;
map<pair<int, int>, int>wp;
vector<bool>used;
vector<vector<int> >xxx;
vector<pair<int,int> >nw_gr;
int cur = 0;
void dfs(int u,bool naob){
  used[u] = 1;
  for(int i = 0;i < g[u].size();i++){
  	if(!used[g[u][i]]){
      if(naob){
        kek[wp[mp(u,g[u][i])]] = 1;
        nw_gr.pb(mp(g[u][i],u));
      }else{
      	kek[wp[mp(u,g[u][i])]] = 0;
      	nw_gr.pb(mp(u,g[u][i]));
      }
      dfs(g[u][i],naob ^ 1);
  	}
  }
  for(int i = 0;i < gr[u].size();i++){
  	// cout << u << endl;
  	if(!used[gr[u][i]]){
  	  if(naob){
        kek[wp[mp(gr[u][i],u)]] = 0;
        nw_gr.pb(mp(gr[u][i],u));
      }else{
      	kek[wp[mp(gr[u][i],u)]] = 1;
      	nw_gr.pb(mp(u,gr[u][i]));
      }
      dfs(gr[u][i],naob ^ 1);
  	}
  }
}
void dfs2(int u){
  cur++;
  used[u] = 1;
  for(int i = 0;i < xxx[u].size();i++){
  	if(!used[xxx[u][i]]){
  	  dfs2(xxx[u][i]);
  	  break;
  	}
  }
}
signed main(){
  int n,m;
  cin >> n >> m;
  g.resize(n);
  gr.resize(n);
  used.resize(n,false);
  kek.resize(n,false);
  xxx.resize(n);
  int f,t;
  for(int i = 0;i < m;i++){
    cin >> f >> t;
    f--;
    t--;
    g[f].pb(t);
    gr[t].pb(f);
    wp[mp(f,t)] = i;
  }
  dfs(0,0);
  fill(all(used),0);
  for(int i = 0;i < nw_gr.size();i++){
  	// cout << nw_gr[i].x << ' ' << nw_gr[i].y << endl;
    xxx[nw_gr[i].x].pb(nw_gr[i].y);
  }
  for(int i = 0;i < n;i++){
  	if(!used[i]){
  	  cur = 0;
  	  dfs2(i);
  	  if(cur > 2){
  	  	puts("NO");
  	  	return 0;
  	  }
  	}
  }
  puts("YES");
  for(int i = 0;i < m;i++){
    cout << kek[i];
  }
  return 0;
}


#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<unordered_map>
#define x first
#define y second
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
using namespace std;
// #define int long long
vector<vector<int> >g;
vector<pair<int,int> >kek;
vector<int>color;
void dfs(int u,bool naob){
  color[u] = naob;
  for(int i = 0;i < g[u].size();i++){
  	if(color[g[u][i]] == -1){
  	  dfs(g[u][i],naob ^ 1);
  	}
  	if(color[g[u][i]] == color[u]){
  	  puts("NO");
  	  exit(0);
  	  return 0;
  	}
  }
}
signed main(){
  int n,m;
  cin >> n >> m;
  g.resize(n);
  color.resize(n,-1);
  int gl, hf;
  for(int i = 0;i < m;i++){
    cin >> gl >> hf;
    gl--;
    hf--;
    g[gl].pb(hf);
    g[hf].pb(gl);
    kek.pb(mp(gl,hf));
  }
  dfs(0,0);
  puts("YES");
  for(int i = 0;i < kek.size();i++){
    cout << (color[kek[i].x] > color[kek[i].y]);
  }
  return 0;
}


#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<unordered_map>
#define x first
#define y second
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
using namespace std;
// #define int long long
vector<vector<int> >g;
vector<pair<int,int> >kek;
vector<int>color;
void dfs(int u,bool naob){
  color[u] = naob;
  for(int i = 0;i < g[u].size();i++){
  	if(color[g[u][i]] == -1){
  	  dfs(g[u][i],naob ^ 1);
  	}
  	if(color[g[u][i]] == color[u]){
  	  puts("NO"),0;
  	}
  }
}
signed main(){
  int n,m;
  cin >> n >> m;
  g.resize(n);
  color.resize(n,-1);
  int gl, hf;
  for(int i = 0;i < m;i++){
    cin >> gl >> hf;
    gl--;
    hf--;
    g[gl].pb(hf);
    g[hf].pb(gl);
    kek.pb(mp(gl,hf));
  }
  dfs(0,0);
  puts("YES");
  for(int i = 0;i < kek.size();i++){
    cout << (color[kek[i].x] > color[kek[i].y]);
  }
  return 0;
}


#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<unordered_map>
#define x first
#define y second
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
using namespace std;
// #define int long long
vector<vector<int> >g;
vector<pair<int,int> >kek;
vector<int>color;
void dfs(int u,bool naob){
  color[u] = naob;
  for(int i = 0;i < g[u].size();i++){
  	if(color[g[u][i]] == -1){
  	  dfs(g[u][i],naob ^ 1);
  	}
  	if(color[g[u][i]] == color[u]){
  	  puts("NO"),0;
  	}
  }
}
signed main(){
  int n,m;
  cin >> n >> m;
  g.resize(n);
  color.resize(n,-1);
  int gl, hf;
  for(int i = 0;i < m;i++){
    cin >> gl >> hf;
    gl--;
    hf--;
    g[gl].pb(hf);
    g[hf].pb(gl);
    kek.pb(mp(gl,hf));
  }
  dfs(0,0);
  puts("YES");
  for(int i = 0;i < kek.size();i++){
    cout << (kek[i].x > kek[i].y);
  }
  return 0;
}


#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<unordered_map>
#define x first
#define y second
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
using namespace std;
// #define int long long
vector<vector<int> >g,gr;
vector<bool>kek;
map<int,pair<int, int> >gg;
map<pair<int, int>, int>wp;
vector<bool>used;
vector<vector<int> >xxx;
vector<pair<int,int> >nw_gr;
int cur = 0;
void dfs(int u,bool naob){
  used[u] = 1;
  for(int i = 0;i < g[u].size();i++){
  	if(!used[g[u][i]]){
      if(naob){
        kek[wp[mp(u,g[u][i])]] = 1;
        nw_gr.pb(mp(g[u][i],u));
      }else{
      	kek[wp[mp(u,g[u][i])]] = 0;
      	nw_gr.pb(mp(u,g[u][i]));
      }
      dfs(g[u][i],naob ^ 1);
  	}
  }
  for(int i = 0;i < gr[u].size();i++){
  	if(!used[gr[u][i]]){
  	  if(naob){
        kek[wp[mp(gr[u][i],u)]] = 0;
        nw_gr.pb(mp(gr[u][i],u));
      }else{
      	kek[wp[mp(gr[u][i],u)]] = 1;
      	nw_gr.pb(mp(u,gr[u][i]));
      }
      dfs(gr[u][i],naob ^ 1);
  	}
  }
}
void dfs2(int u){
  cur++;
  used[u] = 1;
  for(int i = 0;i < xxx[u].size();i++){
  	if(!used[xxx[u][i]]){
  	  dfs2(xxx[u][i]);
  	  break;
  	}
  }
}
signed main(){
  int n,m;
  cin >> n >> m;
  g.resize(n);
  gr.resize(n);
  used.resize(n,false);
  kek.resize(n,false);
  xxx.resize(n);
  int f,t;
  for(int i = 0;i < m;i++){
    cin >> f >> t;
    f--;
    t--;
    g[f].pb(t);
    gr[t].pb(f);
    wp[mp(f,t)] = i;
  }
  for(int i = 0;i < n;i++){
  	if(!used[i]){
  	  dfs(i,0);
  	}
  }
  fill(all(used),0);
  for(int i = 0;i < nw_gr.size();i++){
  	// cout << nw_gr[i].x << ' ' << nw_gr[i].y << endl;
    xxx[nw_gr[i].x].pb(nw_gr[i].y);
  }
  for(int i = 0;i < n;i++){
  	if(!used[i]){
  	  cur = 0;
  	  dfs2(i);
  	  if(cur > 2){
  	  	puts("NO");
  	  	return 0;
  	  }
  	}
  }
  puts("YES");
  for(int i = 0;i < m;i++){
    cout << kek[i];
  }
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
//using namespace __gnu_cxx;

#define IOC std::ios::sync_with_stdio(false)
typedef long long LL;
typedef unsigned long long uLL;
typedef unsigned int uit;
typedef long double ld;
//typedef pair<int,int> pii;
const int INF = 0x3f3f3f3f;
const double enf = 1e-8;
const double pi = acos(-1.0);
inline LL read()
{
    LL X=0,w=0; char ch=0;
    while(!isdigit(ch)) {w|=ch=='-';ch=getchar();}
    while(isdigit(ch)) X=(X<<3)+(X<<1)+(ch^48),ch=getchar();
    return w?-X:X;
}
inline void write(LL x)
{
     if(x<0) putchar('-'),x=-x;
     if(x>9) write(x/10);
     putchar(x%10+'0');
}
//-------head------------

const int maxn = 2e5 + 10;
struct grap{
    int head[maxn],tot = 1;
    struct edge{
        int from,to,id;
    }e[maxn << 1];
    inline void add(int u,int v,int id){
        e[++tot].from = head[u];
        e[tot].to = v;
        e[tot].id = id;
        head[u] = tot;
    }
    inline void dbadd(int u,int v,int id){
        add(u,v,id);   add(v,u,id);
    }
}g;

int vis[maxn],in[maxn];
struct node{
    int u,v;
}dict[maxn];

inline void dfs(int x,int k){
    in[x] = 1;
    for(int i = g.head[x]; i; i = g.e[i].from){
        int id = g.e[i].id,v = g.e[i].to;
        if(in[v])   continue;
        in[v] = 1;
        if(vis[id] == 0){
            if(dict[id].u == x){
                vis[id] = k;
            }
            else{
                vis[id] = -k;
            }
            dfs(v,-k);
        }
    }
}
int main()
{
    int n = read(),m = read();
    for(int u,v,i = 0; i < m; ++i){
        u = read(),v = read();
        dict[i].u = u,dict[i].v = v;
        g.dbadd(u,v,i);
    }
    cout << "YES" << endl;
    dfs(1,1);
    for(int i = 0; i < m; ++i){
        printf("%d",vis[i] == 1 ? 1 : 0);
    }

    return 0;
}


#include <bits/stdc++.h>
//#include<algorithm>
//#include<math.h>
//#include<stdio.h>
//#include<ctype.h>
//#include<string.h>
//#include<iostream>
using namespace std;
//using namespace __gnu_cxx;

#define IOC std::ios::sync_with_stdio(false)
typedef long long LL;
typedef unsigned long long uLL;
typedef unsigned int uit;
typedef long double ld;
typedef pair<int,int> pii;
const int INF = 0x3f3f3f3f;
const double enf = 1e-8;
const double pi = acos(-1.0);
inline LL read()
{
    LL X=0,w=0; char ch=0;
    while(!isdigit(ch)) {w|=ch=='-';ch=getchar();}
    while(isdigit(ch)) X=(X<<3)+(X<<1)+(ch^48),ch=getchar();
    return w?-X:X;
}
inline void write(LL x)
{
     if(x<0) putchar('-'),x=-x;
     if(x>9) write(x/10);
     putchar(x%10+'0');
}
//-------head------------

const int maxn = 2e5 + 10;
struct grap{
    int head[maxn],tot = 1;
    struct edge{
        int from,to,id;
    }e[maxn << 1];
    inline void add(int u,int v,int id){
        e[++tot].from = head[u];
        e[tot].to = v;
        e[tot].id = id;
        head[u] = tot;
    }
    inline void dbadd(int u,int v,int id){
        add(u,v,id);   add(v,u,id);
    }
}g;

int vis[maxn],in[maxn];
struct node{
    int u,v;
}dict[maxn];

bool flag = 0;
inline void judge(int x,int fa){
    for(int i = g.head[x]; i; i = g.e[i].from){
        int v = g.e[i].to;
        if(v == fa) continue;
        if(in[v]){
            flag = 1;
            cout << "----" << endl;
            return;
        }
        in[v] = 1;
        judge(v,x);
    }
}
inline void dfs(int x,int k){
    in[x] = 1;
    for(int i = g.head[x]; i; i = g.e[i].from){
        int id = g.e[i].id,v = g.e[i].to;
        if(in[v])   continue;
        in[v] = 1;
        if(vis[id] == 0){
            if(dict[id].u == x){
                vis[id] = k;
            }
            else{
                vis[id] = -k;
            }
            dfs(v,-k);
        }
    }
}
int main()
{
    int n = read(),m = read();
    for(int u,v,i = 0; i < m; ++i){
        u = read(),v = read();
        dict[i].u = u,dict[i].v = v;
        g.dbadd(u,v,i);
    }
    judge(1,0);
    if(flag == 1){
        return cout << "NO" << endl,0;
    }
    cout << "YES" << endl;
    memset(in,0,sizeof in);
    dfs(1,1);
    for(int i = 0; i < m; ++i){
        printf("%d",vis[i] == 1 ? 1 : 0);
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
//using namespace __gnu_cxx;

#define IOC std::ios::sync_with_stdio(false)
typedef long long LL;
typedef unsigned long long uLL;
typedef unsigned int uit;
typedef long double ld;
//typedef pair<int,int> pii;
const int INF = 0x3f3f3f3f;
const double enf = 1e-8;
const double pi = acos(-1.0);
inline LL read()
{
    LL X=0,w=0; char ch=0;
    while(!isdigit(ch)) {w|=ch=='-';ch=getchar();}
    while(isdigit(ch)) X=(X<<3)+(X<<1)+(ch^48),ch=getchar();
    return w?-X:X;
}
inline void write(LL x)
{
     if(x<0) putchar('-'),x=-x;
     if(x>9) write(x/10);
     putchar(x%10+'0');
}
//-------head------------

const int maxn = 2e5 + 10;
struct grap{
    int head[maxn],tot = 1;
    struct edge{
        int from,to,id;
    }e[maxn << 1];
    inline void add(int u,int v,int id){
        e[++tot].from = head[u];
        e[tot].to = v;
        e[tot].id = id;
        head[u] = tot;
    }
    inline void dbadd(int u,int v,int id){
        add(u,v,id);   add(v,u,id);
    }
}g;

int vis[maxn],in[maxn];
struct node{
    int u,v;
}dict[maxn];

bool flag = 0;
inline void judge(int x,int fa){
    for(int i = g.head[x]; i; i = g.e[i].from){
        int v = g.e[i].to;
        if(v == fa) continue;
        if(in[v]){
            flag = 1;
            return;
        }
        in[v] = 1;
        judge(v,x);
    }
}
inline void dfs(int x,int k){
    in[x] = 1;
    for(int i = g.head[x]; i; i = g.e[i].from){
        int id = g.e[i].id,v = g.e[i].to;
        if(in[v])   continue;
        in[v] = 1;
        if(vis[id] == 0){
            if(dict[id].u == x){
                vis[id] = k;
            }
            else{
                vis[id] = -k;
            }
            dfs(v,-k);
        }
    }
}
int main()
{
    int n = read(),m = read();
    for(int u,v,i = 0; i < m; ++i){
        u = read(),v = read();
        dict[i].u = u,dict[i].v = v;
        g.dbadd(u,v,i);
    }
    judge(1,0);
    if(flag == 1){
        return cout << "NO" << endl,0;
    }
    cout << "YES" << endl;
    memset(in,0,sizeof in);
    dfs(1,1);
    for(int i = 0; i < m; ++i){
        printf("%d",vis[i] == 1 ? 1 : 0);
    }

    return 0;
}


#include <bits/stdc++.h>
//#include<algorithm>
//#include<math.h>
//#include<stdio.h>
//#include<ctype.h>
//#include<string.h>
//#include<iostream>
using namespace std;
//using namespace __gnu_cxx;

#define IOC std::ios::sync_with_stdio(false)
typedef long long LL;
typedef unsigned long long uLL;
typedef unsigned int uit;
typedef long double ld;
typedef pair<int,int> pii;
const int INF = 0x3f3f3f3f;
const double enf = 1e-8;
const double pi = acos(-1.0);
inline LL read()
{
    LL X=0,w=0; char ch=0;
    while(!isdigit(ch)) {w|=ch=='-';ch=getchar();}
    while(isdigit(ch)) X=(X<<3)+(X<<1)+(ch^48),ch=getchar();
    return w?-X:X;
}
inline void write(LL x)
{
     if(x<0) putchar('-'),x=-x;
     if(x>9) write(x/10);
     putchar(x%10+'0');
}
//-------head------------

const int maxn = 2e5 + 10;
struct grap{
    int head[maxn],tot = 1;
    struct edge{
        int from,to,id;
    }e[maxn << 1];
    inline void add(int u,int v,int id){
        e[++tot].from = head[u];
        e[tot].to = v;
        e[tot].id = id;
        head[u] = tot;
    }
    inline void dbadd(int u,int v,int id){
        add(u,v,id);   add(v,u,id);
    }
}g;

int vis[maxn],in[maxn];
struct node{
    int u,v;
}dict[maxn];

bool flag = 0;
inline bool judge(int x,int fa){
    for(int i = g.head[x]; i; i = g.e[i].from){
        int v = g.e[i].to;
        if(v == fa) continue;
        if(!vis[v]){
            vis[v] = 1;
            if(judge(v,x))  return true;
        }
        return true;
    }
    return false;
}
inline void dfs(int x,int k){
    in[x] = 1;
    for(int i = g.head[x]; i; i = g.e[i].from){
        int id = g.e[i].id,v = g.e[i].to;
        if(in[v])   continue;
        in[v] = 1;
        if(vis[id] == 0){
            if(dict[id].u == x){
                vis[id] = k;
            }
            else{
                vis[id] = -k;
            }
            dfs(v,-k);
        }
    }
}
int main()
{
    int n = read(),m = read();
    for(int u,v,i = 0; i < m; ++i){
        u = read(),v = read();
        dict[i].u = u,dict[i].v = v;
        g.dbadd(u,v,i);
    }
    if(judge(1,0)){
        return cout << "NO" << endl,0;
    }
    cout << "YES" << endl;
    memset(vis,0,sizeof vis);
    dfs(1,1);
    for(int i = 0; i < m; ++i){
        printf("%d",vis[i] == 1 ? 1 : 0);
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
//using namespace __gnu_cxx;

#define IOC std::ios::sync_with_stdio(false)
typedef long long LL;
typedef unsigned long long uLL;
typedef unsigned int uit;
typedef long double ld;
//typedef pair<int,int> pii;
const int INF = 0x3f3f3f3f;
const double enf = 1e-8;
const double pi = acos(-1.0);
inline LL read()
{
    LL X=0,w=0; char ch=0;
    while(!isdigit(ch)) {w|=ch=='-';ch=getchar();}
    while(isdigit(ch)) X=(X<<3)+(X<<1)+(ch^48),ch=getchar();
    return w?-X:X;
}
inline void write(LL x)
{
     if(x<0) putchar('-'),x=-x;
     if(x>9) write(x/10);
     putchar(x%10+'0');
}
//-------head------------

const int maxn = 2e5 + 10;
struct grap{
    int head[maxn],tot = 1;
    struct edge{
        int from,to,id;
    }e[maxn];
    inline void add(int u,int v,int id){
        e[++tot].from = head[u];
        e[tot].to = v;
        e[tot].id = id;
        head[u] = tot;
    }
    inline void dbadd(int u,int v,int id){
        add(u,v,id);   add(v,u,id);
    }
}g;

int vis[maxn],in[maxn];
struct node{
    int u,v;
}dict[maxn];

inline void dfs(int x,int k){
    in[x] = 1;
    for(int i = g.head[x]; i; i = g.e[i].from){
        int id = g.e[i].id,v = g.e[i].to;
        if(in[v])   continue;
        in[v] = 1;
        if(vis[id] == 0){
            if(dict[id].u == x){
                vis[id] = k;
            }
            else{
                vis[id] = -k;
            }
            dfs(v,-k);
        }
    }
}
int main()
{
    int n = read(),m = read();
    for(int u,v,i = 0; i < m; ++i){
        u = read(),v = read();
        dict[i].u = u,dict[i].v = v;
        g.dbadd(u,v,i);
    }
    cout << "YES" << endl;
    dfs(1,1);
    for(int i = 0; i < m; ++i){
        printf("%d",vis[i] == 1 ? 1 : 0);
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
//using namespace __gnu_cxx;

#define IOC std::ios::sync_with_stdio(false)
typedef long long LL;
typedef unsigned long long uLL;
typedef unsigned int uit;
typedef long double ld;
//typedef pair<int,int> pii;
const int INF = 0x3f3f3f3f;
const double enf = 1e-8;
const double pi = acos(-1.0);
inline LL read()
{
    LL X=0,w=0; char ch=0;
    while(!isdigit(ch)) {w|=ch=='-';ch=getchar();}
    while(isdigit(ch)) X=(X<<3)+(X<<1)+(ch^48),ch=getchar();
    return w?-X:X;
}
inline void write(LL x)
{
     if(x<0) putchar('-'),x=-x;
     if(x>9) write(x/10);
     putchar(x%10+'0');
}
//-------head------------

const int maxn = 2e5 + 10;
struct grap{
    int head[maxn],tot = 1;
    struct edge{
        int from,to,id;
    }e[maxn];
    inline void add(int u,int v,int id){
        e[++tot].from = head[u];
        e[tot].to = v;
        e[tot].id = id;
        head[u] = tot;
    }
    inline void dbadd(int u,int v,int id){
        add(u,v,id);   add(v,u,id);
    }
}g;

int vis[maxn];

inline void dfs(int x,int k){
    for(int i = g.head[x]; i; i = g.e[i].from){
        int id = g.e[i].id,v = g.e[i].to;
        if(!vis[id]){
            vis[id] = k;
            dfs(v,-k);
        }
    }
}
int main()
{
    int n = read(),m = read();
    for(int u,v,i = 0; i < m; ++i){
        u = read(),v = read();
        g.dbadd(u,v,i);
    }
    cout << "YES" << endl;
    dfs(1,1);
    for(int i = 0; i < m; ++i){
        printf("%d",vis[i] == 1 ? 1 : 0);
    }

    return 0;
}