#include <bits/stdc++.h> 
#include<cmath>
#include<string>
#define pb push_back
#define x first
#define y second
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define all(x) x.begin(),x.end()
#define int long long
#define ll long long
using namespace std;
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
//void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
// look for  all edge cases
//search for a pattern

void solve(){
	int a,b;
	cin >> a >> b;
	int ans = 1;
	for(int i = 2 ; i < (b - a) + 1; i++){
		int val1 = a/i;
		int val2 = b/i;
		val2 += (a % i == 0) ? 1:0;
		//debug(val2, val1);
		if(val2 - val1 > 1){
			ans = i;
		}
	}
	cout << ans ;
}

signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);	
	
	solve();
	
	return 0;
}

#include <bits/stdc++.h>
#include <unistd.h>

#define rep(i,j,n) for(i=j;i<n;i++)
#define repi(i,j,n) for(i=j;i>n;i--)
#define pie 3.141592653589793238
#define ll long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define pb push_back
#define F first
#define S second
#define endl '\n'
#define UQ(x) (x).resize(distance((x).begin(),unique(x.begin(),x.end())))

using namespace std;

mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
mt19937_64 rnd64(chrono::high_resolution_clock::now().time_since_epoch().count());

ll power(ll a,ll m,ll mod){
	ll ans = 1;
	while(m){
		if(m%2) ans *= a, ans %= (mod);
		a = (a*a) % mod;
		m >>= 1;
	}
	return ans;
}

struct custom_hash {  // Credits: https://codeforces.com/blog/entry/62393
 	static uint64_t splitmix64(uint64_t x) {
    	// http://xorshift.di.unimi.it/splitmix64.c
    	x += 0x9e3779b97f4a7c15;
    	x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    	x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    	return x ^ (x >> 31);
  	}
 
  	size_t operator()(uint64_t x) const {
    	static const uint64_t FIXED_RANDOM =
        	chrono::steady_clock::now().time_since_epoch().count();
    	return splitmix64(x + FIXED_RANDOM);
  	}
  	size_t operator()(pair<int64_t, int64_t> Y) const {
    	static const uint64_t FIXED_RANDOM =
        	chrono::steady_clock::now().time_since_epoch().count();
    	return splitmix64(Y.first * 31 + Y.second + FIXED_RANDOM);
  	}
};

const long long inf = 1e18;
const long long M = 1000000007;



void solve(){
	ll i,j,_;
	ll n, m;
	cin >> n >> m;
	// brute(n,m,0);
	if(n == 1 && m == 0) {
		cout << 1 << ' ' << 2 << endl;
		return;
	} 
	if(m < 0 || m > n - 2) {
		cout << - 1 << endl;
		return;
	}
	cout << 1 << ' ' << 2 * (m + 2) << endl;
	j = 2;
	rep(i,1,m + 2) {
		cout << j << ' ' << j + 1 << endl;
		j += 2;
	} 
	n -= m + 2;
	j++;
	while(n--) {
		cout << j << ' ' << j + 1 << endl;
		j += 2;
	}
}

int main()
{
	ios::sync_with_stdio(0);
 	cin.tie(0);
	ll T=1;
	// cin>>T;
	while(T--){
		solve();
	}
	return 0;
}


