#include <iostream>
using namespace std;
#include <bits/stdc++.h>
int main() {
// your code goes here
int n,m;
cin>>n>>m;
vector<int>b[n+5];
int i=1;
for(i=1;i<=m;i++)
{
int x,y;
cin>>x>>y;
b[x].push_back(y);
b[y].push_back(x);
}
int source = 1;
int used[n+5]={0};
int level[n+5]={-1};
queue<int>q;
q.push(source);
used[source]=1;
level[source]=0;
int ways[n+5]={0};
ways[1]=1;
int count=0;
//int count[n+5]={0};
while(!q.empty())
{
int removed;
removed=q.front();
//cout<<removed<<"-"<<count<<endl;
q.pop();
for(auto x:b[removed])
{
if(used[x]==0)
{
q.push(x);
used[x]=1;
level[x]=level[removed]+1;
if(x==5)
{
ways[x]=count++;
}else
{
ways[x]=ways[removed]+ways[x];
}
}
else
{
if(level[x]==level[removed]+1)
{
if(x==5)
{
ways[x]=count++;
}else
{
ways[x]=ways[removed]+ways[x];
}
}
}
}
}
i=1;
while(i<=n)
{
cout<<i<<"-"<<ways[i]<<endl;
i++;
}
// cout<<ways[6];
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwojaW5jbHVkZSA8Yml0cy9zdGRjKysuaD4KCmludCBtYWluKCkgewoJLy8geW91ciBjb2RlIGdvZXMgaGVyZQoJaW50IG4sbTsKCWNpbj4+bj4+bTsKCXZlY3RvcjxpbnQ+YltuKzVdOwoJaW50IGk9MTsKCWZvcihpPTE7aTw9bTtpKyspCgkgewoJIAlpbnQgeCx5OwoJIAljaW4+Png+Pnk7CgkgCWJbeF0ucHVzaF9iYWNrKHkpOwoJIAliW3ldLnB1c2hfYmFjayh4KTsKCSB9CgkgCgkgaW50IHNvdXJjZSA9IDE7CgkgaW50IHVzZWRbbis1XT17MH07CgkgaW50IGxldmVsW24rNV09ey0xfTsKCSBxdWV1ZTxpbnQ+cTsKCSBxLnB1c2goc291cmNlKTsKCSB1c2VkW3NvdXJjZV09MTsKCSBsZXZlbFtzb3VyY2VdPTA7CgkgaW50IHdheXN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