Impurity spin dynamics in 2D antiferromagnets and superconductors