A compound of formula I, or a pharmaceutically acceptable salt thereof, wherein: X is Cl; Y is C N; Ring A is C 5-10 aryl, a 3-8 membered saturated or partially unsaturated carbocyclic ring, a 3-7 membered heterocylic ring having 1-4 heteroatoms independently selected from nitrogen, oxygen, or sulfur, or a 5-6 membered monocyclic heteroaryl ring having 1-4 heteroatoms independently selected from nitrogen, oxygen, or sulfur; or a 6-18 membered bicyclic, fused bicyclic, spiro bicyclic, or polycyclic ring having 0-4 heteroatoms independently selected from nitrogen, oxygen, or sulfur, each of which is optionally substituted; each R 1 is independently -R, halogen, -haloalkyl, -hydroxyalkyl, -OR, -SR, -CN, - NO 2, -SO 2 R, -SOR, -C R, -CO 2 R, -C N 2, -NRC R, -NRC N 2, - NRSO 2 R, or-N 2; or two R 1 groups, together with the atom or atoms to which each is attached, may form a fused or spiro ring selected from C 5-10 aryl, a 3-8 membered saturated or partially unsaturated carbocyclic ring, a 3-7 membered heterocylic ring having 1-4 heteroatoms independently selected from nitrogen, oxygen, or sulfur, or a 5-6 membered monocyclic heteroaryl ring having 1-4 heteroatoms independently selected from nitrogen, oxygen, or sulfur; each of which is optionally substituted; Z is -R, halogen, -haloalkyl, -hydroxyalkyl, -OR, -SR, -CN, - NO 2, -SO 2 R, -SOR, -C R, -CO 2 R, -C N 2, -NRC R, -NRC N 2, - NRSO 2 R, or-N 2. each R a is independently -R, halogen, -haloalkyl, -hydroxyalkyl, -OR, -SR, -CN, - NO 2, -SO 2 R, -SOR, -C R, -CO 2 R, -C N 2, -NRC R, -NRC N 2, - NRSO 2 R, or-N 2; each R is independently hydrogen, C 1-6 aliphatic, C 3-10 aryl, a 3-8 membered saturated or partially unsaturated carbocyclic ring, a 3-7 membered heterocylic ring having 1-4 heteroatoms independently selected from nitrogen, oxygen, or sulfur, or a 5-6 membered monocyclic heteroaryl ring having 1-4 heteroatoms independently selected from nitrogen, oxygen, or sulfur; each of which is optionally substituted; or two R groups on the same atom are taken together with the atom to which they are attached to form a C 3-10 aryl, a 3-8 membered saturated or partially unsaturated carbocyclic ring, a 3-7 membered heterocylic ring having 1-4 heteroatoms independently selected from nitrogen, oxygen, or sulfur, or a 5-6 membered monocyclic heteroaryl ring having 1-4 heteroatoms independently selected from nitrogen, oxygen, or sulfur; each of which is optionally substituted; m is 1; n is 1, 2, or 3; and p is 1, or 2. X is Cl; Y is C N; Ring A is C 5-10 aryl, a 3-8 membered saturated or partially unsaturated carbocyclic ring, a 3-7 membered heterocylic ring having 1-4 heteroatoms independently selected from nitrogen, oxygen, or sulfur, or a 5-6 membered monocyclic heteroaryl ring having 1-4 heteroatoms independently selected from nitrogen, oxygen, or sulfur; or a 6-18 membered bicyclic, fused bicyclic, spiro bicyclic, or polycyclic ring having 0-4 heteroatoms independently selected from nitrogen, oxygen, or sulfur, each of which is optionally substituted; each R 1 is independently -R, halogen, -haloalkyl, -hydroxyalkyl, -OR, -SR, -CN, - NO 2, -SO 2 R, -SOR, -C R, -CO 2 R, -C N 2, -NRC R, -NRC N 2, - NRSO 2 R, or-N 2; or two R 1 groups, together with the atom or atoms to which each is attached, may form a fused or spiro ring selected from C 5-10 aryl, a 3-8 membered saturated or partially unsaturated carbocyclic ring, a 3-7 membered heterocylic ring having 1-4 heteroatoms independently selected from nitrogen, oxygen, or sulfur, or a 5-6 membered monocyclic heteroaryl ring having 1-4 heteroatoms independently selected from nitrogen, oxygen, or sulfur; each of which is optionally substituted; Z is -R, halogen, -haloalkyl, -hydroxyalkyl, -OR, -SR, -CN, - NO 2, -SO 2 R, -SOR, -C R, -CO 2 R, -C N 2, -NRC R, -NRC N 2, - NRSO 2 R, or-N 2. each R a is independently -R, halogen, -haloalkyl, -hydroxyalkyl, -OR, -SR, -CN, - NO 2, -SO 2 R, -SOR, -C R, -CO 2 R, -C N 2, -NRC R, -NRC N 2, - NRSO 2 R, or-N 2; each R is independently hydrogen, C 1-6 aliphatic, C 3-10 aryl, a 3-8 membered saturated or partially unsaturated carbocyclic ring, a 3-7 membered heterocylic ring having 1-4 heteroatoms independently selected from nitrogen, oxygen, or sulfur, or a 5-6 membered monocyclic heteroaryl ring having 1-4 heteroatoms independently selected from nitrogen, oxygen, or sulfur; each of which is optionally substituted; or two R groups on the same atom are taken together with the atom to which they are attached to form a C 3-10 aryl, a 3-8 membered saturated or partially unsaturated carbocyclic ring, a 3-7 membered heterocylic ring having 1-4 heteroatoms independently selected from nitrogen, oxygen, or sulfur, or a 5-6 membered monocyclic heteroaryl ring having 1-4 heteroatoms independently selected from nitrogen, oxygen, or sulfur; each of which is optionally substituted; m is 1; n is 1, 2, or 3; and p is 1, or 2.