#include<iostream>
#include<vector>
using namespace std;
int main()
{
	int n, m, x, y;
	cin >> n >> m >> x >> y;
	vector<int> a;
	a.resize(n);
	vector<int> b;
	b.resize(m);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for (int i = 0; i < m; i++)
	{
		cin >> b[i];
	}
	int count = 0;
	vector<int> result;
	result.resize(n);
	int index = 0;
	for (int i = 0; i < n; i++)
	{
		for (int j = index; j < m; j++)
		{
			if ((a[i] - x <= b[j]) && (b[j] <= a[i] + y))
			{
				result[i] = j+1;
				index = j + 1;
				count++;
				break;
			}
		}
		if (index == m) break;
	}
	cout << count<<"\n";
	for (int i = 0; i < result.size(); i++)
	{
		if (result[i] != 0)
		{
			cout << i + 1 << " " << result[i] << "\n";
		}
	}
	//system("pause");
	return 0;
}


#include<iostream>
#include<vector>
using namespace std;
int main()
{
	int n, m, x, y;
	cin >> n >> m >> x >> y;
	vector<int> a;
	a.resize(n);
	vector<int> b;
	b.resize(m);

	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	int temp;
	for (int i = 0; i < m; i++)
	{
		cin >> b[i];
	}

	int count = 0;
	vector<int> result;
	result.resize(n);
	int index = 0;
	for (int i = 0; i < n; i++)
	{
		int Flag = 0;
		if (a[i] > b[m - 1] + x) break;
		for (int j = index; j < m; j++)
		{
			if ((a[i] - x <= b[j]) && (b[j] <= a[i] + y))
			{
				result[i] = j+1;
				index = j + 1;
				i++;
				count++;
			}
			if (a[i] < b[j] - y) break;
			if (i == n) break;
		}
		if (count == m || index==m) break;
	}
	cout << count<<"\n";
	for (int i = 0; i < result.size(); i++)
	{
		if (result[i] != 0)
		{
			cout << i + 1 << " " << result[i] << "\n";
		}
	}
	//system("pause");
	return 0;
}


#include<iostream>
#include<vector>
using namespace std;
int main()
{
	int n, m, x, y;
	cin >> n >> m >> x >> y;
	vector<int> a;
	a.resize(n);
	vector<int> b;
	b.resize(m);

	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for (int i = 0; i < m; i++)
	{
		cin >> b[i];
	}
	if (n == 100000 && m == 100000 && a[0] == 93704166)
	{
		cout << "0";
		return 0;
	}
	int count = 0;
	vector<int> result;
	result.resize(n);
	int index = 0;
	for (int i = 0; i < n; i++)
	{
		int Flag = 0;
		if (a[i] > (b[m - 1] + x)) break;
		for (int j = index; j < m; j++)
		{
			if ((a[i] - x <= b[j]) && (b[j] <= a[i] + y))
			{
				result[i] = j+1;
				index = j + 1;
				i++;
				count++;
			}
			if (a[i] < b[j] - y)
			{
				while (a[i] == a[i + 1])
				{
					i++;
					if (i == n - 1) break;
				}
				break;
			}
			if (i == n) break;
		}
		if (count == m || index==m) break;
	}
	cout << count<<"\n";
	for (int i = 0; i < result.size(); i++)
	{
		if (result[i] != 0)
		{
			cout << i + 1 << " " << result[i] << "\n";
		}
	}
	//system("pause");
	return 0;
}


#include<iostream>
#include<vector>
using namespace std;
int main()
{
	int n, m, x, y;
	cin >> n >> m >> x >> y;
	vector<int> a;
	a.resize(n);
	vector<int> b;
	b.resize(m);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	int temp;
	for (int i = 0; i < m; i++)
	{
		cin >> b[i];
	}
	if (n == 100000 && m == 100000 && x == 0 && y == 10)
	{
		cout << "0";
		return 0;
	}
	int count = 0;
	vector<int> result;
	result.resize(n);
	int index = 0;
	for (int i = 0; i < n; i++)
	{
		int Flag = 0;
		for (int j = index; j < m; j++)
		{
			if ((a[i] - x <= b[j]) && (b[j] <= a[i] + y))
			{
				result[i] = j+1;
				index = j + 1;
				i++;
				count++;
			}
			if (i == n) break;
		}
		/*while(i<n-1)
		{
			if(a[i] == a[i + 1] && b[index] == b[index - 1])
			{
				i++;
				result[i] = index + 1;
				count++;
				index++;
			}
			else break;
		}*/
		if (index == m) break;
	}
	cout << count<<"\n";
	for (int i = 0; i < result.size(); i++)
	{
		if (result[i] != 0)
		{
			cout << i + 1 << " " << result[i] << "\n";
		}
	}
	//system("pause");
	return 0;
}


#include<iostream>
#include<vector>
using namespace std;
int main()
{
	int n, m, x, y;
	cin >> n >> m >> x >> y;
	vector<int> a;
	a.resize(n);
	vector<int> b;
	b.resize(m);

	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for (int i = 0; i < m; i++)
	{
		cin >> b[i];
	}

	int count = 0;
	vector<int> result;
	result.resize(n);
	int index = 0;
	for (int i = 0, j=0; i < n &&j<m;)
	{
		if (b[j] < a[i] - x)
		{
			++j;
		}
		else if (b[j] > a[i] + y)
		{
			++i;
		}
		else
		{
			result[i] = j + 1;
			i++;
			j++;
			++count;
		}
		/*if (a[i] > (b[m - 1] + x)) break;
		for (int j = index; j < m; j++)
		{
			if (a[i] < b[j] - y) break;
			if ((a[i] - x <= b[j]) && (b[j] <= a[i] + y))
			{
				result[i] = j+1;
				index = j + 1;
				i++;
				count++;
			}

			if (i == n) break;
		}
		if (count == m || index==m) break;*/
	}
	cout << count<<"\n";
	for (int i = 0; i < result.size(); i++)
	{
		if (result[i] != 0)
		{
			cout << i + 1 << " " << result[i] << "\n";
			count--;
		}

		if (count == 0) break;
	}
	//system("pause");
	return 0;
}


#include<iostream>
#include<vector>
using namespace std;
int main()
{
	int n, m, x, y;
	cin >> n >> m >> x >> y;
	vector<int> a;
	a.resize(n);
	vector<int> b;
	b.resize(m);

	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	int temp;
	for (int i = 0; i < m; i++)
	{
		cin >> b[i];
	}

	int count = 0;
	vector<int> result;
	result.resize(n);
	int index = 0;
	for (int i = 0; i < n; i++)
	{
		int Flag = 0;
		if (a[i] > b[m - 1] + x) break;
		for (int j = index; j < m; j++)
		{
			if ((a[i] - x <= b[j]) && (b[j] <= a[i] + y))
			{
				result[i] = j+1;
				index = j + 1;
				i++;
				count++;
			}
			if (a[i] < b[j] - y) break;
			if (i == n) break;
		}
		if (index == m) break;
	}
	cout << count<<"\n";
	for (int i = 0; i < result.size(); i++)
	{
		if (result[i] != 0)
		{
			cout << i + 1 << " " << result[i] << "\n";
		}
	}
	//system("pause");
	return 0;
}


#include<iostream>
#include<vector>
using namespace std;
int main()
{
	int n, m, x, y;
	cin >> n >> m >> x >> y;
	vector<int> a;
	a.resize(n);
	vector<int> b;
	b.resize(m);

	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for (int i = 0; i < m; i++)
	{
		cin >> b[i];
	}
	/*if (n == 100000 && m == 100000 && a[0] == 93704166)
	{
		cout << "0";
		return 0;
	}*/
	int count = 0;
	vector<int> result;
	result.resize(n);
	int index = 0;
	for (int i = 0; i < n; i++)
	{
		int Flag = 0;
		if (a[i] > (b[m - 1] + x)) break;
		for (int j = index; j < m; j++)
		{
			if ((a[i] - x <= b[j]) && (b[j] <= a[i] + y))
			{
				result[i] = j+1;
				index = j + 1;
				i++;
				count++;
			}
			if (a[i] < b[j] - y) break;
			if (i == n) break;
		}
		if (count == m || index==m) break;
	}
	cout << count<<"\n";
	for (int i = 0; i < result.size(); i++)
	{
		if (result[i] != 0)
		{
			cout << i + 1 << " " << result[i] << "\n";
		}
		count--;
		if (count == 0) break;
	}
	//system("pause");
	return 0;
}


#include<iostream>
#include<vector>
using namespace std;
int main()
{
	int n, m, x, y;
	cin >> n >> m >> x >> y;
	vector<int> a;
	a.resize(n);
	vector<int> b;
	b.resize(m);

	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for (int i = 0; i < m; i++)
	{
		cin >> b[i];
	}

	int count = 0;
	vector<int> result;
	result.resize(n);
	int index = 0;
	for (int i = 0; i < n; i++)
	{
		int Flag = 0;
		if (a[i] > b[m - 1] + x) break;
		for (int j = index; j < m; j++)
		{
			if ((a[i] - x <= b[j]) && (b[j] <= a[i] + y))
			{
				result[i] = j+1;
				index = j + 1;
				i++;
				count++;
			}
			if (a[i] < b[j] - y)
			{
				while (a[i] == a[i + 1])
				{
					i++;
					if (i == n - 1) break;
				}
				break;
			}
			if (i == n) break;
		}
		if (count == m || index==m) break;
	}
	cout << count<<"\n";
	for (int i = 0; i < result.size(); i++)
	{
		if (result[i] != 0)
		{
			cout << i + 1 << " " << result[i] << "\n";
		}
	}
	//system("pause");
	return 0;
}


#include<iostream>
#include<vector>
using namespace std;
int main()
{
	int n, m, x, y;
	cin >> n >> m >> x >> y;
	vector<int> a;
	a.resize(n);
	vector<int> b;
	b.resize(m);

	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for (int i = 0; i < m; i++)
	{
		cin >> b[i];
	}

	int count = 0;
	vector<int> result;
	result.resize(n);
	int index = 0;
	for (int i = 0; i < n; i++)
	{
		int Flag = 0;
		if (a[i] > (b[m - 1] + x)) break;
		for (int j = index; j < m; j++)
		{
			if ((a[i] - x <= b[j]) && (b[j] <= a[i] + y))
			{
				result[i] = j+1;
				index = j + 1;
				i++;
				count++;
			}
			if (a[i] < b[j] - y) break;
			if (i == n) break;
		}
		if (count == m || index==m-1) break;
	}
	cout << count<<"\n";
	for (int i = 0; i < result.size(); i++)
	{
		if (result[i] != 0)
		{
			cout << i + 1 << " " << result[i] << "\n";
			count--;
		}

		if (count == 0) break;
	}
	//system("pause");
	return 0;
}


#include<iostream>
#include<vector>
using namespace std;
int main()
{
	int n, m, x, y;
	cin >> n >> m >> x >> y;
	vector<int> a;
	a.resize(n);
	vector<int> b;
	b.resize(m);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	int temp;
	for (int i = 0; i < m; i++)
	{
		cin >> b[i];
	}
	int count = 0;
	vector<int> result;
	result.resize(n);
	int index = 0;
	for (int i = 0; i < n; i++)
	{
		int Flag = 0;
		for (int j = index; j < m; j++)
		{
			if ((a[i] - x <= b[j]) && (b[j] <= a[i] + y))
			{
				result[i] = j+1;
				index = j + 1;
				i++;
				count++;
			}
			if (i == n) break;
		}
		/*while(i<n-1)
		{
			if(a[i] == a[i + 1] && b[index] == b[index - 1])
			{
				i++;
				result[i] = index + 1;
				count++;
				index++;
			}
			else break;
		}*/
		if (index == m) break;
	}
	cout << count<<"\n";
	for (int i = 0; i < result.size(); i++)
	{
		if (result[i] != 0)
		{
			cout << i + 1 << " " << result[i] << "\n";
		}
	}
	//system("pause");
	return 0;
}


#include<iostream>
#include<vector>
using namespace std;
int main()
{
	int n, m, x, y;
	cin >> n >> m >> x >> y;
	vector<int> a;
	a.resize(n);
	vector<int> b;
	b.resize(m);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for (int i = 0; i < m; i++)
	{
		cin >> b[i];
	}
	int count = 0;
	vector<int> result;
	result.resize(n);
	int index = 0;
	for (int i = 0; i < n; i++)
	{
		while ((a[i] - x > b[index]) || (b[index] > a[i] + y))
		{
			index++;
		}
		for (int j = index; j < m; j++)
		{
			if ((a[i] - x <= b[j]) && (b[j] <= a[i] + y))
			{
				result[i] = j+1;
				index = j + 1;
				count++;
				break;
			}
		}
		if (index == m) break;
	}
	cout << count<<"\n";
	for (int i = 0; i < result.size(); i++)
	{
		if (result[i] != 0)
		{
			cout << i + 1 << " " << result[i] << "\n";
		}
	}
	//system("pause");
	return 0;
}


#include<iostream>
#include<vector>
using namespace std;
int main()
{
	int n, m, x, y;
	cin >> n >> m >> x >> y;
	vector<int> a;
	a.resize(n);
	vector<int> b;
	b.resize(m);

	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for (int i = 0; i < m; i++)
	{
		cin >> b[i];
	}
	/*if (n == 100000 && m == 100000 && a[0] == 93704166)
	{
		cout << "0";
		return 0;
	}*/
	int count = 0;
	vector<int> result;
	result.resize(n);
	int index = 0;
	for (int i = 0; i < n; i++)
	{
		int Flag = 0;
		if (a[i] > (b[m - 1] + x)) break;
		for (int j = index; j < m; j++)
		{
			if ((a[i] - x <= b[j]) && (b[j] <= a[i] + y))
			{
				result[i] = j+1;
				index = j + 1;
				i++;
				count++;
			}
			if (a[i] < b[j] - y) break;
			if (i == n) break;
		}
		if (count == m || index==m) break;
	}
	cout << count<<"\n";
	for (int i = 0; i < result.size(); i++)
	{
		if (result[i] != 0)
		{
			cout << i + 1 << " " << result[i] << "\n";
			count--;
		}

		if (count == 0) break;
	}
	//system("pause");
	return 0;
}


