#![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 mut x = (N-1) % (K+1); loop { send(x); let y = recv(); if y >= N { break; } assert!(x+1 <= y && y <= x+K); x += K+1; } }