The present invention provides compounds of formula (I) and pharmaceutically acceptable salts thereof, wherein R1, X, m, R2, Y, R3, Z, n, R4, A and B are as defined in the specification, processes for their preparation, pharmaceutical compositions containing them and their use in therapy.