train and query