Added main logic to solve input