def matrix_vector_dot_product(matrix, vector):
# 补全代码
# 判断矩阵是否为空
if not matrix or not vector:
return -1
# 矩阵的列数
num_cols = len(matrix[0])
# 向量的长度
vec_len = len(vector)
# 如果列数不等于向量长度,返回 -1
if num_cols != vec_len:
return -1
# 逐行计算点积
result = []
for row in matrix:
# 如果行长度不一致,也算非法,返回 -1
if len(row) != num_cols:
return -1
dot = sum(row[i] * vector[i] for i in range(vec_len))
result.append(dot)
return result
# 主程序
if __name__ == "__main__":
# 输入矩阵和向量
matrix_input = input()
vector_input = input()
# 处理输入
import ast
matrix = ast.literal_eval(matrix_input)
vector = ast.literal_eval(vector_input)
# 调用函数计算点积
output = matrix_vector_dot_product(matrix, vector)
# 输出结果
print(output)