// https://atcoder.jp/contests/nikkei2019-2-qual/tasks/nikkei2019_2_qual_e
//
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, [ next / $t:tt ]) => {
        {
            let len = read_value!($iter, usize);
            (0..len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
        }
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! dvec {
    ($t:expr ; $len:expr) => {
        vec![$t; $len]
    };

    ($t:expr ; $len:expr, $($rest:expr),*) => {
        vec![dvec!($t; $($rest),*); $len]
    };
}

#[allow(unused_macros)]
macro_rules! ifv {
    ($t:expr, $a:expr, $b: expr) => {
        if $t { $a } else { $b }
    }
}

#[allow(unused_macros)]
macro_rules! fill {
    ($t:expr, $v:expr) => {
        for i in 0..$t.len() {
            $t[i] = $v;
        }
    };
}

#[allow(unused_macros)]
macro_rules! join {
    ($t:expr, $glue:expr) => {
        $t.into_iter().map(|w| w.to_string()).collect::<Vec<_>>().join($glue)
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn solve(n: i64, k: i64) -> Option<Vec<(i64, i64, i64)>> {
    let mut ans = vec![];
    let le = (k+1)/2;
    for i in 0..n {
        if k+2*n+i*2 > 3*n-1+k {
            break;
        }
        if 2*n+i >= 2*n+k {
            break;
        }
        ans.push((k+i, 2*n+i, k+2*n+i*2));
    }
    // debug!(ans);
    let le = ans.len();
    let ni = n as usize;
    let mut used = vec![0; 3*ni];
    for i in 0..le {
        let num = ans[i].0 - k;
        if num < 0 || num >= 2*n {
            return None;
        }
        used[num as usize] += 1;
        let num = ans[i].1 - k;
        if num < 0 || num >= 2*n {
            return None;
        }
        used[num as usize] += 1;
        used[2*ni+i*2] = 1;
    }

    let mut left = vec![];
    for i in 0..2*ni {
        if used[i] >= 2 {
            return None;
        }
        if used[i] == 0 {
            left.push(i);
        }
    }
    let mut right = vec![];
    for i in 2*ni..3*ni {
        if used[i] == 0 {
            right.push(i);
        }
    }
    let ln = left.len();
    for w in 0..ln/2 {
        let a = left[w] as i64;
        let b = left[w+ln/2] as i64;
        let c = right[w] as i64;
        ans.push((a+k, b+k, c+k));
    }
    let n = ans.len();
    for i in 0..n {
        if ans[i].0 + ans[i].1 > ans[i].2 {
            return None;
        }
    }
    return Some(ans);
}

fn main() {
    input! {
        n: i64, k: i64
    };
    if let Some(a) = solve(n, k) {
        for i in 0..(n as usize) {
            println!("{} {} {}", a[i].0, a[i].1, a[i].2);
        }
    } else {
        println!("-1");
    }
}


Measured memory_bytes: 16300