Extracting resources and renewable energy from waste