The second main theorem for moving targets