#include <bits/stdc++.h>
using namespace std;
int random(int n){
return (long long)rand()*rand()%n;
}
int main()
{
freopen("data.in","w",stdout);
srand((unsigned)time(0));
int n,m;
//注:n为节点数,m为边数,不存在重边,自环,且为连通图,保证数据范围为:5<=n<=m<=n(n-1)/4<=10**6
cin>>n>>m;
pair<int,int> e[1000005];
map<pair<int,int>,bool> h;
for(int i = 1;i<n;i++){
int fa = random(i)+1;
e[i] = make_pair(fa,i+1);
h[e[i]] = h[make_pair(i+1,fa)] = 1;
}
for(int i = n;i<=m;i++){
int x,y;
do{
x = random(n)+1,y = random(n)+1;
}while(x==y||h[make_pair(x,y)]);
e[i] = make_pair(x,y);
h[e[i]] = h[make_pair(y,x)] = 1;
}
random_shuffle(e+1,e+m+1);
for(int i = 1;i<=m;i++){
cout<<e[i].first<<e[i].second<<endl;
}
return 0;
}