[BenweiZhu] add condition pq pp qr and pq pr or ps qr
[BenweiZhu] fix the bug in pq pr or ps qr