import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m = sc.nextInt();
int sumA = 0;
// a数组之和
for (int i = 0; i < n; i++) {
sumA += sc.nextInt();
}
// 将b数组存储起来
int[] b = new int[m];
for (int i = 0; i < m; i++) {
b[i] = sc.nextInt();
}
// 只有一个的时候直接输出
if (m == 1) {
for (int i = 0; i < m; i++) {
System.out.print(b[i] + " ");
}
} else {
int endIndex = 0; // 结束的下标
int beginIndex = 0; // 开始的下标
int sub = Math.abs(b[0] - sumA); // 给一个默认初始化的值
for (int i = 0; i < m; i++) {
int sum = 0; // 每一次都需要归0,重新计算
for (int j = i; j < m; j++) {
sum += b[j]; // 计算子数组之和
int num = Math.abs(sum - sumA);
if (num < sub) {
sub = num;
beginIndex = i;
endIndex = j;
}
}
}
// 输出最后的子数组
for (int i = beginIndex; i < endIndex + 1; i++) {
System.out.print(b[i] + " ");
}
}
}
}