Fred had had had but Tom had had had had had had had been right. This sentence is grammatically 100 % right but there are missing a few ,s and "s. Now it's to you to place them at the right places. Good luck!