Memory Config

iMac arriving soon after 20+ years of Windows. It's coming with 4Gb and I have been given 2 x 4Gb SODIMMS from a mates memory upgrade to 16Gb, so that would be 12Gb question i have is I also have 1 x 4Gb SODIMM at home from an old laptop if I use that instead of one of the 2Gb would that work to give me 14Gb or do that all have to match?