The present invention provides compounds of the general formula (I), their salts and N-oxides, and solvates and prodrugs thereof (wherein the substituents are as defined in the description). The compounds of the general formula (I) are inhibitors of factor XIa, and are useful in the prevention of and/or therapy for thromboembolic diseases.