• + 0 comments
    #python
    import numpy as np
    m, n=map(int, input().split())
    Y, X, res=[], [], []
    for _ in range(n):
        temp=list(map(float, input().split()))
        Y.append(temp[-1])
        temp.pop()
        X.append([1.0] + temp)
    Xtranspose=np.transpose(X)
    coeffset=np.dot(np.dot(np.linalg.inv(np.dot(Xtranspose, X)), Xtranspose), Y)
    q=int(input())
    for x in range(q):
        s=coeffset[0]
        temp=list(map(float, input().split()))
        for i in range(m):
            s+=temp[i]*coeffset[i+1]
        res.append(s)
    print(*res, sep='\n')