How did the Spanish-American War affect both the Philippines and Cuba?