#include <bits/stdc++.h>
 
#define int long long
 
#define pii pair<int, int>
 
#define x1 x1228
#define y1 y1228
 
#define left left228
#define right right228
 
#define pb push_back
#define eb emplace_back
 
#define mp make_pair                                                                
                                                                                                                                        
#define ff first                                                                  
#define ss second   
 
#define matr vector<vector<int> > 
 
#define all(x) x.begin(), x.end()
 
 
using namespace std;
typedef long long ll; 
typedef long double ld; 
                                                                                                   
const int maxn = 3e5 + 7, mod = 998244353, MAXN = 1e6 + 7;
const double eps = 1e-9;
const ll inf = 1e18; 
mt19937 rnd(time(0));
int n, k; 
set<int> have; 
 
struct ANS {
    int a, b, c; 
    ANS(int a, int b, int c) : a(a), b(b), c(c) {}
    ANS() : a(0), b(0), c(0) {}
};
 
void solve() { 
    cin >> n >> k; 
    if (k > (n + 1) / 2) {
        cout << -1;
        return; 
    }
    int k1 = k;         
    k = (n + 1) / 2; 
    vector<int> ms;
    for (int i = 2 * n - k; i < 3 * n - k; ++i) {
        ms.pb(i); 
    }
    int cur = n; 
    set<int> kek; 
    for (int i = 0; i < n; ++i) {
        kek.insert(i); 
    }
    vector<ANS> ans;
    bool fl = true; 
    for (int i = 0; i < ms.size(); i += 2) {
        int add = ms[i] - cur;  
        auto t = kek.upper_bound(add);
        if (t == kek.begin()) {
            fl = false; 
            break; 
        }
        --t; 
//        cout << ms[i] << " " << cur << " "; 
        add = *t; 
//        cout << add << endl; 
        kek.erase(t);  
        ans.eb(add + k + (k1 - k), cur + k + (k1 - k), ms[i] + k + k + (k1 - k)); 
        ++cur; 
    }
    for (int i = 1; i < ms.size(); i += 2) {
        int add = ms[i] - cur;  
        auto t = kek.upper_bound(add);
        if (t == kek.begin()) {
            fl = false; 
            break; 
        }
        --t; 
        add = *t; 
        kek.erase(t);  
        ans.eb(add + k + (k1 - k), cur + k + (k1 - k), ms[i] + k + k + (k1 - k)); 
        ++cur; 
    }
    for (auto v : ans) cout << v.a << " " << v.b << " " << v.c << '\n';
/*    ans.clear();
    set<int> kek; 
    for (int i = 0; i < n; ++i) {
        kek.inert(i); 
    }
    cur = n; 
    for (int i = 1; i < ms.size(); i += 2) {
        int add = ms[i] - cur + k; 
        ans.eb(ms[i] - cur + k + (k1 - k), cur + k + (k1 - k), ms[i] + k + k + (k1 - k)); 
        ++cur; 
    }
    for (int i = 0; i < ms.size(); i += 2) {
        ans.eb(ms[i] - cur + k + (k1 - k), cur + k + (k1 - k), ms[i] + k + k + (k1 - k)); 
        ++cur;                         
    }
    for (auto v : ans) cout << v.a << " " << v.b << " " << v.c << '\n';*/
}   

signed main() {
#ifdef LOCAL
    freopen("TASK.in", "r", stdin);
    freopen("TASK.out", "w", stdout);
#else 
    
#endif // LOCAL
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20); 
    cout << fixed; 
    int t = 1; 
    for (int i = 0; i < t; ++i) {              
        solve();
    }
    return 0;
}     

Measured memory_bytes: 8688