from typing import List
from typing import Tuple


def bell_value(
        wsr: List[List[int]],
        raw_bits: List[List[int]]
) -> Tuple[float, float, float]:
    """Calculate the bell values.

    Args:
        wsr: WSR used to calculate the raw bits.
        raw_bits: Random bits used to calculate the bell values.

    Returns:
        A tuple of Mermin losing probability, winning probability, and correlator.
    """
    losing_prob = 0
    for i in range(len(wsr)):   # pylint: disable=consider-using-enumerate
        wsr_sum = sum(wsr[i])
        raw_bits_sum = sum(raw_bits[i])
        if wsr_sum == 1 and raw_bits_sum % 2 == 1:
            losing_prob += 1
        elif wsr_sum == 3 and raw_bits_sum % 2 == 0:
            losing_prob += 1
    losing_prob = losing_prob / len(wsr)
    winning_prob = 1 - losing_prob
    correlator = 4-16*losing_prob

    return losing_prob, winning_prob, correlator