// Arup Guha
// 11/5/2016
// Solution to SER 2016 Division II Problem A: Barbells

import java.util.*;

public class barbells {

	public static int numBars;
	public static int numWeights;
	public static int[] bars;
	public static int[] weights;

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);
		numBars = stdin.nextInt();
		numWeights = stdin.nextInt();

		// Read in bars.
		bars = new int[numBars];
		for (int i=0; i<numBars; i++)
			bars[i] = stdin.nextInt();

		// Read in weights.
		weights = new int[numWeights];
		for (int i=0; i<numWeights; i++)
			weights[i] = stdin.nextInt();

		// Store all possible subsets of weights.
		pair[] totals = new pair[1<<numWeights];

		// Go through each subset.
		for (int mask=0; mask<(1<<numWeights); mask++) {

			// Calculate each total.
			int total = 0;
			for (int i=0; i<numWeights; i++)
				if ((mask & (1<<i)) > 0)
					total += weights[i];

			// Store each subset with its total weight.
			totals[mask] = new pair(mask, total);
		}
		
		// Sort it!
		Arrays.sort(totals);

		TreeSet<Integer> all = new TreeSet<Integer>();
		for (int x=0; x<numBars; x++)
			all.add(bars[x]);

		// Try each pair of masks.
		int i=0;
		while(i<totals.length) {

			// Go to next unique weight.
			int j = i;
			while (j<totals.length && totals[j].total == totals[i].total) j++;

			// Match up equal weights.
			boolean flag = false;
			for (int x=i; x<j; x++) {
				for (int y=x+1; y<j; y++) {
					
					// This is key, we want nothing shared.
					if ((totals[x].mask & totals[y].mask) == 0)
						flag = true;
					if (flag) break;
				}
				if (flag) break;
			}

			// Ta da!
			if (flag) {
				for (int x=0; x<numBars; x++)
					all.add(bars[x] + 2*totals[i].total);
			}
			
			// Go to next.
			i = j;
		}

		// Now print in order.
		while (all.size() > 0) {
			System.out.println(all.pollFirst());
		}
	}
}

class pair implements Comparable<pair> {

	public int mask;
	public int total;

	public pair(int a, int b) {
		mask = a;
		total = b;
	}

	public int compareTo(pair other) {
		return this.total - other.total;
	}
}