def read_matrix(matrix, m_file):
    """Read 1+n lines from given file, n is read from the first line.
    Write n rows of n floats to the matrix."""

    n = 0
    with open(m_file, "r") as f:
        first_line = f.readline()
        n = int(first_line);
        for i in range(n):
            line = f.readline()
            matrix.append([float(x) for x in line.split()])
    return n