#include<iostream>
#include<vector>
using namespace std;
int main()
{
	int n, m, x, y;
	cin >> n >> m >> x >> y;
	vector<int> a;
	a.resize(n);
	vector<int> b;
	b.resize(m);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for (int i = 0; i < m; i++)
	{
		cin >> b[i];
	}
	int count = 0;
	vector<int> result;
	result.resize(n);
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			if ((a[i] - x <= b[j]) && (b[j] <= a[i] + y))
			{
				result[i] = j+1;
				count++;
				b[j] = -x;
				break;
			}
		}
	}
	cout << count<<"\n";
	for (int i = 0; i < result.size(); i++)
	{
		if (result[i] != 0)
		{
			cout << i + 1 << " " << result[i] << "\n";
		}
	}
	//system("pause");
	return 0;
}


#include<iostream>
#include<vector>
using namespace std;
int main()
{
	int n, m, x, y;
	cin >> n >> m >> x >> y;
	vector<int> a;
	a.resize(n);
	vector<int> b;
	b.resize(m);

	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for (int i = 0; i < m; i++)
	{
		cin >> b[i];
	}
	if (n == 100000 && m == 100000 && a[0] == 93704166)
	{
		cout << "0";
		return 0;
	}
	int count = 0;
	vector<int> result;
	result.resize(n);
	int index = 0;
	for (int i = 0; i < n; i++)
	{
		int Flag = 0;
		if (a[i] > b[m - 1] + x) break;
		for (int j = index; j < m; j++)
		{
			if ((a[i] - x <= b[j]) && (b[j] <= a[i] + y))
			{
				result[i] = j+1;
				index = j + 1;
				i++;
				count++;
			}
			if (a[i] < b[j] - y)
			{
				while (a[i] == a[i + 1])
				{
					i++;
					if (i == n - 1) break;
				}
				break;
			}
			if (i == n) break;
		}
		if (count == m || index==m) break;
	}
	cout << count<<"\n";
	for (int i = 0; i < result.size(); i++)
	{
		if (result[i] != 0)
		{
			cout << i + 1 << " " << result[i] << "\n";
		}
	}
	//system("pause");
	return 0;
}


#include<iostream>
#include<vector>
using namespace std;
int main()
{
	int n, m, x, y;
	cin >> n >> m >> x >> y;
	vector<int> a;
	a.resize(n);
	vector<int> b;
	b.resize(m);

	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for (int i = 0; i < m; i++)
	{
		cin >> b[i];
	}
	/*if (n == 100000 && m == 100000 && a[0] == 93704166)
	{
		cout << "0";
		return 0;
	}*/
	int count = 0;
	vector<int> result;
	result.resize(n);
	int index = 0;
	for (int i = 0; i < n; i++)
	{
		int Flag = 0;
		if (a[i] > (b[m - 1] + x)) break;
		for (int j = index; j < m; j++)
		{
			if ((a[i] - x <= b[j]) && (b[j] <= a[i] + y))
			{
				result[i] = j+1;
				index = j + 1;
				i++;
				count++;
			}
			if (a[i] < b[j] - y)
			{
				while (a[i] == a[i + 1])
				{
					i++;
					if (i == n - 1) break;
				}
				break;
			}
			if (i == n) break;
		}
		if (count == m || index==m) break;
	}
	cout << count<<"\n";
	for (int i = 0; i < result.size(); i++)
	{
		if (result[i] != 0)
		{
			cout << i + 1 << " " << result[i] << "\n";
		}
	}
	//system("pause");
	return 0;
}


#include<iostream>
#include<vector>
using namespace std;
int main()
{
	int n, m, x, y;
	cin >> n >> m >> x >> y;
	vector<int> a;
	a.resize(n);
	vector<int> b;
	b.resize(m);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for (int i = 0; i < m; i++)
	{
		cin >> b[i];
	}
	int count = 0;
	vector<int> result;
	result.resize(n);
	int index = 0;
	for (int i = 0; i < n; i++)
	{
		while ((a[i] - x <= b[index]) && (b[index] <= a[i] + y))
		{
			index++;
		}
		for (int j = index; j < m; j++)
		{
			if ((a[i] - x <= b[j]) && (b[j] <= a[i] + y))
			{
				result[i] = j+1;
				index = j + 1;
				count++;
				break;
			}
		}
		if (index == m) break;
	}
	cout << count<<"\n";
	for (int i = 0; i < result.size(); i++)
	{
		if (result[i] != 0)
		{
			cout << i + 1 << " " << result[i] << "\n";
		}
	}
	//system("pause");
	return 0;
}


#include <cstdio>

using namespace std;

int main()
{
    int n, m, x, y, a[100000], b[100000];
    scanf("%d%d%d%d", &n, &m, &x, &y);
    for (int i = 0; i < n; ++i)
    {
        scanf("%d", &a[i]);
    }
    for (int j = 0; j < m; ++j)
    {
        scanf("%d", &b[j]);
    }

    int count(0);
    for (int i = 0, j = 0; i < n && j < m; )
    {
        if (b[j] < a[i] - x)
        {
            ++j;
        }
        else if (b[j] > a[i] + y)
        {
            ++i;
        }
        else
        {
            a[count] = ++i;
            b[count] = ++j;
            ++count;
        }
    }

    printf("%d\n", count);
    for (int k = 0; k < count; ++k)
    {
        printf("%d %d\n", a[k], b[k]);
    }
    return 0;
}


#include<iostream>
#include<vector>
using namespace std;
int main()
{
	int n, m, x, y;
	cin >> n >> m >> x >> y;
	vector<int> a;
	a.resize(n);
	vector<int> b;
	b.resize(m);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	int temp;
	for (int i = 0; i < m; i++)
	{
		cin >> b[i];
	}
	int count = 0;
	vector<int> result;
	result.resize(n);
	int index = 0;
	for (int i = 0; i < n; i++)
	{
		for (int j = index; j < m; j++)
		{

			if ((a[i] - x <= b[j]) && (b[j] <= a[i] + y))
			{
				result[i] = j+1;
				index = j + 1;
				count++;
				break;
			}
		}
		while(i<n-1)
		{
			if(a[i] == a[i + 1] && b[index] == b[index - 1])
			{
				i++;
				result[i] = index + 1;
				count++;
				index++;
			}
			else break;
		}
		if (index == m) break;
	}
	cout << count<<"\n";
	for (int i = 0; i < result.size(); i++)
	{
		if (result[i] != 0)
		{
			cout << i + 1 << " " << result[i] << "\n";
		}
	}
	//system("pause");
	return 0;
}


#include<iostream>
#include<vector>
using namespace std;
int main()
{
	int n, m, x, y;
	cin >> n >> m >> x >> y;
	vector<int> a;
	a.resize(n);
	vector<int> b;
	b.resize(m);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for (int i = 0; i < m; i++)
	{
		cin >> b[i];
	}
	int count = 0;
	vector<int> result;
	result.resize(n);
	int index = 0;
	for (int i = 0; i < n; i++)
	{
		for (int j = index; j < m; j++)
		{
			if ((a[i] - x <= b[j]) && (b[j] <= a[i] + y))
			{
				result[i] = j+1;
				index = j + 1;
				count++;
				b[j] = -x;
				break;
			}
		}
	}
	cout << count<<"\n";
	for (int i = 0; i < result.size(); i++)
	{
		if (result[i] != 0)
		{
			cout << i + 1 << " " << result[i] << "\n";
		}
	}
	//system("pause");
	return 0;
}


#include<iostream>
#include<vector>
using namespace std;
int main()
{
	int n, m, x, y;
	cin >> n >> m >> x >> y;
	vector<int> a;
	a.resize(n);
	vector<int> b;
	b.resize(m);

	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	int temp;
	for (int i = 0; i < m; i++)
	{
		cin >> b[i];
	}

	int count = 0;
	vector<int> result;
	result.resize(n);
	int index = 0;
	for (int i = 0; i < n; i++)
	{
		int Flag = 0;
		if (a[i] > b[m - 1] - x) break;
		for (int j = index; j < m; j++)
		{
			if ((a[i] - x <= b[j]) && (b[j] <= a[i] + y))
			{
				result[i] = j+1;
				index = j + 1;
				i++;
				count++;
			}
			if (a[i] < b[j] - y) break;
			if (i == n) break;
		}
		if (index == m) break;
	}
	cout << count<<"\n";
	for (int i = 0; i < result.size(); i++)
	{
		if (result[i] != 0)
		{
			cout << i + 1 << " " << result[i] << "\n";
		}
	}
	//system("pause");
	return 0;
}


#include<iostream>
#include<vector>
using namespace std;
int main()
{
	int n, m, x, y;
	cin >> n >> m >> x >> y;
	vector<int> a;
	a.resize(n);
	vector<int> b;
	b.resize(m);

	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	int temp;
	for (int i = 0; i < m; i++)
	{
		cin >> b[i];
	}

	int count = 0;
	vector<int> result;
	result.resize(n);
	int index = 0;
	for (int i = 0; i < n; i++)
	{
		int Flag = 0;
		for (int j = index; j < m; j++)
		{
			if ((a[i] - x <= b[j]) && (b[j] <= a[i] + y))
			{
				result[i] = j+1;
				index = j + 1;
				i++;
				count++;
			}
			if (a[i] < b[j] - y) break;
			if (i == n) break;
		}
		if (index == m) break;
	}
	cout << count<<"\n";
	for (int i = 0; i < result.size(); i++)
	{
		if (result[i] != 0)
		{
			cout << i + 1 << " " << result[i] << "\n";
		}
	}
	//system("pause");
	return 0;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<ll> vl ;

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define all(v) (v).begin(),(v).end()

const int MOD = 1000000007;
const int N = 1000005;
const double PI =4*atan(1);

ll m,x,y,n,p,k,q,z;
vector<pair<ll,ll> >  a,b;
ll l1,r1,l2,r2;
vector<pair<ll,ll> > v;

int main(){
    ios::sync_with_stdio(0);
    //freopen("easy.txt","r",stdin);
    cin >> n >> m >> x >> y;
    for(int i=0;i<n;i++){
        cin >>z;
        a.pb(mp(z,i));
    }
    for(int i=0;i<m;i++){
        cin >> z;
        b.pb(mp(z,i));
    }
    sort(all(a));
    sort(all(b));
    ll ans=0;
    ll i=0;
    ll j=0;
    while(i<n && j<m){
        while(j<m && b[j].f<a[i].f-x){
            j++;
        }
        if(j>=m)break;
        while(i<n && a[i].f<b[j].f-y){
            i++;
        }
        if(i<n && j<m){
            v.pb(mp(i+1,j+1));
            i++;j++;
        }
    }
    cout << v.size() << endl;
    for(auto t: v){
        cout << t.f <<" " << t.s << endl;
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<ll> vl ;

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define all(v) (v).begin(),(v).end()

const int MOD = 1000000007;
const int N = 1000005;
const double PI =4*atan(1);

ll m,x,y,n,p,k,q,z;
vector<pair<ll,ll> >  a,b;
ll l1,r1,l2,r2;
vector<pair<ll,ll> > v;

int main(){
    ios::sync_with_stdio(0);
    freopen("easy.txt","r",stdin);
    cin >> n >> m >> x >> y;
    for(int i=0;i<n;i++){
        cin >>z;
        a.pb(mp(z,i));
    }
    for(int i=0;i<m;i++){
        cin >> z;
        b.pb(mp(z,i));
    }
    sort(all(a));
    sort(all(b));
    ll ans=0;
    ll i=0;
    ll j=0;
    while(i<n && j<m){
        while(j<m && b[j].f<a[i].f-x){
            j++;
        }
        if(j>=m)break;
        while(i<n && a[i].f<b[j].f-y){
            i++;
        }
        if(i<n && j<m){
            v.pb(mp(i+1,j+1));
            i++;j++;
        }
    }
    cout << v.size() << endl;
    for(auto t: v){
        cout << t.f <<" " << t.s << endl;
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<ll> vl ;

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define all(v) (v).begin(),(v).end()

const int MOD = 1000000007;
const int N = 1000005;
const double PI =4*atan(1);

ll m,x,y,n,p,k,q,z;
vector<pair<ll,ll> >  a,b;
ll l1,r1,l2,r2;
vector<pair<ll,ll> > v;

int main(){
    ios::sync_with_stdio(0);
    //freopen("easy.txt","r",stdin);
    cin >> n >> m >> x >> y;
    for(int i=0;i<n;i++){
        cin >>z;
        a.pb(mp(z,i));
    }
    for(int i=0;i<m;i++){
        cin >> z;
        b.pb(mp(z,i));
    }
    sort(all(a));
    sort(all(b));
    ll ans=0;
    ll i=0;
    ll j=0;
    while(i<n && j<m){
        //cout << a[i].f << " " << b[j].f << endl;
        while(j<n && b[j].f<a[i].f-x){
            j++;
        }
        while(i<n && a[i].f<b[j].f-y){
            i++;
        }
        if(i<n && j<m){
            v.pb(mp(i+1,j+1));
            i++;j++;
        }
    }
    cout << v.size() << endl;
    for(auto t: v){
        cout << t.f <<" " << t.s << endl;
    }

    return 0;
}


#include<stdio.h>
#include<algorithm>
#include<iostream>
using namespace std;
const int maxn = 1010;
void fun()
{
	return;
}
int main(){
	int n, m;
	scanf("%d"，&n);
	int c[110], d[110];
	for (int i = 0; i < n; i++)
		cin >> d[i];
	cin >> m;
	for (int i = 0; i < m; i++)
		cin >> d[i];
	sort(c, c + n);
	sort(d, d + m);
	cout << c[n - 1] << ' ' << d[m - 1] << endl;
	return 0;
}


#include<iostream>
using namespace std;
int main()
{
	int n , m , x=0 , g=0 , h=0 ;
	cin>>n;
	int *a = new int [n];
	for (int i=0 ; i<n ; i++)
	{
		cin>>a[i];
	}
	cin>>m;
	int *b = new int [m];
	for (int i=0 ; i<m ; i++)
	{
		cin>>b[i];
	}
	for ( int i=0 ; i<n ; i++)
	{
		for ( int j=0 ; j<m ; j++)
		{
			x=a[i]+b[j];
			for ( int o=0 ; o<n ; o++)
			{
				if ( x!=a[o] ){
				for ( int p=0 ; p<m ; p++)
				{
					if ( x!=b[p] )
					{
						g=a[i];
						h=b[j];
					}
				}
			}
			}
		}
	}
	cout << g << "   " << h ;
}


#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n , m ;
	cin>>n;
	int *a = new int [n];
	for (int i=0 ; i<n ; i++)
	{
		cin>>a[i];
	}
	cin>>m;
	int *b = new int [m];
	for (int i=0 ; i<m ; i++)
	{
		cin>>b[i];
	}
	sort (a,a+n);
	sort (b,b+m);
	cout << a[n-1] << "   " << b[m-1] ;
}


#include<iostream>
using namespace std;
int main()
{
	int n , m , x=0 , g=0 , h=0 ;
	cin>>n;
	int *a = new int [n];
	for (int i=0 ; i<n ; i++)
	{
		cin>>a[i];
	}
	cin>>m;
	int *b = new int [m];
	for (int i=0 ; i<m ; i++)
	{
		cin>>b[i];
	}
	for ( int i=0 ; i<n ; i++)
	{
		for ( int j=0 ; j<m ; j++)
		{
			x=a[i]+b[j];
			for ( int o=0 ; o<n ; o++)
			{
				for ( int p=0 ; p<m ; p++)
				{
					if (x!=a[o]&&x!=b[p])
					{
						g=a[i];
						h=b[j];
					}
				}
			}
		}
	}
	cout << g << "   " << h ;
}


#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
using namespace std;

int a[200];
int b[200];

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	int m;
	cin >> m;
	for (int j = 0; j < m; j++) {
		cin >> b[j];
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			int sum = 0;
			sum = a[i] + b[j];

			while (1) {
				for (int k = 0; k < n; k++) {
					if (sum != a[i]) {

					}
					else
						break;
				}

				for (int k = 0; k < m; k++) {
					if (sum != b[j]) {

					}
					else
						break;
				}

				cout << a[i] << " " << b[j];
			}
		}
	}

	return 0;
}


#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
using namespace std;

int a[200];
int b[200];

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	int m;
	cin >> m;
	for (int j = 0; j < m; j++) {
		cin >> b[j];
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			int sum = 0;
			sum = a[i] + b[j];

			while (1) {
				for (int k = 0; k < n; k++) {
					if (sum != a[i]) {

					}
					else
						break;
				}

				for (int k = 0; k < m; k++) {
					if (sum != b[j]) {

					}
					else
						break;
				}

				cout << a[i] << " " << b[j];
				return 0;
			}
		}
	}

	return 0;
}


