The present invention provides 2,4-disubstituted pyrimidine compounds useful as kinase inhibitors, pharmaceutically acceptable compositions thereof, and methods of using the same. In some embodiments, the present invention provides a compound of formula I-a or I-b: wherein each of Ring A, Ring B, W1, W2, Ry, Rv, Rx, m, p, and R1 is described herein.