Measurement of analyzing powers of pi+ and pi- produced on a hydrogen and a carbon target with a 22-GeV/c incident polarized proton beam