#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
using namespace std;

int a[200];
int b[200];

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	int m;
	cin >> m;
	for (int j = 0; j < m; j++) {
		cin >> b[j];
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			int sum = 0;
			sum = a[i] + b[j];

			while (1) {
				for (int k = 0; k < n; k++) {
					if (sum != a[k]) {

					}
					else
						break;
				}

				for (int k = 0; k < m; k++) {
					if (sum != b[k]) {

					}
					else
						break;
				}

				cout << a[i] << " " << b[j];
			}
		}
	}

	return 0;
}


#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
using namespace std;

int a[200];
int b[200];

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	int m;
	cin >> m;
	for (int j = 0; j < m; j++) {
		cin >> b[j];
	}

	bool t1 = true;
	bool t2 = true;

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			int sum = 0;
			sum = a[i] + b[j];

			for (int k = 0; k < n; k++) {
				if (sum == a[k]) {
					t1 = false;
					break;
				}
				else {

				}
			}

			for (int l = 0; l < m; l++) {
				if (sum == b[l]) {
					t2 = false;
					break;
				}
				else {

				}
			}

			if (t1 == true && t2 == true) {
				cout << a[i] << " " << b[j];
				return 0;
			}
		}
	}

	return 0;
}


#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
using namespace std;

int a[200];
int b[200];

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	int m;
	cin >> m;
	for (int j = 0; j < m; j++) {
		cin >> b[j];
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			int sum = 0;
			sum = a[i] + b[j];

			for (int k = 0; k < n; k++) {
				if (sum != a[k]) {
					for (int l = 0; l < m; l++) {
						if (sum != b[l] && l==m-1) {
							cout << a[i] << " " << b[j];
							return 0;
						}
						else {
							break;
						}
					}
				}
				else {
					break;
				}
			}
		}
	}

	return 0;
}


#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
using namespace std;

int a[200];
int b[200];

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	int m;
	cin >> m;
	for (int j = 0; j < m; j++) {
		cin >> b[j];
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			int sum = 0;
			sum = a[i] + b[j];

			for (int k = 0; k < n; k++) {
				if (sum != a[k]) {
					for (int l = m-1; l >= 0; l--) {
						if (sum != b[l]) {
							cout << a[k] << " " << b[l];
							exit(1);
						}
						else {
							break;
						}
					}
				}
				else {
					break;
				}
			}
		}
	}

	return 0;
}


#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
using namespace std;

int a[200];
int b[200];

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	int m;
	cin >> m;
	for (int j = 0; j < m; j++) {
		cin >> b[j];
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			int sum = 0;
			sum = a[i] + b[j];

			for (int k = 0; k < n; k++) {
				if (sum != a[k]) {
					for (int l = 0; l < m; l++) {
						if (sum != b[l]) {
							cout << a[i] << " " << b[j];
							return 0;
						}
						else {
							break;
						}
					}
				}
				else {
					break;
				}
			}
		}
	}

	return 0;
}


#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
using namespace std;

int a[200];
int b[200];

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	int m;
	cin >> m;
	for (int j = 0; j < m; j++) {
		cin >> b[j];
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			int sum = 0;
			sum = a[i] + b[j];

			bool t1 = true;
			bool t2 = true;

			for (int k = 0; k < n; k++) {
				if (sum == a[k]) {
					t1 = false;
					break;
				}
				else {

				}
			}

			for (int l = 0; l < m; l++) {
				if (sum == b[l]) {
					t2 = false;
					break;
				}
				else {

				}
			}

			if (t1 == true && t2 == true) {
				cout << a[i] << " " << b[j];
				return 0;
			}
		}
	}

	return 0;
}


#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
using namespace std;

int a[200];
int b[200];

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	int m;
	cin >> m;
	for (int j = 0; j < m; j++) {
		cin >> b[j];
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			int sum = 0;
			sum = a[i] + b[j];

			for (int k = 0; k < n; k++) {
				if (sum != a[k]) {
					for (int l = 0; l < m; l++) {
						if (sum != b[l] && l==m-1) {
							cout << a[k] << " " << b[l];
							return 0;
						}
						else {
							break;
						}
					}
				}
				else {
					break;
				}
			}
		}
	}

	return 0;
}


#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
using namespace std;

int a[200];
int b[200];

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	int m;
	cin >> m;
	for (int j = 0; j < m; j++) {
		cin >> b[j];
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			int sum = 0;
			sum = a[i] + b[j];

			for (int k = 0; k < n; k++) {
				if (sum != a[k]) {
					for (int l = 0; l < m; l++) {
						if (sum != b[l]) {
							cout << a[k] << " " << b[l];
							exit(1);
						}
						else {
							break;
						}
					}
				}
				else {
					break;
				}
			}
		}
	}

	return 0;
}


#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
using namespace std;

int a[200];
int b[200];

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	int m;
	cin >> m;
	for (int j = 0; j < m; j++) {
		cin >> b[j];
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			int sum = 0;
			sum = a[i] + b[j];

			for (int k = 0; k < n; k++) {
				if (sum != a[k]) {
					for (int l = m-1; l >= 0; l--) {
						if (sum != b[l]) {
							cout << a[k] << " " << b[l];
							return 0;
						}
						else {
							break;
						}
					}
				}
				else {
					break;
				}
			}
		}
	}

	return 0;
}


#include <iostream>
#include <cstdlib>
#include <string>
#include <ctime>

using namespace std;

int main()
{
	setlocale(LC_ALL, "Rus");
	int n, temp_1, index_1;
	temp_1 = 0;
	cin >> n;
	int *arr_1 = new int[n];
	for (int i = 0; i < n; i++)
	{
		cin >> arr_1[i];
		if (arr_1[i] > temp_1);
		{
			temp_1 = arr_1[i];
			index_1 = i;
		}
	}

	int m, temp_2, index_2;
	temp_2 = 0;
	cin >> m;
	int *arr_2 = new int[m];
	for (int i = 0; i < m; i++)
	{
		cin >> arr_2[i];
		if (arr_2[i] > temp_2);
		{
			temp_2 = arr_2[i];
			index_2 = i;
		}
	}

	cout <<arr_1[index_1] << "\t" << arr_2[index_2];

	delete[] arr_1;
	delete[] arr_2;

}


#include <iostream>
#include <cstdlib>
#include <string>
#include <ctime>

using namespace std;

int main()
{
	setlocale(LC_ALL, "Rus");
	int n, temp_1, index_1;
	temp_1 = 0;
	cin >> n;
	int *arr_1 = new int[n];
	for (int i = 0; i < n; i++)
	{
		cin >> arr_1[i];
		if (arr_1[i] > temp_1)
		{
			temp_1 = arr_1[i];
			index_1 = i;
		}
	}

	int m, temp_2, index_2;
	temp_2 = 0;
	cin >> m;
	int *arr_2 = new int[m];
	for (int i = 0; i < m; i++)
	{
		cin >> arr_2[i];
		if (arr_2[i] > temp_2)
		{
			temp_2 = arr_2[i];
			index_2 = i;
		}
	}

	cout << arr_1[index_1] << "\t" << arr_2[index_2];

	delete[] arr_1;
	delete[] arr_2;

}


#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define sqr(x) x * x
#define forn( i, n) for (int i = 0; i < (int)n; ++i)
#define all(i) i.begin(), i.end()
#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <fstream>
#include <queue>
#include <ctime>
#include <map>
#include <set>
#include <random>
#include<iomanip>
#include<future>
template<typename T>
inline  T abs(const T& a)
{
	return a < 0 ? -a : a;
}
using namespace std;
void boost()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
}
void spr(int x) { cout << setprecision(x) << fixed; }

int main()
{
	boost();
	int n;
	vector<long long> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	int m;
	cin >> m;
	vector<long long> b(m);
	for (int i = 0; i < m; i++) cin >> b[i];
	sort(all(a));
	sort(all(b));
	cout << a[n - 1] << " " << b[m - 1];
}


#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define sqr(x) x * x
#define forn( i, n) for (int i = 0; i < (int)n; ++i)
#define all(i) i.begin(), i.end()
#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <fstream>
#include <queue>
#include <ctime>
#include <map>
#include <set>
#include <random>
#include<iomanip>
#include<future>
template<typename T>
inline  T abs(const T& a)
{
	return a < 0 ? -a : a;
}
using namespace std;
void boost()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
}
void spr(int x) { cout << setprecision(x) << fixed; }

int main()
{
	boost();
	int n;
	cin >> n;
	vector<long long> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	int m;
	cin >> m;
	vector<long long> b(m);
	for (int i = 0; i < m; i++) cin >> b[i];
	sort(all(a));
	sort(all(b));
	cout << a[n - 1] << " " << b[m - 1];
}


#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define sqr(x) x * x
#define forn( i, n) for (int i = 0; i < (int)n; ++i)
#define all(i) i.begin(), i.end()
#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <fstream>
#include <queue>
#include <ctime>
#include <map>
#include <set>
#include <random>
#include<iomanip>
#include<future>
template<typename T>
inline  T abs(const T& a)
{
	return a < 0 ? -a : a;
}
using namespace std;
void boost()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
}
void spr(int x) { cout << setprecision(x) << fixed; }

int main()
{
	boost();
	int n;
	vector<long long> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	int m;
	cin >> m;
	vector<long long> b(m);
	for (int i = 0; i < m; i++) cin >> b[i];
	sort(all(a));
	sort(all(b));
	cout << a[n - 1] + b[m - 1];
}


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
    int n, k;
    vector<int> a, b;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int num;
        cin >> num;
        a.push_back(num);
    }
    cin >> k;
    for (int i = 0; i < k; ++i) {
        int num;
        cin >> num;
        b.push_back(num);
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    cout << a[n-1] << " " << b[k-1] << endl;

return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <set>
using namespace std;

int main() {
  int n; cin >> n;
  vector<int> a(n);
  int m1 = 0;
  for (int i=0;i<n;i++){
    cin >> a[i];
    m1 = max(m1, a[i]);
  }

  int m; cin >> m;
  vector<int> b(m);
  int m2 = 0;
  for (int i=0;i<m;i++){
    cin >> b[i];
    m2 = max(m2, b[i]);
  }

  cout << m1 << " " << m2 << '\n';
}


#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;

int main() {
  int n; cin >> n;
  vector<int> a(n);
  int m1 = 0;
  for (int i=0;i<n;i++){
    cin >> a[i];
    m1 = max(m1, a[i]);
  }

  int m; cin >> m;
  vector<int> b(m);
  int m2 = 0;
  for (int i=0;i<m;i++){
    cin >> b[i];
    m2 = max(m2, b[i]);
  }

  cout << m1 << " " << m2 << '\n';
}


#include<iostream>
#include<cstring>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
std::vector<int>::iterator it1,it2;
int n1,n2,x1,x2;
vector<int> v1,v2;
bool breake=false;
cin >> n1 ;

for (int i = 0; i < n1; i++)
{
    cin >> x1; v1.push_back(x1);
}

cin >> n2 ;
for (int i = 0; i < n2; i++)
{
    cin >> x2; v2.push_back(x2);
}

for (int i = 0; i < n1; i++)
{
    for (int j = 0; j < n2; j++)
    {
        int Y=v1[i]+v2[j];
        it1 = std::find (v1.begin(), v1.end(), Y);
        it2 = std::find (v2.begin(), v2.end(), Y);

        if (it1 == v1.end() && it2 == v2.end())
        {
            cout <<  v1[i] << " " << v2[j]; breake=true; break;
        }
    }
    if(breake)break;
}

}


