QP algorithm for TREC dataset