The benchmark indices posted their strongest monthly gains since 2020 on Monday, supported by record foreign investment inflows.