//�������� ��� �����
#include <iostream>
#include <vector>
using namespace std;

int main() {
	long long n, m, iMax = 0, Imax = 0;
	cin >> n;
	vector<long long>A(n);
	for (int i = 0; i < n; i++)
	{
		cin >> A.at(i);
	}
	cin >> m;
	vector<long long>B(m);
	for (int e = 0; e < m; e++)
	{
		cin >> B.at(e);
	}
	for (int i = 0; i < n; i++)
	{
		if (A.at(i) > A.at(iMax))
		{
			iMax = i;
		}
	}
	for (int e = 0; e < m; e++)
	{
		if (B.at(e) > B.at(Imax))
		{
			Imax = e;
		}
	}
	cout << A.at(iMax) << " " << B.at(Imax);
	return 0;
}
//_s1nmeee_


#include <iostream>
#include <algorithm>
#include <string.h>
#include <string>
#include <vector>
using namespace std;

int main()
{
	int a, b;
	bool visited[201] = { 0, };
	vector<int>A, B;
	cin >> a;
	A.resize(a);
	for (int i = 0; i < a; i++) {
		cin >> A[i]; visited[A[i]] = true;
	}
	cin >> b;
	B.resize(b);
	for (int i = 0; i < b; i++) {
		cin >> B[i]; visited[B[i]] = true;
	}
	for (int i = 0; i < a; i++)
		for (int j = 0; j < b; j++)
		{
			if (A[i] + B[j] > 200 || !visited[A[i] + B[j]])
			{
				cout << A[i] << " " << B[j];
				return 0;
			}
		}
}


#include <iostream>
#include <algorithm>
#include <string.h>
#include <string>
#include <vector>
using namespace std;

int main()
{
	int a, b;
	bool visited[201] = { 0, };
	vector<int>A, B;
	cin >> a;
	A.resize(a);
	for (int i = 0; i < a; i++) {
		cin >> A[i]; visited[A[i]] = true;
	}
	cin >> b;
	B.resize(b);
	for (int i = 0; i < b; i++) {
		cin >> B[i]; visited[B[i]] = true;
	}
	for (int i = 0; i < a; i++)
		for (int j = 0; j < b; j++)
		{
			if (A[i] + B[j] > 200 || !visited[A[i] + B[i]])
			{
				cout << A[i] << " " << B[i];
				return 0;
			}
		}
}


#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <math.h>

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	int m;
	cin >> m;
	vector<int> b(m);
	for (int i = 0; i < m; ++i)
		cin >> b[i];

	int pos1 = max_element(a.begin(), a.end()) - a.begin();
	int pos2 = max_element(b.begin(), b.end()) - b.begin();

	cout << a[pos1] << " " << b[pos2] << endl;
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	int n, m;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	cin >> m;
	vector<int> b(m);
	for (int j = 0; j < m; ++j)
		cin >> b[j];
	cout << *max_element(a.begin(), a.end()) << " " << *max_element(b.begin(), b.end());
	return 0;
}


#include<iostream>
#include<string>
using namespace std;
int main() {

	int n, m;
	cin >> n;
	int* arrA = new int[n];
	for (int i = 0; i < n; i++) {
		cin >> arrA[i];
	}
	cin >> m;
	int* arrB = new int[m];
	for (int i = 0; i < m; i++) {
		cin >> arrB[i];
	}

	int bigA = arrA[0], bigB = arrB[0];

	for (int i = 0; i < n; i++) {
		if (bigA <= arrA[i]) {
			bigA = arrA[i];
		}
	}

	for (int i = 0; i < m; i++) {
		if (bigB <= arrB[i]) {
			bigB = arrB[i];
		}
	}

	cout << bigA << " " << bigB;

}


#include<iostream>
#include<string>
using namespace std;
int main() {

	int n, m;
	cin >> n;
	int* arrA = new int[n];
	for (int i = 0; i < n; i++) {
		cin >> arrA[i];
	}
	cin >> m;
	int* arrB = new int[m];
	for (int i = 0; i < m; i++) {
		cin >> arrB[i];
	}

	int total = 0, positionA = 0, positionB = 0;

	for (int i = 0; i < n; i++) {

		for (int j = 0; j < m; j++) {
			total = arrA[i] + arrB[j];
			positionA = i;
			positionB = j;
			if (arrA[i] != total && arrB[j] != total) {
				cout << arrA[i] << " " << arrB[j] << endl;
				break;
			}
		}

	}

}


#include<iostream>
#include<string>
using namespace std;
int main() {

	int n, m;
	cin >> n;
	int* arrA = new int[n];
	for (int i = 0; i < n; i++) {
		cin >> arrA[i];
	}
	cin >> m;
	int* arrB = new int[m];
	for (int i = 0; i < m; i++) {
		cin >> arrB[i];
	}

	int total = 0, positionA = 0, positionB = 0;

	for (int i = 0; i < n; i++) {

		for (int j = 0; j < m; j++) {
			total = arrA[i] + arrB[j];
			positionA = i;
			positionB = j;
			if (arrA[i] != total && arrB[j] != total) {
				cout << arrA[i] << " " << arrB[j] << endl;
				break;
			}
		}
		break;
	}

}


#include<iostream>
#include<string>
using namespace std;
int main() {

	int n, m;
	cin >> n;
	int* arrA = new int[n];
	for (int i = 0; i < n; i++) {
		cin >> arrA[i];
	}
	cin >> m;
	int* arrB = new int[m];
	for (int i = 0; i < m; i++) {
		cin >> arrB[i];
	}

	int* total = new int[n * m], * posA = new int[n * m], * posB = new int[n * m], y = 0;

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			for (int k = 0; k < n * m; k++) {
				if (k + y >= n * m) {
					break;
				}
				total[k + y] = arrA[i] + arrB[j];
				posA[k + y] = arrA[i];
				posB[k + y] = arrB[j];
			}
			y++;
		}
	}

	/*for (int i = 0; i < n * m; i++) {
		cout << total[i] << " posA:" << posA[i] << " posB:" << posB[i] << endl;
	}*/

	int a = 0, b = 0;
	int i = 0, j = 0;
	bool flag1 = false, flag2 = false;
	while (i < n * m) {
		while (j < n) {
			flag1 = false;
			if (total[i] != arrA[j]) {
				flag1 = true;
			}
			j++;
		}
		while (j < m) {
			flag2 = false;
			if (total[i] != arrB[j]) {
				flag2 = true;
			}
			j++;
		}
		if (flag1 == true && flag2 == true) {
			a = i;
			b = i;
		}
		i++;
	}
	cout << posA[a]<<" " << posB[b] << endl;
}


#include<iostream>
#include<string>
using namespace std;
int main() {

	int n, m;
	cin >> n;
	int* arrA = new int[n];
	for (int i = 0; i < n; i++) {
		cin >> arrA[i];
	}
	cin >> m;
	int* arrB = new int[m];
	for (int i = 0; i < m; i++) {
		cin >> arrB[i];
	}

	int total = 0, positionA = 0, positionB = 0;

	for (int i = 0; i < n; i++) {

		for (int j = 0; j < m; j++) {
			total = arrA[i] + arrB[j];
			positionA = i;
			positionB = j;
			if (arrA[i] != total && arrB[j] != total) {
				cout << arrA[i] << " " << arrB[j] << endl;
			}
		}

	}

}


#pragma comment(linker, "/STACK:256000000")
#define _CRT_SECURE_NO_DEPRECATE
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <memory.h>
#include <fstream>
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <stack>
#include <utility>
#include <algorithm>
#include <functional>
#include <random>
#include <bitset>

using namespace std;

#define pi (3.1415926535897932384626433832795)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define tmin(x,y,z) (min(min((x),(y)),(z)))
#define tmax(x,y,z) (max(max((x),(y)),(z)))
#define sq(x) ((x)*(x))
#define cube(x) (((x)*(x))*(x))
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()

typedef long long int64;
typedef unsigned long long uint64;
typedef long double ld;
typedef unsigned long long uint64;
typedef pair<int, int> pii;
typedef pair<int64, int64> pint64;
const int INF = (int)(1e9 + 1e6);
const int64 LINF = (int64)(4e18);
const double EPS = 1e-9;
const int64 mod = 1e9 + 7;
mt19937 ggen;

void solve();

int main()
{
	iostream::sync_with_stdio(false);
	cin.tie(0);

	#ifdef _MY_DEBUG
		freopen("input.txt", "rt", stdin); freopen("output.txt", "wt", stdout);
	#endif

		//ggen = mt19937(1337);
	solve();
}

void solve()
{
	int n, m;
	vector<int> a, b;
	cin >> n;
	a.resize(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}

	cin >> m;
	b.resize(m);
	for (int i = 0; i < m; ++i) {
		cin >> b[i];
	}

	cout << *max_element(a.begin(), a.end()) << " " << *max_element(all(b));

}


#pragma comment(linker, "/STACK:256000000")
#define _CRT_SECURE_NO_DEPRECATE
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <memory.h>
#include <fstream>
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <stack>
#include <utility>
#include <algorithm>
#include <functional>
#include <random>
#include <bitset>

using namespace std;

#define pi (3.1415926535897932384626433832795)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define tmin(x,y,z) (min(min((x),(y)),(z)))
#define tmax(x,y,z) (max(max((x),(y)),(z)))
#define sq(x) ((x)*(x))
#define cube(x) (((x)*(x))*(x))
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()

typedef long long int64;
typedef unsigned long long uint64;
typedef long double ld;
typedef unsigned long long uint64;
typedef pair<int, int> pii;
typedef pair<int64, int64> pint64;
const int INF = (int)(1e9 + 1e6);
const int64 LINF = (int64)(4e18);
const double EPS = 1e-9;
const int64 mod = 1e9 + 7;
mt19937 ggen;

void solve();

int main()
{
	iostream::sync_with_stdio(false);
	cin.tie(0);

	#ifdef _MY_DEBUG
		freopen("input.txt", "rt", stdin); freopen("output.txt", "wt", stdout);
	#endif

		//ggen = mt19937(1337);
	solve();
}

void solve()
{
	int n, m;
	vector<int> a, b;
	cin >> n;
	a.resize(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}

	cin >> m;
	for (int i = 0; i < m; ++i) {
		cin >> b[i];
	}

	cout << *max_element(a.begin(), a.end()) << " " << *max_element(all(b));

}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <fstream>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include<unordered_map>
#include<iterator>
#include<climits>

#define LL long long
#define debug cout<<"Error!"
#define INF 0x7f7f7f7f7f7f7f7f
#define PI atan(1.0)*4
#define ll long long

using namespace std;

typedef double db;
const ll MM = 1e9 + 7;
ll qpow(ll x, ll n)
{
	ll ans = 1ll;
	while (n)
	{
		if (n & 1ll)
		{
			ans = (ans * x) % MM;
		}
		x = (x * x) % MM;
		n >>= 1;
	}
	return ans;
}
ll gcd(ll a, ll b)
{
	if (b == 0)return a;
	return gcd(b, a % b);
}
typedef pair<int, int> pp;
const ll maxn = 1e5 + 5;

int a[105], b[105];
int main()
{
	int n, m;
	map<int, int>a1, b1;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		a1[a[i]] = 1;
	}
	int ans1, ans2, flag = 0;
	cin >> m;
	for (int i = 0; i < m; i++)
	{
		cin >> b[i];
		b1[b[i]] = 1;
	}
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			int num = a[i] + b[j];
			if (a1[num] == 0 && b1[num] == 0) {
				flag++;
				if (flag == 1)ans1 = num;
				else ans2 = num;
			}
			if (flag == 2)break;
		}
		if (flag == 2)break;

	}
	cout << ans1 << ' ' << ans2;

	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <fstream>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include<unordered_map>
#include<iterator>
#include<climits>

#define LL long long
#define debug cout<<"Error!"
#define INF 0x7f7f7f7f7f7f7f7f
#define PI atan(1.0)*4
#define ll long long

using namespace std;

typedef double db;
const ll MM = 1e9 + 7;
ll qpow(ll x, ll n)
{
	ll ans = 1ll;
	while (n)
	{
		if (n & 1ll)
		{
			ans = (ans * x) % MM;
		}
		x = (x * x) % MM;
		n >>= 1;
	}
	return ans;
}
ll gcd(ll a, ll b)
{
	if (b == 0)return a;
	return gcd(b, a % b);
}
typedef pair<int, int> pp;
const ll maxn = 1e5 + 5;

ll a[maxn];
int main()
{
	int n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];

	}

	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <fstream>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include<unordered_map>
#include<iterator>
#include<climits>

#define LL long long
#define debug cout<<"Error!"
#define INF 0x7f7f7f7f7f7f7f7f
#define PI atan(1.0)*4
#define ll long long

using namespace std;

typedef double db;
const ll MM = 1e9 + 7;
ll qpow(ll x, ll n)
{
	ll ans = 1ll;
	while (n)
	{
		if (n & 1ll)
		{
			ans = (ans * x) % MM;
		}
		x = (x * x) % MM;
		n >>= 1;
	}
	return ans;
}
ll gcd(ll a, ll b)
{
	if (b == 0)return a;
	return gcd(b, a % b);
}
typedef pair<int, int> pp;
const ll maxn = 1e5 + 5;

