Riyad as-Salihin
Ibn 'Umar (May Allah be pleased with them) said: The Messenger of Allah (ﷺ) said, "If Allah afflicts punishment upon a nation, it befalls the whole population indiscriminately and then they will be resurrected and judged according to their deeds."
[Al- Bukhari and Muslim].
وعن ابن عمر رضي الله عنهما قال : قال رسولُ اللهِ : « إذَا أنْزَلَ اللهُ تَعَالَى بِقَومٍ عَذَاباً ، أصَابَ العَذَابُ مَنْ كَانَ فِيهِمْ ، ثُمَّ بُعِثُوا عَلَى أَعْمَالِهِمْ » . متفق عليه .
Reference