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, -Z-C 3-6 cycloalkyl, halogen, haloC 1-6 alkyl, C 1-6 alkoxy, haloC 1-6 alkoxy, -Z-phenyl, -Z-Het, -CN, -CONR 6 R 7,-NR 6 R 7, -Z-C 1-3 alkyl, 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 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-phenyl or one -Z-Het group; Z represents a bond or a linker selected from -O-, -CH 2 -, -CH 2 -O- 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 or -NR 6 R 7; m represents an integer selected from 0 to 2; 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; p represents an integer from 0 to 3; each R 5 independently represents C 1-3 alkyl or fluoro; Y represents -CH 2 - or -(CH 2) 2 -; q represents an integer selected from 0 to 2; and R 9 represents C 1-3 alkyl. 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, -Z-C 3-6 cycloalkyl, halogen, haloC 1-6 alkyl, C 1-6 alkoxy, haloC 1-6 alkoxy, -Z-phenyl, -Z-Het, -CN, -CONR 6 R 7,-NR 6 R 7, -Z-C 1-3 alkyl, 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 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-phenyl or one -Z-Het group; Z represents a bond or a linker selected from -O-, -CH 2 -, -CH 2 -O- 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 or -NR 6 R 7; m represents an integer selected from 0 to 2; 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; p represents an integer from 0 to 3; each R 5 independently represents C 1-3 alkyl or fluoro; Y represents -CH 2 - or -(CH 2) 2 -; q represents an integer selected from 0 to 2; and R 9 represents C 1-3 alkyl.