int a[105], b[105];
int main()
{
	int n, m;
	int max1 = -1, max2 = -1;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		max1 = max(max1, a[i]);
	}
	cin >> m;
	for (int i = 0; i < m; i++)
	{
		cin >> b[i];
		max2 = max(max2, b[i]);
	}

	cout << max1 << ' ' << max2;

	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <fstream>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include<unordered_map>
#include<iterator>
#include<climits>

#define LL long long
#define debug cout<<"Error!"
#define INF 0x7f7f7f7f7f7f7f7f
#define PI atan(1.0)*4
#define ll long long

using namespace std;

typedef double db;
const ll MM = 1e9 + 7;
ll qpow(ll x, ll n)
{
	ll ans = 1ll;
	while (n)
	{
		if (n & 1ll)
		{
			ans = (ans * x) % MM;
		}
		x = (x * x) % MM;
		n >>= 1;
	}
	return ans;
}
ll gcd(ll a, ll b)
{
	if (b == 0)return a;
	return gcd(b, a % b);
}
typedef pair<int, int> pp;
const ll maxn = 1e5 + 5;

int a[105], b[105];
int main()
{
	int n, m;
	map<int,int>a1, b1;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		a1[a[i]] = 1;
	}
	int ans1, ans2, flag = 0;
	cin >> m;
	for (int i = 0; i < m; i++)
	{
		cin >> b[i];
		b1[b[i]] = 1;
	}
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			int num = a[i] + b[j];
			if (a[num] == 0 && b[num] == 0) {
				flag++;
				if (flag == 1)ans1 = num;
				else ans2 = num;
			}
			if (flag == 2)break;
		}
		if (flag == 2)break;

	}
	cout << ans1<<' ' << ans2;

	return 0;
}


#include <iostream>
#include <cmath>
#include <bits/stdc++.h>
using namespace std;

int main(){
int n, m;
int a[101], b[101];

cin >>n;

for(int i = 0; i<n; i++){
	cin >> a[i];
}

cin >> m;
for(int i = 0; i<m; i++){
	cin >> b[i];
}

sort(a, a+n);
sort(b, b+m);

cout<< a[n-1]<<" "<< b[m-1];

return 0;
 }


#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;

int main(){
int n, m;
int a[101], b[101];

cin >>n;

for(int i = 0; i<n; i++){
	cin >> a[i];
}

cin >> m;
for(int i = 0; i<m; i++){
	cin >> b[i];
}

sort(a, a+n);
sort(b, b+m);

cout<< a[n-1]<<" "<< b[m-1];

return 0;
 }


#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<string>
#include<cmath>
#include<map>
#include<bitset>
#include<utility>
//#include<unordered_map>
#ifdef LOCAL
#include"file.h"
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
const double eps = 1e-12;
const double Pi = 3.1415926535897932;
const int dir[4][2] = { -1,0,1,0,0,-1,0,1 };
//const int dir[8][2] = { -2,-1,-2,1,2,-1,2,1,-1,2,-1,-2,1,2,1,-2 };

const int maxn = 2000 + 5;

int n, m;
int a[maxn], b[maxn];
bool vis[maxn];

int main() {
#ifdef LOCAL
	fileopen();
#endif
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		scanf("%d", &a[i]), vis[a[i]] = true;
	scanf("%d", &m);
	for (int i = 1; i <= m; i++)
		scanf("%d", &b[i]), vis[b[i]] = true;

	bool ok = true;
	for (int i = 1; ok&&i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			if (vis[a[i] + b[j]] == false) {
				printf("%d %d\n", a[i], b[j]);
				ok = false;
				break;
			}
		}
	}

#ifdef LOCAL
	fileclose();
#endif
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<string>
#include<cmath>
#include<map>
#include<bitset>
#include<utility>
//#include<unordered_map>
#ifdef LOCAL
#include"file.h"
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
const double eps = 1e-12;
const double Pi = 3.1415926535897932;
const int dir[4][2] = { -1,0,1,0,0,-1,0,1 };
//const int dir[8][2] = { -2,-1,-2,1,2,-1,2,1,-1,2,-1,-2,1,2,1,-2 };

const int maxn = 2000 + 5;

int n, m;
int a[maxn], b[maxn];
bool vis[maxn];

int main() {
#ifdef LOCAL
	fileopen();
#endif
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		scanf("%d", &a[i]), vis[a[i]] = true;
	scanf("%d", &m);
	for (int i = 1; i <= n; i++)
		scanf("%d", &b[i]), vis[b[i]] = true;

	bool ok = true;
	for (int i = 1; ok&&i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			if (vis[a[i] + b[j]] == false) {
				printf("%d %d\n", a[i], b[j]);
				ok = false;
				break;
			}
		}
	}

#ifdef LOCAL
	fileclose();
#endif
	return 0;
}


#include<iostream>
#include<string>
#include<cstring>
#include<vector>
#include<cmath>
#include<iomanip>
#include<map>
#include<queue>
#include<stack>
#include<algorithm>
#include <fstream>
#include <set>
#include <list>
#include <stdio.h>

using namespace std;
#define ll long long
#define ld long double
#define mp make_pair
#define all(g) g.begin(),g.end()
#define allr(g) g.rbegin(),g.rend()
#define re(x)   return cout<<x,0
#define in(n)for(int i=0;i<n;i++)cin>>v[i];
#define loop(n)for(int i=0;i<n;i++)
#define matar 	ios_base::sync_with_stdio(false); cin.tie(NULL);
#define me(x,v) memset(x,v,sizeof(x))
#define endl '\n'
ll GCD(ll a, ll b){ return(b == 0) ? a : GCD(b, a%b); }
ll LCM(ll a, ll b)
{
	ll temp = GCD(a, b);

	return temp ? (a / temp * b) : 0;
}
ll const MOD = 998244353, N = 5e5 + 7;
ll fast(ll p, ll b) {
	if (b == 1)return p;
	ll res = fast(p, b / 2);
	if (b % 2)
		return (res%MOD*res%MOD*p%MOD) % MOD;
	else
		return (res%MOD*res%MOD) % MOD;
}

int dx[4] = { 1, -1, 0, 0 };
int dy[4] = { 0, 0, 1, -1 };
ll oo = 1e18;
int f[N],p[N];
ll   n, sum,m, x, y;
bool can(int nx, int ny){
	return (nx < 0 || ny < 0 || nx >= n || ny >= m);
}
int k,d;
vector<string>v;

int main()
{
	int n, m;
	cin >> n ;
	vector<string>a(n),b;
	loop(n)cin >> a[i];
	cin >> m;
	b.resize(m);
	loop(m)cin >> b[i];
	sort(all(a));
	sort(all(b));
	cout << a[0] << " " << b[m - 1];

	return 0;
}


#include<iostream>
#include<string>
#include<cstring>
#include<vector>
#include<cmath>
#include<iomanip>
#include<map>
#include<queue>
#include<stack>
#include<algorithm>
#include <fstream>
#include <set>
#include <list>
#include <stdio.h>

using namespace std;
#define ll long long
#define ld long double
#define mp make_pair
#define all(g) g.begin(),g.end()
#define allr(g) g.rbegin(),g.rend()
#define re(x)   return cout<<x,0
#define in(n)for(int i=0;i<n;i++)cin>>v[i];
#define loop(n)for(int i=0;i<n;i++)
#define matar 	ios_base::sync_with_stdio(false); cin.tie(NULL);
#define me(x,v) memset(x,v,sizeof(x))
#define endl '\n'
ll GCD(ll a, ll b){ return(b == 0) ? a : GCD(b, a%b); }
ll LCM(ll a, ll b)
{
	ll temp = GCD(a, b);

	return temp ? (a / temp * b) : 0;
}
ll const MOD = 998244353, N = 5e5 + 7;
ll fast(ll p, ll b) {
	if (b == 1)return p;
	ll res = fast(p, b / 2);
	if (b % 2)
		return (res%MOD*res%MOD*p%MOD) % MOD;
	else
		return (res%MOD*res%MOD) % MOD;
}

int dx[4] = { 1, -1, 0, 0 };
int dy[4] = { 0, 0, 1, -1 };
ll oo = 1e18;
int f[N],p[N];
ll   n, sum,m, x, y;
bool can(int nx, int ny){
	return (nx < 0 || ny < 0 || nx >= n || ny >= m);
}
int k,d;
vector<string>v;

int main()
{
	int n, m;
	cin >> n ;
	vector<int>a(n),b;
	loop(n)cin >> a[i];
	cin >> m;
	b.resize(m);
	loop(m)cin >> b[i];
	sort(all(a));
	sort(all(b));
	//loop(m)cout << b[i] << " ";
	cout << a[0] << " " << b[m - 1];

	return 0;
}


#include<iostream>
#include<string>
#include<cstring>
#include<vector>
#include<cmath>
#include<iomanip>
#include<map>
#include<queue>
#include<stack>
#include<algorithm>
#include <fstream>
#include <set>
#include <list>
#include <stdio.h>

using namespace std;
#define ll long long
#define ld long double
#define mp make_pair
#define all(g) g.begin(),g.end()
#define allr(g) g.rbegin(),g.rend()
#define re(x)   return cout<<x,0
#define in(n)for(int i=0;i<n;i++)cin>>v[i];
#define loop(n)for(int i=0;i<n;i++)
#define matar 	ios_base::sync_with_stdio(false); cin.tie(NULL);
#define me(x,v) memset(x,v,sizeof(x))
#define endl '\n'
ll GCD(ll a, ll b){ return(b == 0) ? a : GCD(b, a%b); }
ll LCM(ll a, ll b)
{
	ll temp = GCD(a, b);

	return temp ? (a / temp * b) : 0;
}
ll const MOD = 998244353, N = 5e5 + 7;
ll fast(ll p, ll b) {
	if (b == 1)return p;
	ll res = fast(p, b / 2);
	if (b % 2)
		return (res%MOD*res%MOD*p%MOD) % MOD;
	else
		return (res%MOD*res%MOD) % MOD;
}

int dx[4] = { 1, -1, 0, 0 };
int dy[4] = { 0, 0, 1, -1 };
ll oo = 1e18;
int f[N],p[N];
ll   n, sum,m, x, y;
bool can(int nx, int ny){
	return (nx < 0 || ny < 0 || nx >= n || ny >= m);
}
int k,d;
vector<string>v;

int main()
{
	int n, m;
	cin >> n ;
	vector<int>a(n),b;
	loop(n)cin >> a[i];
	cin >> m;
	b.resize(m);
	loop(m)cin >> b[i];
	sort(all(a));
	sort(all(b));
	//loop(m)cout << b[i] << " ";
	cout << a[n-1] << " " << b[m - 1];

	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int n, m, x, maxA, maxB;
	vector<int> a, b;
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		cin >> x;
		a.push_back(x);
	}
	cin >> m;
	maxA = *max_element(a.begin(), a.end());
	for (int i = 0; i < m; ++i)
	{
		cin >> x;
		b.push_back(x);
	}
	maxB = *max_element(b.begin(), b.end());
	cout << maxA << " " << maxB;
    return 0;
}


#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;

int binearysearch(int a[], int s,int e, int num) {
	if (s >= e)return -1;
	int	mid = (s + e) / 2;
	if (a[mid] == num)return mid;
	else if (a[mid] > num) {
		binearysearch(a, s, mid - 1, num);
	}
	else binearysearch(a, mid + 1,e, num);
}

int main() {
	int n, m; int a[200], b[200];
	cin >> n;
	for (int i = 0; i < n; i++)cin >> a[i];
	cin >> m;
	for (int i = 0; i < m; i++)cin >> b[i];
	sort(a, a + n);
	sort(b, b + m);
	int flag = 0;
	for (int i = 0; i < n&&!flag; i++) {
		for (int j = 0; j < m; j++) {
			if (binearysearch(a, 0,n, a[i] + b[j]) == -1) {
				if (binearysearch(b, 0,m, a[i] + b[j]) == -1) {
					cout << a[i] << " " << b[j] << endl;
					flag = 1;
					break;
				}
			}
		}
	}

	return 0;
}


#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;

int binearysearch(int a[], int s,int e, int num) {
	if (s >= e)return -1;
	int	mid = (s + e) / 2;
	if (a[mid] == num)return mid;
	else if (a[mid] > num) {
		binearysearch(a, s, mid - 1, num);
	}
	else binearysearch(a, mid + 1,e, num);
}

int ser(int a[], int n, int key) {
	int flag = 0, i;
	for (i = 0; i < n; i++) {
		if (a[i] == key) {
			flag = 1;
			break;
		}
	}
	if (flag == 1)return 1;
	else return -1;
}

int main() {
	int n, m; int a[200], b[200];
	cin >> n;
	for (int i = 0; i < n; i++)cin >> a[i];
	cin >> m;
	for (int i = 0; i < m; i++)cin >> b[i];

	int flag = 0;
	for (int i = 0; i < n&&!flag; i++) {
		for (int j = 0; j < m&&!flag; j++) {
			if (ser(a, n, a[i] + b[j]) == -1 && ser(b, m, a[i] + b[j]) == -1) {
				flag = 1;
				cout << a[i] << " " << b[j] << endl;
				break;
			}
		}
	}
	return 0;
}


#include <iostream>
#include <cstdlib>
using namespace std;

int main()
{  int n,m,*a,*b,temp;
   cin>>n;
   a=(int*)malloc(sizeof(int)*n);
   for(int i=0;i<n;i++)
   {
       cin>>a[i];
   }
   cin>>m;
   b=(int*)malloc(sizeof(int)*m);
   for(int i=0;i<m;i++)
   {
       cin>>b[i];
   }
   for(int i=0;i<n-1;i++)
   {
      for(int j=i+1;j<n;j++)
      {
          if(a[i]<a[j]){temp=a[i];a[i]=a[j];a[j]=temp;}
      }
   }
   for(int i=0;i<m-1;i++)
   {
      for(int j=i+1;j<m;j++)
      {
          if(b[i]<b[j]){temp=a[i];b[i]=b[j];b[j]=temp;}
      }
   }
    cout<<a[0]<<" "<<b[0];
    return 0;
}


