Heteroarylpiperidine and -piperazine derivatives of the formula (I) in which the symbols A, X, Y, L 1 , L 2 , G, Q, p, R 1 , R 2 and R 10 are each as defined in the description, and salts, metal complexes and N-oxides of the compounds of the formula (I), and the use thereof for controlling phytopathogenic harmful fungi and processes for preparing compounds of the formula (I).