from typing import Dict
from typing import Any
from typing import Iterable


def check_same_and_different(a: Dict[str, Any], b: Dict[str, Any],
                            same: Iterable[str], different: Iterable[str]) -> bool:
    """Return true iff for all properties in same that are in a, they
    exist in b and have the same value, and for all properties in
    different that are in a, they exist in b and are different.
    """
    same_ok = True
    for prop in same:
        if prop in a:
            if prop not in b or a[prop] != b[prop]:
                same_ok = False
                break
    if not same_ok:
        return False
    diff_ok = True
    for prop in different:
        if prop in a:
            if prop not in b or a[prop] == b[prop]:
                diff_ok = False
                break
    return diff_ok