#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
int main() {
	int a, b, sum;
	cin >> a;
	int* arr1 = new int[a];
	for (int i = 0; i < a; i++)cin >> arr1[i];
	cin >> b;
	int* arr2 = new int[b];
	for (int i = 0; i < b; i++)cin >> arr2[i];
	sort(arr1, arr1 + a);
	sort(arr2, arr2 + b);
	cout << arr1[a - 1] << " " << arr2[b - 1];
}


#include <stdio.h>
#include <string>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>

#define fo(i,n) for(int i=0;i<n;i++)
#define forr(i,a,b) for(int i=a;i<b;i++)
const int maxN = 50005;
using namespace std;

int main() {

	int t = 1;
	//cin >> t;
	while (t--) {
		int n, m, a[200], b[200];
		cin >> n;
		for (int i = 0; i < n; i++)
		{
			cin >> a[i];
		}
		sort(a, a + n);

		cin >> m;
		for (int i = 0; i < m; i++)
		{
			cin >> b[i];
		}
		sort(b, b + m);

		cout << a[n - 1] << " " << b[m - 1];
	}
}


#include <stdio.h>
#include <string>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>

#define fo(i,n) for(int i=0;i<n;i++)
#define forr(i,a,b) for(int i=a;i<b;i++)
const int maxN = 50005;
using namespace std;

int main() {

	int t;
	cin >> t;
	while (t--) {
		int n, m, a[200], b[200];
		cin >> n;
		for (int i = 0; i < n; i++)
		{
			cin >> a[i];
		}
		sort(a, a + n);

		cin >> m;
		for (int i = 0; i < m; i++)
		{
			cin >> b[i];
		}
		sort(b, b + m);

		cout << a[n - 1] << " " << b[m - 1];
	}
}


#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <cmath>

using namespace std;

int main()
{
	int aSize;
	cin >> aSize;
	vector<int> A(aSize);
	for (int i = 0; i < aSize; ++i)
		cin >> A[i];

	int bSize;
	cin >> bSize;
	vector<int> B(bSize);
	for (int i = 0; i < bSize; ++i)
		cin >> B[i];

	for (int i = 0; i < A.size(); ++i)
	{
		for (int j = 0; j < B.size(); ++j)
		{
			if (find(A.begin(), A.end(), A[i] + B[j]) == A.end() && find(B.begin(), B.end(), A[i] + B[j]) == B.end())
			{
				cout << A[i] << ' ' << B[j];
				return 0;
			}
		}
	}

	return 0;
}


#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <cmath>

using namespace std;

int main()
{
	int aSize;
	cin >> aSize;
	vector<int> A(aSize);
	for (int i = 0; i < aSize; ++i)
		cin >> A[i];

	int bSize;
	cin >> bSize;
	vector<int> B(bSize);
	for (int i = 0; i < bSize; ++i)
		cin >> B[i];

	for (int i = 0; i < A.size(); ++i)
	{
		for (int j = 0; j < B.size(); ++j)
		{
			if (find(A.begin(), A.end(), A[i] + B[j]) == A.end() || find(B.begin(), B.end(), A[i] + B[j]) == B.end())
			{
				cout << A[i] << ' ' << B[j];
				return 0;
			}
		}
	}

	return 0;
}


#include <iostream>
using namespace std;
int main()
{
	int n,m;
	int a[100];
	int b[100];
	cin >> n;
	for(int i=0;i<n;i++)
	{
		cin >> a[i];
	}
	cin >> m;
	for(int i=0;i<m;i++)
	{
		cin >> b[i];
	}
	int s=0;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			s=a[i]+b[j];
                        bool r=true;
       			for(int k=0;k<n;k++)
	                {
				if(s == a[k])
				   r=false;
			}
                        for(int l=0;l<m;l++)
	                {
				if(s == b[l])
				   r=false;
			}
			if(r == true)
			{
			cout << a[i] << " " << b[j] << endl;
			return 0;
			}
		}
	}
	return 0;
}


#include <iostream>
using namespace std;
int main()
{
	int n,m;
	int a[100];
	int b[100];
	cin >> n;
	for(int i=0;i<n;i++)
	{
		cin >> a[i];
	}
	cin >> m;
	for(int i=0;i<m;i++)
	{
		cin >> b[i];
	}
	int s=0;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			s=a[i]+b[j];
			if(s!=a[i] && s!=b[i])
			{
			cout << a[i] << " " << b[j] << endl;
			return 0;
			}
		}
	}
	return 0;
}


#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
bool search(int val,int a[],int b[],int n,int m)
{
    int flag1=0;
    int flag2=0;
    for(int i=0;i<n;i++)
    {
        if(a[i]==val)
            flag1++;
    }
    for(int i=0;i<m;i++)
    {
        if(b[i]==val)
            flag2++;
    }
    if(flag1==0 && flag2==0)
        return 1;
    return 0;
}
int main()
{
    int n,m,a[101],b[101];
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    cin>>m;
    for(int i=0;i<m;i++)
        cin>>b[i];
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            int res=a[i]+b[j];
            if(search(res,a,b,n,m))
            {
                cout<<a[i]<<" "<<b[j];
                return 0;
            }
        }
    }
}


#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
bool search(int val,int a[],int b[],int n,int m)
{
    int flag1=0;
    int flag2=0;
    for(int i=0;i<n;i++)
    {
        if(a[i]==val)
            flag1++;
    }
    for(int i=0;i<m;i++)
    {
        if(b[i]==val)
            flag2++;
    }
    if(flag1==0 && flag2==0)
        return 1;
    return 0;
}
int main()
{
    int n,m,a[101],b[101];
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    cin>>m;
    for(int i=0;i<m;i++)
        cin>>b[i];
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            int res=a[i]+b[j];
            if(search(res,a,b,n,m))
            {
                cout<<a[i]<<" "<<b[i];
                return 0;
            }
        }
    }
}


#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
bool search(int val,int a[],int b[],int n,int m)
{
    int flag1=0;
    int flag2=0;
    for(int i=0;i<n;i++)
    {
        if(a[i]==val)
            flag1++;
    }
    for(int i=0;i<m;i++)
    {
        if(b[i]==val)
            flag2++;
    }
    if(flag1==0 && flag2==0)
        return 1;
    return 0;
}
int main()
{
    int n,m,a[100],b[100];
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    cin>>m;
    for(int i=0;i<m;i++)
        cin>>b[i];
    for(int i=0;i<n&&(i<m);i++)
    {
        int res=a[i]+b[i];
        if(search(res,a,b,n,m))
        {
            cout<<a[i]<<" "<<b[i];
            break;
        }
    }
}


#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;
#define ll long long
ll GCD(ll a, ll b) { return (a) ? GCD(b % a, a) : b; }
ll LCM(ll a, ll b) { return a * b / GCD(a, b); }
ll fastpow(ll b, ll p) { if (!p) return 1; ll ret = fastpow(b, p >> 1); ret *= ret; if (p & 1) ret *= b; return ret; }
int a[101],b[101];
int main()
{
	int n;
	cin >> n;
	for (size_t i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	int M;
	cin >> M;
	for (size_t i = 0; i < n; i++)
	{
		cin >> b[i];
	}
	sort(a, a + n);
	sort(b, b + n);
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < M; j++)
		{
			int sum = a[i] + b[j];
			// now binary search in b and a
			int l = 0, r = n - 1,m;
			bool f = 0;
			while (l<=r)
			{
				m = (l + r) / 2;
				if (sum < a[m])
				{
					r = m - 1;
				}
				else if (sum > a[m])
				{
					l = m + 1;
				}
				else
				{
					f = 1;
					break;
				}
			}
			if (f)
				break;
			else
			{
				l = 0; r = M - 1;
				f = 0;
				while (l <= r)
				{
					m = (l + r) / 2;
					if (sum < a[m])
					{
						r = m - 1;
					}
					else if (sum > a[m])
					{
						l = m + 1;
					}
					else
					{
						f = 1;
						break;
					}
				}
				if (f)
					break;
				else
				{
					cout << a[i] << " " << b[j];
					return 0;
				}
			}

		}
	}
}


#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;
#define ll long long
ll GCD(ll a, ll b) { return (a) ? GCD(b % a, a) : b; }
ll LCM(ll a, ll b) { return a * b / GCD(a, b); }
ll fastpow(ll b, ll p) { if (!p) return 1; ll ret = fastpow(b, p >> 1); ret *= ret; if (p & 1) ret *= b; return ret; }
int a[101],b[101];
int main()
{
	int n;
	cin >> n;
	for (size_t i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	int M;
	cin >> M;
	for (size_t i = 0; i < M; i++)
	{
		cin >> b[i];
	}
	sort(a, a + n);
	sort(b, b + M);
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < M; j++)
		{
			int sum = a[i] + b[j];
			// now binary search in b and a
			int l = 0, r = n - 1,m;
			bool f = 0;
			while (l<=r)
			{
				m = (l + r) / 2;
				if (sum < a[m])
				{
					r = m - 1;
				}
				else if (sum > a[m])
				{
					l = m + 1;
				}
				else
				{
					f = 1;
					break;
				}
			}
			if (f)
				break;
			else
			{
				l = 0; r = M - 1;
				f = 0;
				while (l <= r)
				{
					m = (l + r) / 2;
					if (sum < b[m])
					{
						r = m - 1;
					}
					else if (sum > b[m])
					{
						l = m + 1;
					}
					else
					{
						f = 1;
						break;
					}
				}
				if (f)
					;
				else
				{
					cout << a[i] << " " << b[j];
					return 0;
				}
			}

		}
	}
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <list>
#include <functional>

using namespace std;

const int N = 1e5 + 7;
int ans[N][2], arr[4 * N];
long long sum[N];

int main(void)
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;
	for (int i = 1, j = 1; i <= 2 * n; i += 2, j++) {
		if (i / 2 % 2 == 0) {
			ans[j][0] = i;
			ans[j][1] = i + 1;
		}
		else {
			ans[j][0] = i + 1;
			ans[j][1] = i;
		}
	}
	for (int i = 1; i <= n; i++) {
		arr[i] = ans[i][0];
	}
	for (int i = n + 1, j = 1; i <= 2 * n; i++, j++) {
		arr[i] = ans[j][1];
	}
	for (int i = 1; i <= 2 * n; i++) {
		sum[i] = sum[i - 1] + arr[i];
	}
	int st = n;
	for (int i = n; i <= 2 * n - 1; i++) {
		if (abs((sum[i] - sum[i - n]) - (sum[i + 1] - sum[i - n + 1])) > 1) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	for (int i = 1; i <= 2 * n; i++) {
		cout << arr[i] << " ";
	}
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <list>
#include <functional>

using namespace std;

const int N = 1e5 + 7;

int arr[N], brr[N], cnt[N];

int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	int n;
	cin >> n;

	for (int i = 1; i <= n; i++) {
		cin >> arr[i];
		cnt[arr[i]]++;
	}
	int m;
	cin >> m;
	for (int i = 1; i <= m; i++) {
		cin >> brr[i];
		cnt[brr[i]]++;
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			if (cnt[arr[i] + brr[j]] == 0) {
				cout << arr[i] << " " << brr[j];
				return 0;
			}
		}
	}

	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <set>
#include <iomanip>

using namespace std;
const long long INF = 1e9;
const long double pi = 3.14159265358979323846;

long long f() {
	long long a = 0;
	char c = ' ';
	bool flag = false;
	while (!isdigit(c))
	{
		c = _getchar_nolock();
		if (c == '-')
			flag = true;
	}
	while (isdigit(c)) {
		a = a * 10 + (c - '0');
		c = _getchar_nolock();
	}
	if (flag)
		return -a;
	return a;
}

void print(vector <int>& h) {
	for (int i = 0; i < h.size(); ++i) {
		cout << h[i] << " ";
	}
	cout << "\n";
}

long long gcd(long long a, long long b) {
	if (b == 0)
		return a;
	else
		return gcd(b, a % b);
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n;
	vector <int> h(n);
	for (int i = 0; i < n; ++i) {
		cin >> h[i];
	}
	cin >> m;
	vector <int> b(m);
	for (int i = 0; i < m; ++i) {
		cin >> b[i];
	}
	sort(b.begin(), b.end());
	sort(h.begin(), b.end());
	cout << h[n - 1]  << " " b[m - 1];
	return 0;
}


 #include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <set>
#include <iomanip>

using namespace std;
const long long INF = 1e9;
const long double pi = 3.14159265358979323846;

long long f() {
	long long a = 0;
	char c = ' ';
	bool flag = false;
	while (!isdigit(c))
	{
		c = _getchar_nolock();
		if (c == '-')
			flag = true;
	}
	while (isdigit(c)) {
		a = a * 10 + (c - '0');
		c = _getchar_nolock();
	}
	if (flag)
		return -a;
	return a;
}

void print(vector <int>& h) {
	for (int i = 0; i < h.size(); ++i) {
		cout << h[i] << " ";
	}
	cout << "\n";
}

