• + 0 comments
    # Enter your code here. Read input from STDIN. Print output to STDOUT
    from sklearn.linear_model import LinearRegression
    from sklearn.preprocessing import PolynomialFeatures
    
    F,N= map(int ,input().split())
    x=[]
    y=[]
    
    for _ in range(N):
        data=list(map(float ,input().split()))
        x.append(data[:-1])
        y.append(data[-1])
        
        
    T=int(input())
    x_test=[]
    for _ in range(T):
        data=list(map(float ,input().split()))
        x_test.append(data)
        
    poly = PolynomialFeatures(degree=3)
    
    xpoly=poly.fit_transform(x)
    x_testpoly=poly.transform(x_test)
    
    model =LinearRegression()
    model.fit(xpoly,y)
    
    predicted=model.predict(x_testpoly)
    
    for p in predicted:
        print(str(round(p,2)))