Oscillation theorems for primes in arithmetic progressions and for sifting functions