#![allow(non_snake_case)] use std::io::{ self, prelude::* }; fn readline() -> String { let mut s = String::new(); io::stdin().read_line(&mut s).expect("i/o error"); s.trim().to_owned() } fn recv() -> i64 { readline().parse().unwrap() } fn send(x: i64) { println!("{}", x); io::stdout().flush().expect("i/o error"); } fn main() { let line = readline(); let mut tokens = line.split_whitespace(); let N: i64 = tokens.next().unwrap().parse().unwrap(); let K: i64 = tokens.next().unwrap().parse().unwrap(); let R = (N-1) % (K+1); let mut x = if R == 0 { 0 } else { R }; if x != 0 { send(x); } loop { let y = recv(); if y >= N { break; } assert!(x+1 <= y && y <= x+K); x += K+1; send(x); } }