A compound of formula or a pharmaceutically acceptable salt thereof: wherein: Ring A represents a phenyl ring, a 5- or 6-membered aromatic heterocyclic ring or a 5- to 12-membered aromatic or non-aromatic bicyclic heterocyclic group; n represents an integer selected from 0 to 4; each R 1 independently represents C 1-6 alkyl, C 2-6 alkenyl, C 2-6 alkynyl, halogen, haloC 1-6 alkyl, C 1-6 alkoxy, -CH 2 -C 1-6 alkoxy, haloC 1-6 alkoxy, -C(=O)-C 1-6 alkyl, -Z-C 3-8 cycloalkyl, -Z-phenyl, -Z-Het, -SO 2 C 1-6 alkyl, -CN, -OH, -CONR 6 R 7, -NR 6 R 7, wherein said Het group represents a 5- or 6-membered aromatic heterocyclic ring or a 4- to 7-membered non-aromatic heterocyclic ring, wherein said C 3-8 cycloalkyl, phenyl or Het group of R 1 may be optionally substituted by one or more (e.g. 1, 2 or 3) R 8 groups and wherein n represents an integer greater than 1, said R 1 groups represent no more than one -Z-C 3-8 cycloalkyl or one-Z-phenyl or one -Z-Het group; Z represents a bond or a linker selected from -O-, -CH 2 -, -CH 2 -O-, -OCH(CH 3)- or -O-CH 2 -; R 6 and R 7 independently represent hydrogen or C 1-6 alkyl or R 6 and R 7 together with the nitrogen atom to which they are attached join to form a 4- to 7-membered nitrogen containing non-aromatic heterocyclic ring; R 8 represents C 1-6 alkyl, C 2-6 alkenyl, C 2-6 alkynyl, halogen, haloC 1-6 alkyl, C 1-6 alkoxy, haloC 1-6 alkoxy, -CN, -NR 6 R 7 or =O; m represents an integer selected from 0 to 3; each R 2 independently represents C 1-6 alkyl, C 2-6 alkenyl, C 2-6 alkynyl, halogen, haloC 1-6 alkyl, C 1-6 alkoxy, haloC 1-6 alkoxy, -CN or -NR 7 R 8; R 3 represents hydrogen or C 1-6 alkyl; R 4 represents hydrogen or C 1-6 alkyl; each R 5 independently represents C 1-3 alkyl or fluoro; each R 9 independently represents C 1-3 alkyl; Y represents -CH 2 - or -(CH 2) 2 -; and p and q independently represent an integer from 0 to 3. Ring A represents a phenyl ring, a 5- or 6-membered aromatic heterocyclic ring or a 5- to 12-membered aromatic or non-aromatic bicyclic heterocyclic group; n represents an integer selected from 0 to 4; each R 1 independently represents C 1-6 alkyl, C 2-6 alkenyl, C 2-6 alkynyl, halogen, haloC 1-6 alkyl, C 1-6 alkoxy, -CH 2 -C 1-6 alkoxy, haloC 1-6 alkoxy, -C(=O)-C 1-6 alkyl, -Z-C 3-8 cycloalkyl, -Z-phenyl, -Z-Het, -SO 2 C 1-6 alkyl, -CN, -OH, -CONR 6 R 7, -NR 6 R 7, wherein said Het group represents a 5- or 6-membered aromatic heterocyclic ring or a 4- to 7-membered non-aromatic heterocyclic ring, wherein said C 3-8 cycloalkyl, phenyl or Het group of R 1 may be optionally substituted by one or more (e.g. 1, 2 or 3) R 8 groups and wherein n represents an integer greater than 1, said R 1 groups represent no more than one -Z-C 3-8 cycloalkyl or one-Z-phenyl or one -Z-Het group; Z represents a bond or a linker selected from -O-, -CH 2 -, -CH 2 -O-, -OCH(CH 3)- or -O-CH 2 -; R 6 and R 7 independently represent hydrogen or C 1-6 alkyl or R 6 and R 7 together with the nitrogen atom to which they are attached join to form a 4- to 7-membered nitrogen containing non-aromatic heterocyclic ring; R 8 represents C 1-6 alkyl, C 2-6 alkenyl, C 2-6 alkynyl, halogen, haloC 1-6 alkyl, C 1-6 alkoxy, haloC 1-6 alkoxy, -CN, -NR 6 R 7 or =O; m represents an integer selected from 0 to 3; each R 2 independently represents C 1-6 alkyl, C 2-6 alkenyl, C 2-6 alkynyl, halogen, haloC 1-6 alkyl, C 1-6 alkoxy, haloC 1-6 alkoxy, -CN or -NR 7 R 8; R 3 represents hydrogen or C 1-6 alkyl; R 4 represents hydrogen or C 1-6 alkyl; each R 5 independently represents C 1-3 alkyl or fluoro; each R 9 independently represents C 1-3 alkyl; Y represents -CH 2 - or -(CH 2) 2 -; and p and q independently represent an integer from 0 to 3.