fn main() { let mut nk = String::new(); std::io::stdin().read_line(&mut nk).ok(); let nk: Vec = nk.trim().split_whitespace().map(|s| s.parse().unwrap()).collect(); let n = nk[0]; let k = nk[1]; if k < n/2+n%2 { println!("-1"); return; } let mut result = vec![]; for i in 0..k { let lidx = if i >= n/2 && n % 2 == 0 { 1 } else { 0 } + 2*i; let lidx = lidx % n; let ridx = (lidx + 1) % n; result.push((lidx+1, ridx+1)); } for i in 0..n { result.push((i+1, i+1)); } println!("{}", result.len()); for &(l, r) in result.iter() { println!("{} {}", l, r); } }