#include <vector>
#include <iostream>
#include <string>
#include <map>
#include <stack>
#include <cstring>
#include <queue>
#include <list>
#include <cstdio>
#include <set>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <cctype>
#include <sstream>
#include <functional>
using namespace std;
#define pi acos(-1)
#define endl '\n'
#define rand() srand(time(0));
#define me(x) memset(x,0,sizeof(x));
#define foreach(it,a) for(__typeof((a).begin()) it=(a).begin();it!=(a).end();it++)
#define close() ios::sync_with_stdio(0);
typedef long long LL;
const int INF=0x3f3f3f3f;
const LL LINF=0x3f3f3f3f3f3f3f3fLL;
//const int dx[]={-1,0,1,0,-1,-1,1,1};
//const int dy[]={0,1,0,-1,1,-1,1,-1};
const int maxn=1e3+5;
const int maxx=200020;
const double EPS=1e-7;
const int MOD=1000000007;
#define mod(x) ((x)%MOD);
template<class T>inline T min(T a,T b,T c) { return min(min(a,b),c);}
template<class T>inline T max(T a,T b,T c) { return max(max(a,b),c);}
template<class T>inline T min(T a,T b,T c,T d) { return min(min(a,b),min(c,d));}
template<class T>inline T max(T a,T b,T c,T d) { return max(max(a,b),max(c,d));}
//typedef tree<pt,null_type,less< pt >,rb_tree_tag,tree_order_statistics_node_update> rbtree;
/*lch[root] = build(L1,p-1,L2+1,L2+cnt);
rch[root] = build(p+1,R1,L2+cnt+1,R2);中前*/
/*lch[root] = build(L1,p-1,L2,L2+cnt-1);
rch[root] = build(p+1,R1,L2+cnt,R2-1);中后*/
long long gcd(long long a , long long b){if(b==0) return a;a%=b;return gcd(b,a);}
int p,q;
vector<int >G[maxx];
int main()
{
freopen("drunkard.in","r",stdin);
freopen("drunkard.out","w",stdout);
while(cin>>p>>q,p)
{
int n=q+1;
for(int i=1;i<=n;i++)
G[i].clear();
vector<int >ans;
ans.push_back(n-1);//最左边
int t=q-p+1;//右边距离 p点位置
int now=1;
for(int i=2;i<t;i++) ans.push_back(++now);
ans.push_back(1);
for(int i=t+1;i<n;i++) ans.push_back(++now);
ans.push_back(n);
for(int i=1;i+1<ans.size();i++)
{
G[ans[i]].push_back(ans[i-1]);
G[ans[i]].push_back(ans[i+1]);
}
cout<<n<<endl;
for(int i=1;i<n-1;i++)
cout<<G[i][0]<<" "<<G[i][1]<<endl;
}
}