long long gcd(long long a, long long b) {
	if (b == 0)
		return a;
	else
		return gcd(b, a % b);
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n;
	vector <int> h(n);
	for (int i = 0; i < n; ++i) {
		cin >> h[i];
	}
	cin >> m;
	vector <int> b(m);
	for (int i = 0; i < m; ++i) {
		cin >> b[i];
	}
	sort(b.begin(), b.end());
	sort(h.begin(), b.end());
	cout << h[n - 1]  << " " << b[m - 1];
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <set>
#include <iomanip>

using namespace std;
const long long INF = 1e9;
const long double pi = 3.14159265358979323846;

long long f() {
	long long a = 0;
	char c = ' ';
	bool flag = false;
	while (!isdigit(c))
	{
		c = _getchar_nolock();
		if (c == '-')
			flag = true;
	}
	while (isdigit(c)) {
		a = a * 10 + (c - '0');
		c = _getchar_nolock();
	}
	if (flag)
		return -a;
	return a;
}

void print(vector <int>& h) {
	for (int i = 0; i < h.size(); ++i) {
		cout << h[i] << " ";
	}
	cout << "\n";
}

long long gcd(long long a, long long b) {
	if (b == 0)
		return a;
	else
		return gcd(b, a % b);
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n;
	vector <int> h(n);
	for (int i = 0; i < n; ++i) {
		cin >> h[i];
	}
	cin >> m;
	vector <int> b(m);
	for (int i = 0; i < m; ++i) {
		cin >> b[i]
	}
	sort(b.begin(), b.end());
	sort(h.begin(), b.end());
	cout << b[m - 1] + h[n - 1];
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <set>
#include <iomanip>

using namespace std;
const long long INF = 1e9;
const long double pi = 3.14159265358979323846;

long long f() {
	long long a = 0;
	char c = ' ';
	bool flag = false;
	while (!isdigit(c))
	{
		c = _getchar_nolock();
		if (c == '-')
			flag = true;
	}
	while (isdigit(c)) {
		a = a * 10 + (c - '0');
		c = _getchar_nolock();
	}
	if (flag)
		return -a;
	return a;
}

void print(vector <int>& h) {
	for (int i = 0; i < h.size(); ++i) {
		cout << h[i] << " ";
	}
	cout << "\n";
}

long long gcd(long long a, long long b) {
	if (b == 0)
		return a;
	else
		return gcd(b, a % b);
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n;
	vector <int> h(n);
	for (int i = 0; i < n; ++i) {
		cin >> h[i];
	}
	cin >> m;
	vector <int> b(m);
	for (int i = 0; i < m; ++i) {
		cin >> b[i];
	}
	sort(b.begin(), b.end());
	sort(h.begin(), h.end());
	cout << h[n - 1] << " " << b[m - 1];
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <set>
#include <iomanip>

using namespace std;
const long long INF = 1e9;
const long double pi = 3.14159265358979323846;

long long f() {
	long long a = 0;
	char c = ' ';
	bool flag = false;
	while (!isdigit(c))
	{
		c = _getchar_nolock();
		if (c == '-')
			flag = true;
	}
	while (isdigit(c)) {
		a = a * 10 + (c - '0');
		c = _getchar_nolock();
	}
	if (flag)
		return -a;
	return a;
}

void print(vector <int>& h) {
	for (int i = 0; i < h.size(); ++i) {
		cout << h[i] << " ";
	}
	cout << "\n";
}

long long gcd(long long a, long long b) {
	if (b == 0)
		return a;
	else
		return gcd(b, a % b);
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n;
	vector <int> h(n);
	for (int i = 0; i < n; ++i) {
		cin >> h[i];
	}
	cin >> m;
	vector <int> b(m);
	for (int i = 0; i < m; ++i) {
		cin >> b[i];
	}
	sort(b.begin(), b.end());
	sort(h.begin(), b.end());
	cout << b[m - 1] + h[n - 1];
	return 0;
}


#include<iostream>
#include<string>
using namespace std;

int n, m;
int* A;
int* B;
int* C;
int main() {
	cin >> n;
	A = new int[n];
	for (int i = 0; i < n; i++) {
		cin >> A[i];
	}
	cin >> m;
	B = new int[m];
	for (int i = 0; i < m; i++) {
		cin >> B[i];
	}
	C = new int[n + m];
	for (int i = 0; i < n; i++) {
		C[i] = A[i];
	}
	for (int i = n; i < n + m; i++) {
		C[i] = B[i - n];
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			for (int k = 0; k < n + m; k++) {
				if (A[i] + B[j] != C[k]) {
					cout << A[i] << "  " << B[j];
					return 0;
				}
			}
		}
	}
	return 0;
}


#include<iostream>
#include<string>
using namespace std;

int n, m;
int* A;
int* B;
int* C;
int main() {
	cin >> n;
	A = new int[n];
	for (int i = 0; i < n; i++) {
		cin >> A[i];
	}
	cin >> m;
	B = new int[m];
	for (int i = 0; i < m; i++) {
		cin >> B[i];
	}
	C = new int[n + m];
	for (int i = 0; i < n; i++) {
		C[i] = A[i];
	}
	for (int i = n; i < n + m; i++) {
		C[i] = B[i - n];
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			for (int k = 0; k < n + m; k++) {
				if (A[i] + B[j] != C[k]) {
					if (k == n + m - 1) {
						cout << A[i] << " " << B[j];
						return 0;
					}
				}
				else {
					break;
				}
			}
		}
	}
	return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
    int len;
    for (int n=0;n<2;n++){
        cin>>len;
        vector<int>vec;
        for(int i=0;i<len;i++){
            int tmp;
            cin>>tmp;
            vec.push_back(tmp);
        }
        sort(vec.begin(),vec.end());
        cout<<vec[vec.size()-1]<<" ";
    }
    cout<<endl;
    return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
    int len;
    for (int n=0;n<2;n++){
        int max=0;
        cin>>len;
        for(int i=0;i<len;i++){
            int tmp;
            cin>>tmp;
            max=tmp>max?tmp:max;
        }
        cout<<max<<" ";
    }
    cout<<endl;
    return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
    int len,max=0;
    for (int n=0;n<2;n++){
        cin>>len;
        for(int i=0;i<len;i++){
            int tmp;
            cin>>tmp;
            max=tmp>max?tmp:max;
        }
        cout<<max<<" ";
        max=0;
    }
    cout<<endl;
    return 0;
}


#include<stdio.h>
#include<string.h>
#include<vector>
using namespace std;
int main() {
	int n, m;
	int ch1, ch2;
	vector<int> a,b;
	int a1, b1;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a1);
		a.push_back(a1);

	}
	scanf("%d", &m);
	for (int i = 0; i < m; i++) {
		scanf("%d", &a1);
		b.push_back(a1);
	}
	for (int i = 0; i < n; i++) {
		ch1 = 0;
		ch2 = 0;
		for (int j = 0; j < n; j++) {
			b1 = a[i] + b[j];
			if (b1 > 200) {
				printf("%d %d", a[i], b[j]);
				return 0;
			}
			for (int z = 0; z < n; z++) {
				if (b1 == a[z]) {
					ch1 = 1;
					break;
				}
			}
			for (int z = 0; z < n; z++) {
				if (b1 == a[z]) {
					ch2 = 1;
					break;
				}
			}
			if (ch1 == 0 && ch2 == 0) {
				printf("%d %d", a[i], b[j]);
					return 0;
			}
		}
	}

}


#include<stdio.h>
#include<string.h>
int a[101] = { 0 };
int b[101] = { 0 };
int main() {
	int t, w, anw;
	int chc1, chc2;

	scanf("%d", &t);
	for (int i = 0; i < t; i++) {
		scanf("%d", &a[i]);
	}
	scanf("%d", &w);
	for (int i = 0; i < w; i++) {
		scanf("%d", &b[i]);
	}
	for (int i = 0; i < t; i++) {
		chc1 = 0;
		chc2 = 0;
		for (int j = 0; j < w; j++) {
			anw = a[i] + b[j];
			for (int z = 0; z < t; z++) {
				if (anw == a[z]) {
					chc1 = 1;
				}
			}
			for (int z = 0; z < w; z++) {
				if (anw == b[z]) {
					chc2 = 1;
				}
			}
			if (chc1 == 0 && chc2 == 0) {
				printf("%d %d", a[i], b[j]);
				return 0;
			}
		}
	}
	return 0;

}


#include<stdio.h>
#include<string.h>
int a[101] = { 0 };
int b[101] = { 0 };
int main() {
	int n, m, ch1, ch2,anw;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	scanf("%d",&m);
	for (int i = 0; i < m; i++) {
		scanf("%d", &b[i]);
	}
	for (int i = 0; i < n; i++) {
		ch1 = 0;
		ch2 = 0;
		for (int j = 0; j < m; j++) {
			anw = a[i] + b[j];
			for (int q = 0; q < n; q++) {
				if (anw == a[q]) {
					ch1 = 1;
					break;
				}
			}
			for (int z = 0; z < m; z++) {
				if (anw == b[z]) {
					ch2 = 1;
					break;
				}
			}
			if (ch1 == 0 && ch2 == 0) {
				printf("%d %d", a[i], b[j]);
				return 0;
			}
		}
	}
	return 0;
}


#include<stdio.h>
#include<string.h>
int a[101] = { 0 };
int b[101] = { 0 };
int main() {
	int t, w,anw;
	int chc1, chc2;

	scanf("%d", &t);
		for (int i = 0; i < t; i++) {
			scanf("%d", &a[i]);
	}
		scanf("%d", &w);
		for (int i = 0; i < w; i++) {
			scanf("%d", &b[i]);
		}
		for (int i = 0; i < t; i++) {
			chc1 = 0;
			chc2 = 0;
			for (int j = 0; j < w; j++) {
				anw = a[i] + b[j];
				for (int z = 0; z < t; z++) {
					if (anw == a[z]) {
						chc1 = 1;
					}
				}
				for (int z = 0; z < t; z++) {
					if (anw == a[z]) {
						chc2 = 1;
					}
				}
				if (chc1 == 0 && chc2 == 0) {
					printf("%d %d", a[i], b[j]);
					return 0;
				}
			}
	 }
		return 0;

}


#include<stdio.h>
#include<string.h>
#include<vector>
using namespace std;
int main() {
	int n, m;
	int ch1, ch2;
	vector<int> a,b;
	int a1, b1;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a1);
		a.push_back(a1);

	}
	scanf("%d", &m);
	for (int i = 0; i < m; i++) {
		scanf("%d", &a1);
		b.push_back(a1);
	}
	for (int i = 0; i < n; i++) {
		ch1 = 0;
		ch2 = 0;
		for (int j = 0; j < m; j++) {
			b1 = a[i] + b[j];
			for (int z = 0; z < n; z++) {
				if (b1 == a[z]) {
					ch1 = 1;
					break;
				}
			}
			for (int z = 0; z < m; z++) {
				if (b1 == a[z]) {
					ch2 = 1;
					break;
				}
			}
			if (ch1 == 0 && ch2 == 0) {
				printf("%d %d", a[i], b[j]);
					return 0;
			}
		}
	}
	return 2;

}


#include <iostream>

using namespace std;

int main()
{
    int n, m, i, a, b, amax = 0, bmax = 0;
    cin>>n;
    for(i = 1;i<=n;i++){
        cin>>a;
        if(a>amax) amax = a;
        }
    cin>>m;
    for(i = 1;i<=m;i++){
        cin>>b;
        if(b>amax) bmax = b;
        }
    cout<<amax<<" "<<bmax;
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int n, m, i, a, b, amax = 0, bmax = 0;
    cin>>n;
    for(i = 1;i<=n;i++){
        cin>>a;
        if(a>amax) amax = a;
        }
    cin>>m;
    for(i = 1;i<=m;i++){
        cin>>b;
        if(b>bmax) bmax = b;
        }
    cout<<amax<<" "<<bmax;
    return 0;
}


#include <cstdio>

using namespace std;

int va[1005], vb[1005];

int main()
{
    int a, b, A, B, maxxa = -1, maxxb = -1;
    scanf("%d", &A);
    for(int i = 1; i <= A; ++ i)
    {
        scanf("%d", &va[i]);
        if (va[i]>maxxa)
        maxxa=va[i];
    }
    scanf("%d", &B);
    for(int i = 1; i <= B; ++ i)
    {
        scanf("%d", &vb[i]);
        if (vb[i]>maxxb)
        maxxb=vb[i];
    }
    printf("%d %d", maxxa, maxxb);
    return 0;
}


#include <cstdio>

using namespace std;

int va[1005], vb[1005];

int main()
{
    int a, b, A, B, maxxa = -1, maxxb = -1;
    scanf("%d", &A);
    for(int i = 1; i <= A; ++ i)
    {
        scanf("%d", &va[i]);
        if (va[i]>maxxa)
        maxxa=va[i];
    }
    scanf("%d", &B);
    for(int i = 1; i <= B; ++ i)
    {
        scanf("%d", &vb[i]);
        if (va[i]>maxxb)
        maxxb=vb[i];
    }
    printf("%d %d", maxxa, maxxb);
    return 0;
}


#include <iostream>

using namespace std;

struct TaskData
{
	int size1;
	int size2;
	int max1 = 0;
	int max2 = 0;
	int* firstArray;
	int* secondArray;
};

void InputValues(TaskData*);
void SetMaxValues(TaskData*);

int main()
{
	TaskData data;
	InputValues(&data);
	SetMaxValues(&data);
	cout << data.max1 << " " << data.max2;
	return 0;
}

void InputValues(TaskData* data)
{
	cin >> data->size1;
	data->firstArray = new int[data->size1];
	for (int i = 0; i < data->size1; ++i)
		cin >> data->firstArray[i];
	cin >> data->size2;
	data->secondArray = new int[data->size2];
	for (int i = 0; i < data->size2; ++i)
		cin >> data->secondArray[i];
}

void SetMaxValues(TaskData* data)
{
	for (int i = 0; i < data->size1; ++i)
		data->max1 = data->firstArray[i] > data->max1 ? data->firstArray[i] : data->max1;
	for (int i = 0; i < data->size2; ++i)
		data->max2 = data->secondArray[i] > data->max2 ? data->secondArray[i] : data->max2;
}


#include <iostream>
using namespace std;
struct TaskData
{
	int size1;
	int size2;
	int max1 = 0;
	int max2 = 0;
	int* firstArray;
	int* secondArray;
};

void InputValues(TaskData*);
void SetMaxValues(TaskData*);

int main()
{
	TaskData data;
	InputValues(&data);
	SetMaxValues(&data);
	cout << data.max1 << " " << data.max2;
	return 0;
}

