Looking Up

A problem from the 2000 Moscow Mathematical Olympiad:

Some of the cards in a deck are face down and some are face up. From time to time Pete draws out a group of one or more contiguous cards in which the first and last are both face down. He turns over this group as a unit and returns it to the deck in the position from which he drew it. Prove that eventually all the cards in the deck will be face up, no matter how Pete proceeds.

Click for Answer