#include <fstream>
#include <vector>


using namespace std;

int main()
{
	ifstream input("dathuc.inp");
	ofstream output("dathuc.out");

	int n, m;
	input >> n >> m;
	vector <long long> a(n + 1);
	vector <long long> b(m + 1);

	for (int i = 0; i <= n; i++)
	{
		input >> a[i];
	}
	for (int i = 0; i <= m; i++)
	{
		input >> b[i];
	}
	bool end = false;
	if (n >= m)
	{
		output << n << '\n';
		for (int i = m; i >= 0; i--)
		{
			a[i + n - m] += b[i];
		}
		for (int i = 0; i <= n; i++)
		{
			if (a[i] != 0 && end == false)
			{
				end = true;
				output << a[i] << ' ';
			}		
		}
	}
	else
	{
		output << m << '\n';
		for (int i = n; i >= 0; i--)
		{
			b[i + m - n] += a[i];
		}
		for (int i = 0; i <= m; i++)
		{
			if (b[i] != 0 && end == false)
			{
				end = true;
				output << b[i] << ' ';
			}
		}
	}
	input.close();
	output.close();
	return 0;
}