void InputValues(TaskData* data)
{
	cin >> data->size1;
	data->firstArray = new int[data->size1];
	for (int i = 0; i < data->size1; ++i)
		cin >> data->firstArray[i];
	cin >> data->size2;
	data->secondArray = new int[data->size2];
	for (int i = 0; i < data->size2; ++i)
		cin >> data->secondArray[i];
}

void SetMaxValues(TaskData* data)
{
	for (int i = 0; i < data->size1; ++i)
		data->max1 = data->firstArray[i] > data->max1 ? data->firstArray[i] : data->max1;
	for (int i = 0; i < data->size2; ++i)
		data->max2 = data->secondArray[i] > data->max2 ? data->secondArray[i] : data->max2;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;

int main(){
	int A[1000], B[1000];
	int book[1000] = { 0 };
	int a, b;
	cin >> a;
	for (int i = 0; i < a; i++){
		cin >> A[i];
		book[A[i]] = 1;
	}
	cin >> b;
	for (int i = 0; i < b; i++){
		cin >> B[i];
		book[B[i]] = 1;
	}
	for (int i = 0; i < a; i++){
		for (int j = 0; j < b; j++){
			if (!book[A[i] + B[j]]){
				cout << A[i] << " " << B[j];
				return 0;
			}
		}
	}
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;

int main(){
	int A[1000], B[1000];
	int bA[1000] = { 0 }, bB[1000] = {0};
	int a, b;
	cin >> a;
	for (int i = 0; i < a; i++){
		cin >> A[i];
		bA[A[i]] = 1;
	}
	cin >> b;
	for (int i = 0; i < a; i++){
		cin >> B[i];
		bB[B[i]] = 1;
	}
	for (int i = 0; i < a; i++){
		for (int j = 0; j < b; j++){
			if (!bA[A[i] + B[j]] && !bB[A[i] + B[j]]){
				cout << A[i] << " " << B[j];
				return 0;
			}
		}
	}
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;

int main(){
	int A[1000], B[1000];
	int book[1000] = { 0 };
	int a, b;
	cin >> a;
	for (int i = 0; i < a; i++){
		cin >> A[i];
		book[A[i]] = 1;
	}
	cin >> b;
	for (int i = 0; i < a; i++){
		cin >> B[i];
		book[B[i]] = 1;
	}
	for (int i = 0; i < a; i++){
		for (int j = 0; j < b; j++){
			if (!book[A[i] + B[j]]){
				cout << A[i] << " " << B[j];
				return 0;
			}
		}
	}
	return 0;
}


#include <iostream>

using namespace std;
int A,B;
int a[100],b[100];
int main()
{
    cin >> A;
    for (int i=0;i<A;i++)
        cin >> a[i];
    cin >> B;
    for (int i=0;i<B;i++)
        cin >> b[i];
    for (int i=0;i<A;i++)
        for (int w=i+1;i<A;i++)
    {
        if (a[i]<a[w])
        {
            int s;
            s=a[i];
            a[i]=a[w];
            a[w]=s;
        }
    }
    for (int i=0;i<B;i++)
        for (int w=i+1;i<B;i++)
    {
        if (b[i]<b[w])
        {
            int s;
            s=b[i];
            b[i]=b[w];
            b[w]=s;
        }
    }
    cout << a[0] << " " << b[0];
    return 0;
}


#include <iostream>

using namespace std;
int A,B;
int a,b;
int s,d;
int main()
{
    cin >> A;
    for (int i=0;i<A;i++)
        {cin >> s;
        if (s>a)
            a=s;}
    cin >> B;
    for (int i=0;i<B;i++)
        {cin >> d;
         if (d>b)
            b=d;}

    cout << a << " " << b;
    return 0;
}


#include <iostream>
#include <vector>
using namespace std;
int main() {
	int l1, l2, m1=0, m2=0;
	cin >> l1;
	vector <int> A(l1);
	for (int i = 0;i < l1;i++) {
		cin >> A[i];
		if (A[i] > m1){
			m1 = A[i];
		}
	}
	cin >> l2;
	vector <int> B(l2);
	for (int i = 0;i < l2;i++) {
		cin >> B[i];
		if (B[i] > m2) {
			m2 = B[i];
		}
	}
	cout << m1 << ' ' << m2 << endl;
}


#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
    int n=0, m=0;
    int A[100]={};
    int B[100]={};

    cin>>n;

    for(int i=0;i<n;i++)
    {
        cin>>A[i];
    }
        for(int i=0;i<n;i++)
    {
       cout<<A[i]<<" ";
    }

    cin>>m;

        for(int i=0;i<n;i++)
    {
        cin>>B[i];
    }
        for(int i=0;i<m;i++)
    {
       cout<<B[i]<<" ";
    }

    sort(A, A+n);
    sort(B, B+n);

    cout<<A[n-1]<<" "<<B[n-1]<<endl;
}


#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
    int n=0, m=0;
    int A[100]={};
    int B[100]={};

    cin>>n;

    for(int i=0;i<n;i++)
    {
        cin>>A[i];
    }

    cin>>m;

        for(int i=0;i<m;i++)
    {
        cin>>B[i];
    }

    sort(A, A+n);
    sort(B, B+m);

    cout<<A[n-1]<<" "<<B[m-1]<<endl;
}


#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
    int n=0, m=0;
    int A[100]={};
    int B[100]={};

    cin>>n;

    for(int i=0;i<n;i++)
    {
        cin>>A[i];
    }
        for(int i=0;i<n;i++)
    {
       cout<<A[i]<<" ";
    }

    cin>>m;

        for(int i=0;i<n;i++)
    {
        cin>>B[i];
    }
        for(int i=0;i<m;i++)
    {
       cout<<B[i]<<" ";
    }

    sort(A, A+n);
    sort(B, B+n);

    cout<<A[n-1]<<B[n-1]<<endl;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,i,count1=0,count2=0;
    cin>>n;
    string s,p,l,t;
    for(i=0; i<n; i++)
    {
        cin>>s;
        if(i==0)
        {
            count1++;
            p=s;

        }
        else
        {
            if(s!=p)
            {
                count2++;
                l=s;
            }
            else
            {
                count1++;
                t=s;
            }
            p=s;
        }

    }
    if(n==1)
        cout<<s;

    else if(count1>count2)
        cout<<l;
    else
        cout<<t;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,i,count1=1,count2=0;
    cin>>n;
    string s,p,z;
    for(i=0;i<n;i++)
    {
        cin>>s;
        if(i==0)
        p=s;
        else
        {
            if(s==p)
                count1++;
            else
                count2++;
        }

    }
   /// cout<<count1<<" "<<count2<<endl;
    if(count1>=count2)
        cout<<p;
    else
        cout<<s;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    long long int n,i, count1=1,count2=0;
    cin>>n;
    string s,p,z;
    for(i=0; i<n; i++)
    {
        cin>>s;
        if(i==0)
            p=s;
        else
        {
            if(s==p)
                count1++;
            else
            {
                z=s;
                count2++;
            }
        }

    }
    /// cout<<count1<<" "<<count2<<endl;
    if(count1>count2)
        cout<<p;
    else
        cout<<z;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    long long int n,i, count1=1,count2=0;
    scanf("%lld",&n);
    string s,p,z;
    for(i=0; i<n; i++)
    {
        cin>>s;
        if(i==0)
            p=s;
        else
        {
            if(s==p)
                count1++;
            else
                count2++;
        }

    }
   /// cout<<count1<<" "<<count2<<endl;
    if(count1>count2)

        cout<<p;
    else
        cout<<s;
}


#include<cstring>
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
    int s1 = 0, s2 = 0, n, i;
    char temp[11], temp1[11], temp2[11];
    scanf("%d", &n);
    scanf("%s", temp);
    s1++;
    for(i = 2; i <= n; i++)
    {
        scanf("%s", temp2);
        if(strcmp(temp, temp2) == 0)
            s1++;
        else
        {
            s2++;
            strcpy(temp1, temp2);
        }
    }
    if(s1 > s2)
        cout<<temp<<endl;
    else
        cout<<temp1<<endl;
    return 0;
}


#include<cstring>
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
    int s1 = 0, s2 = 0, n, i;
    char temp[11], temp1[11], temp2[11];
    scanf("%d", &n);
    if(n == 0)
        return;
    scanf("%s", temp);
    s1++;
    for(i = 2; i <= n; i++)
    {
        scanf("%s", temp2);
        if(strcmp(temp, temp2) == 0)
            s1++;
        else
        {
            s2++;
            strcpy(temp2, temp1);
        }
    }
    if(s1 > s2)
        cout<<temp<<endl;
    else
        cout<<temp1<<endl;
    return 0;
}


#include<iostream>
#include<cstring>
#include<cstdio>
int main()
{
	int s1 = 0, s2 = 0, n, i, j;
	char temp[11], temp1[11], temp2[11];
	scanf("%d", &n);
	getchar();
	std::cin.getline(temp, 11);
	s1++;
	for(i = 2; i <= n; i++)
	{
		std::cin.getline(temp2, 11);
		if(strcmp(temp, temp2) == 0)
			s1++;
		else
		{
			s2++;
			for(j = 0; j <= strlen(temp2); j++)
				temp1[j] = temp2[j];
		}
	}
	if(s1 > s2)
		for(i = 0; i <= strlen(temp); i++)
			printf("%c", temp[i]);
	else
		for(i = 0; i <= strlen(temp1); i++)
			printf("%c", temp1[i]);
	printf("\n");
}


#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
 int i,n,s1 = 0,s2 = 0;
 char temp[11],temp1[11],temp2[11];
 scanf("%d",&n);
 for(i=0;i<n;i++)
 {
  scanf("%s",temp2);
  if(i==0)
  {
   strcpy(temp2,temp);
   s1++;
  }
  else if(strcmp(temp,temp2)==0)
  s1++;
  else
  {
   strcpy(temp2,temp1);
   s2++;
  }
 }
 if(s1>s2)
 cout<<temp<<"\n";
 else
 cout<<temp1<<"\n";
 return(0);
}


#include<iostream>
#include<cstring>
#include<cstdio>
int main()
{
    int s1 = 0, s2 = 0, n, i, j;
    char temp[11], temp1[11], temp2[11];
    scanf("%d", &n);
    getchar();
    std::cin.getline(temp, 10);
    s1++;
    for(i = 2; i <= n; i++)
    {
        std::cin.getline(temp2, 10);
        if(strcmp(temp, temp2) == 0)
            s1++;
        else
        {
            s2++;
            for(j = 0; j <= strlen(temp2); j++)
                temp1[j] = temp2[j];
        }
    }
    if(s1 > s2)
        for(i = 0; i <= strlen(temp); i++)
            printf("%c", temp[i]);
    else
        for(i = 0; i <= strlen(temp1); i++)
            printf("%c", temp1[i]);
    printf("\n");
}


#include<cstring>
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
	int s1 = 0, s2 = 0, n, i;
	char temp[11], temp1[11], temp2[11];
	scanf("%d", &n);
	scanf("%s", temp);
	s1++;
	for(i = 2; i <= n; i++)
	{
		scanf("%s", temp2);
		if(strcmp(temp, temp2) == 0)
			s1++;
		else
		{
			s2++;
			strcpy(temp2, temp1);
		}
	}
	if(s1 > s2)
		cout<<temp<<endl;
	else
		cout<<temp1<<endl;
	return 0;
}


#include<iostream>
#include<cstring>
#include<cstdio>
int main()
{
    int s1 = 0, s2 = 0, n, i, j;
    char temp[11], temp1[11], temp2[11];
    scanf("%d", &n);
    getchar();
    std::cin.getline(temp, 10);
    s1++;
    for(i = 2; i <= n; i++)
    {
        std::cin.getline(temp2, 10);
        if(strcmp(temp, temp2) == 0)
            s1++;
        else
        {
            s2++;
            for(j = 0; j <= strlen(temp2); j++)
                temp1[j] = temp2[j];
        }
    }
    if(s1 > s2)
        for(i = 0; i <= strlen(temp); i++)
            printf("%c", temp[i]);
    else
        for(i = 0; i <= strlen(temp1); i++)
            printf("%c", temp1[i]);
}


#include<cstring>
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
    int s1 = 0, s2 = 0, n, i;
    char temp[11], temp1[11], temp2[11];
    scanf("%d", &n);
    if(n == 0)
        return 0;
    scanf("%s", temp);
    s1++;
    for(i = 2; i <= n; i++)
    {
        scanf("%s", temp2);
        if(strcmp(temp, temp2) == 0)
            s1++;
        else
        {
            s2++;
            strcpy(temp1, temp2);
        }
    }
    if(s1 > s2)
        cout<<temp<<endl;
    else
        cout<<temp1<<endl;
    return 0;
}


#include<cstring>
#include<stdio.h>
#include<iostream>
using namespace std;
int main()
{
	int s1 = 0, s2 = 0, n, i, j;
	char temp[11], temp1[11], temp2[11];
	scanf("%d", &n);
	scanf("%s", temp);
	s1++;
	for(i = 2; i <= n; i++)
	{
		scanf("%s", temp2);
		if(strcmp(temp, temp2) == 0)
			s1++;
		else
		{
			s2++;
			strcpy(temp2, temp1);
		}
	}
	if(s1 > s2)
		cout<<temp<<endl;
	else
		cout<<temp1<<endl;
	return 0;
}


#include<cstring>
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
    int s1 = 0, s2 = 0, n, i;
    char temp[11], temp1[11], temp2[11];
    scanf("%d", &n);
    if(n == 0)
        return 0;
    scanf("%s", temp);
    s1++;
    for(i = 2; i <= n; i++)
    {
        scanf("%s", temp2);
        if(strcmp(temp, temp2) == 0)
            s1++;
        else
        {
            s2++;
            strcpy(temp2, temp1);
        }
    }
    if(s1 > s2)
        cout<<temp<<endl;
    else
        cout<<temp1<<endl;
    return 0;
}