from typing import List


def nifs3_m(x: List[float], y: List[float] ) -> List[float]:
    """Funkcja generująca wartości momentów NIFS3.

    Parameters
    ----------
    x : List[float]
        Wartości na osi X.
    y : List[float]
        Wartości na osi Y.

    Returns
    -------
    List[float]
        Momenty NIFS3.

    """
    tmp = lambda x1, x2, y1, y2: (y2-y1) / (x2-x1)
    tmp2 = lambda x1, x2, x3, y1, y2, y3: (tmp(x2, x3, y2, y3)-tmp(x1, x2, y1, y2)) / (x3-x1)
    n = len(x)-1
    h = [0.0] + [x[i]-x[i-1] for i in range(1, n+1)]
    lam = [0.0] + [h[i] / (h[i]+h[i+1]) for i in range(1, n)]
    d = [0.0] + [6.0*tmp2(x[i], x[i+1], x[i+2], y[i], y[i+1], y[i+2]) for i in range(0, n-1)]

    q = [0.0]
    p = [0.0]
    u = [0.0]
    for i in range(1, n):
        p.append(lam[i]*q[i-1] + 2)
        q.append((lam[i]-1) / p[i])
        u.append((d[i] - lam[i]*u[i-1]) / p[i])
    
    M = [0.0 for i in range(n+1)]
    M[n-1] = u[n-1]
    for k in range(2, n-1):
        i = n-k
        M[i] = u[i] + q[i]*M[i+1]
    
    return M