def has_valid_dimension(l, d=None):
    """Check congruent dimensions in a two-dimensional list."""
    if not l:
        return False

    if d is None:
        d = len(l[0])

    for sub in l:
        if len(sub) != d:
            return False

    return True