#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define repi(i, x) \
	for (auto i = (x).begin(), i##_fin = (x).end(); i != i##_fin; i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int, int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long, long long> P;
typedef vector<P> VP;
template <class T>
inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return 1;
	}
	return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return 1;
	}
	return 0;
}
template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << "(" << p.first << " " << p.second << ")";
	return os;
}
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	rep(i, v.size()) {
		if (i) os << " ";
		os << v[i];
	}
	return os;
}
template <class T, class U>
istream& operator>>(istream& is, pair<T, U>& p) {
	is >> p.first >> p.second;
	return is;
}
template <class T>
istream& operator>>(istream& is, vector<T>& v) {
	rep(i, v.size()) { is >> v[i]; }
	return is;
}
const long long INFLL = 1LL << 60;
const int INF         = 1 << 30;
const double PI       = acos(-1);
#ifdef LOCAL
#define dbg(x) cerr << #x << ": " << (x) << '\n'
#define say(x) cerr << (x) << '\n'
#else
#define dbg(x)
#define say(x)
#endif
string solve(bool a) { return ((a) ? "Yes" : "No"); }
int main() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n, m;
	// int up   = 1e9;
	// int down = 1;
	// bool can = false;
	cin >> n >> m;
	int margin = m + 1;
	dbg(margin);
	VPi ans(n);
	if (m == 0) {
		rep(i, n) { ans[i] = mp(i * 2 + 1, i * 2 + 2); }
	} else if (m < 0 || m > n - 2) {
		cout << -1 << endl;
		return 0;
	} else {
		for (int i = 1; i <= margin; i++) {
			ans[i - 1] = mp(2 * i, 2 * i + 1);
			dbg(ans[i - 1]);
		}
		ans[margin] = mp(1, 2 * margin + 2);
		dbg(ans[margin]);
		for (int i = margin + 1; i < n; i++) {
			ans[i] = mp(2 * margin + 2 + 2 * i, 2 * margin + 3 + 2 * i);
		}
	}
	rep(i, n) { cout << ans[i].F << " " << ans[i].S << endl; }
}
/*
1  9, 2 3 , 4 5 ,6 7 (2:2)

1 5, 6 9, 2 3 , 7 8 (0:0/0)

1 2 ,3 9, 4 5 ,6 7 (1 : 0/1)

2 3, 4 5, 6 7, (2n: 2n+1;n=1...M) +(1:2(M+1))
*/
//vs solve(int n){
//    vs ans;
//    per(bit,n){
//        rep(cases,1<<(n-1-bit)){
//            ll mask = 1<<bit;
//            rep(i,n-1-bit)
//                if(cases&(1<<i))
//                    mask ^= 1<<(bit+i+1);
//            string cur;
//            rep(i,1<<n)
//                if(__builtin_popcountll(i&mask)%2 == 1)
//                    cur += "A";
//                else
//                    cur += "B";
//
//            ans.pb(cur);
//        }
//    }
//    return ans;
//}
//void __(){
//    _(ll,k);
//    vector<string> ans;
//    rep(i,k){
//        string cur;
//        rep(j,(1<<k))
//            if(j&(1<<i))
//                cur += "A";
//            else
//                cur += "B";
//        ans.pb(cur);
//    }
//    ans = solve(k);
//    print sz(ans);
//    print_vn ans;
//                //if(_[i] != _[j])
//}
//
#include <iomanip>
#include <vector>
#include <utility>
#include <iostream>
#include <string>
#define pb push_back
#define REP_ZERO_INT(i,r) for(int i = 0; i < (r); ++i)
#define GET_REP_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define rep(...) GET_REP_MACRO(__VA_ARGS__,REP_ANY,REP_INT,REP_ZERO_INT)(__VA_ARGS__)
#define PER_ZERO_INT(i,r) for(int i = (r)-1; i >= 0; --i)
#define GET_PER_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define per(...) GET_PER_MACRO(__VA_ARGS__,PER_ANY,PER_INT,PER_ZERO_INT)(__VA_ARGS__)
#define all(v) (v).begin(), (v).end()
#define sz(v) ll(v.size())
#define T1 template<typename T> static
using namespace std;
typedef long long ll;
typedef vector<string> vs;
T1 ostream& operator<<(ostream& stream, const vector<T>& t);
T1 istream& read(T, T, istream& = cin);
struct _print {
    string sep,end;
    bool space;
    ostream &stream;
    _print(string _sep=" ",string _end="\n",
            ostream &_stream = cout) 
        : sep(_sep),end(_end),space(false),
            stream(_stream) {}
    ~_print() { stream << end; }

    template <typename T>
        _print &operator , (const T &t) {
            if (space) stream << sep;
            space = true;
            stream << t;
            return *this;
        }
};
struct _print2{
    string s1,s2,end;
    bool space;
    ostream &stream;
    _print2(string _s1 = " ", string _s2 = " ", string _end="\n", ostream &_stream = cout)
        :s1(_s1),s2(_s2),end(_end),space(false),
        stream(_stream) {}
    ~_print2() { stream << end; }

    template <typename T>
        _print2 &operator , (const T &t) {
            for(auto _ : t){
                if (space) stream << s1;
                space = true;
                _print p(s2,"",stream);
                    p,_;
            }
            return *this;
        }
};
#define print _print(),
#define print_vn _print2("\n"," ","\n"),
#define INPUT_WITHOUT_INIT(type,name) type name; cin >> name
#define GET_INPUT_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define _(...) GET_INPUT_MACRO(__VA_ARGS__,_IWI,_IWI,_IWI,_IWI,_IWI,_IWI,INPUT_WITHOUT_INIT)(__VA_ARGS__)
vs solve(int n){
    vs ans;
    per(bit,n){
        rep(cases,1<<(n-1-bit)){
            ll mask = 1<<bit;
            rep(i,n-1-bit)
                if(cases&(1<<i))
                    mask ^= 1<<(bit+i+1);
            string cur;
            rep(i,1<<n)
                if(__builtin_popcountll(i&mask)%2 == 1)
                    cur += "A";
                else
                    cur += "B";

            ans.pb(cur);
        }
    }
    return ans;
}
void __(){
    _(ll,k);
    vector<string> ans;
    rep(i,k){
        string cur;
        rep(j,(1<<k))
            if(j&(1<<i))
                cur += "A";
            else
                cur += "B";
        ans.pb(cur);
    }
    ans = solve(k);
    print sz(ans);
    print_vn ans;
                //if(_[i] != _[j])
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
        __();
}

