The logic of questions and answers