For years , Indian security and investigation agencies have had a trite , almost comically knee-jerk explanation for terror attacks -- they have been blamed on Islamist fundamentalists aided by " foreign elements , " meaning mostly Pakistan and China .