from typing import Generator
from typing import Tuple


def get_capacities_and_distinct_transports(transports_data: Generator[dict, None, None]) -> Tuple[dict, dict]:
    """
    Returns two dicts with total capacities for each type of transport and
    counts of each distinct models for each type of transport.

    Car total capacity: passenger-capacity value
    Train total capacity: number-wagons * w-passenger-capacity
    Plane total capacity: b-passenger-capacity + e-passenger-capacity
    """

    unique_car_models = set()
    unique_train_models = set()
    unique_plane_models = set()

    cars_total_capacity = 0
    trains_total_capacity = 0
    planes_total_capacity = 0

    for transport in transports_data:
        # Lowercase for all the keys in the transport dict
        transport = dict((k.lower(), v) for k, v in transport.items())

        is_car = 'manufacturer' and 'passenger-capacity' in transport.keys()
        is_train = 'number-wagons' and 'w-passenger-capacity' in \
            transport.keys()
        is_plane = 'b-passenger-capacity' and 'e-passenger-capacity' in \
            transport.keys()

        if is_car:
            unique_car_models.add(transport['model'])
            cars_total_capacity += transport['passenger-capacity']
        elif is_train:
            unique_train_models.add(transport['model'])
            trains_total_capacity += transport['number-wagons'] * \
                transport['w-passenger-capacity']
        elif is_plane:
            unique_plane_models.add(transport['model'])
            planes_total_capacity += transport['b-passenger-capacity'] + \
                transport['e-passenger-capacity']

    capacities = {
        'cars': cars_total_capacity,
        'trains': trains_total_capacity,
        'planes': planes_total_capacity
    }

    distinct_transports = {
        'distinct-cars': len(unique_car_models),
        'distinct-trains': len(unique_train_models),
        'distinct-planes': len(unique_plane_models)
    }

    return capacities, distinct_transports