Does a long term capital loss offset capital gains distributions or short term capital gain first?

For a given tax year, if you have a short term capital gain of $1,000, a long term capital loss of $3,000 and capital gains distributions of $5,000, can the long term capital loss offset the short term capital gain or does it offset the capital gains distributions?

Thanks.
4 answers 4