The sum of a certain infinite geometric series is 2. The sum of the squares of all the terms is 4. Find the common ratio.