Main solution