A compound of the following formula (I) wherein R1, R2, R3, R4, R5, R6, W, X, Y, Z, m, n, and p are as defined herein. This invention also covers methods for inhibiting dipeptidyl peptidase IV or VIII, or treating Type II diabetes with such a compound.