#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<math.h>

using namespace std;

const double pi = 3.1415926535897932384626433832795028;

int main() {
	cout.precision(17);

	int n, d;
	cin >> n >> d;
	vector<int> buildings;
	for (int i = 0; i < n; i++) {
		int num;
		cin >> num;
		buildings.push_back(num);
	}
	int m;
	cin >> m;
	int current = 0;
	for (int c = 1; c <= m; c++) {

		int x;
		cin >> x;
		double alpha = pi;
		while (current < n && buildings[current] < x) current++;
		int left = current - 1;
		int right = current;
		int dist;
		if (right < n && (left < 0 || buildings[right] - x <= x - buildings[left] - 1)) {
			dist = buildings[right] - x;
			if (dist == 0) alpha = pi / 2.0;
			else alpha = atan(1.0 / double(dist));
		}
		else if (left >= 0 && (right >= n || buildings[right] - x > x - buildings[left] - 1)) {
			dist = x - buildings[left] - 1;
			if (dist == 0) alpha = pi / 2.0;
			else alpha = atan(1.0 / double(dist));
		}
		bool cont = true;
		if (left < 0) cont = false;
		if (right >= n) cont = false;
		while (cont) {
			if (buildings[right] - x < x - buildings[left] - 2) right++;
			else if (buildings[right] - x > x - buildings[left]) left--;
			else {
				int dist2 = max(buildings[right] - x, x - buildings[left] - 1);
				double candidate;
				if (dist2 == 0) candidate = pi;
				else candidate = 2.0 * atan(1.0 / double(dist2));
				if (candidate > alpha) alpha = candidate;
				cont = false;
			}
			if (left < 0) cont = false;
			if (right >= n) cont = false;
			if (right >= 2 * dist + 5) cont = false;
		}

		cout << alpha;

	}

	return 0;
}


#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<math.h>

using namespace std;

const double pi = 3.1415926535897932384626433832795028;

int main() {
	cout.precision(17);

	int n, d;
	cin >> n >> d;
	vector<int> buildings;
	for (int i = 0; i < n; i++) {
		int num;
		cin >> num;
		buildings.push_back(num);
	}
	int m;
	cin >> m;
	int current = 0;
	for (int c = 1; c <= m; c++) {

		int x;
		cin >> x;
		double alpha = pi;
		while (current < n && buildings[current] < x) current++;
		int left = current - 1;
		int right = current;
		int dist;
		if (right < n && (left < 0 || buildings[right] - x <= x - buildings[left] - 1)) {
			dist = buildings[right] - x;
			if (dist == 0) alpha = pi / 2.0;
			else alpha = atan2(1.0, double(dist));
		}
		else if (left >= 0 && (right >= n || buildings[right] - x > x - buildings[left] - 1)) {
			dist = x - buildings[left] - 1;
			if (dist == 0) alpha = pi / 2.0;
			else alpha = atan2(1.0, double(dist));
		}
		bool cont = true;
		if (left < 0) cont = false;
		if (right >= n) cont = false;
		while (cont) {
			if (buildings[right] - x < x - buildings[left] - 2) right++;
			else if (buildings[right] - x > x - buildings[left]) left--;
			else {
				int dist2 = max(buildings[right] - x, x - buildings[left] - 1);
				double candidate;
				if (dist2 == 0) candidate = pi;
				else candidate = 2.0 * atan2(1.0, double(dist2));
				if (candidate > alpha) alpha = candidate;
				cont = false;
			}
			if (left < 0) cont = false;
			if (right >= n) cont = false;
			if (x - buildings[left] >= 2 * dist + 5) cont = false;
			if (buildings[right] - x >= 2 * dist + 5) cont = false;
		}

		cout << alpha << endl;

	}

	return 0;
}


import java.io.*;
import java.util.*;

public class CF1167G {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw = new PrintWriter(System.out);
		StringTokenizer st = new StringTokenizer(br.readLine());
		int n = Integer.parseInt(st.nextToken());
		int d = Integer.parseInt(st.nextToken());
		st = new StringTokenizer(br.readLine());
		int[] aa = new int[n];
		for (int i = 0; i < n; i++)
			aa[i] = Integer.parseInt(st.nextToken());
		int m = Integer.parseInt(br.readLine());
		st = new StringTokenizer(br.readLine());
		while (m-- > 0) {
			int x = Integer.parseInt(st.nextToken());
			if (x == 0 || x == aa[n - 1] + 1) {
				pw.println(Math.PI / 2);
				continue;
			}
			int lower = 0, upper = n - 1;
			while (upper - lower > 1) {
				int i = (lower + upper) / 2;
				if (aa[i] < x)
					lower = i;
				else
					upper = i;
			}
			int di = x - aa[lower] - 1;
			int dj = aa[upper] - x;
			if (di == 0 && dj == 0) {
				pw.println(Math.PI);
				continue;
			} else if (di == 0 || dj == 0) {
				pw.println(Math.PI / 2);
				continue;
			}
			double alpha = Math.atan(1.0 / Math.min(di, dj));
			int d_ = (int) (1 / Math.tan(alpha / 2) + 10);
			for (int i = lower, j = upper; i >= 0 && j < n && (di = x - aa[i] - 1) < d_ && (dj = aa[j] - x) < d_; ) {
				if (Math.abs(di - dj) <= 1) {
					double beta = Math.atan(1.0 / Math.max(di, dj)) * 2;
					if (alpha < beta)
						alpha = beta;
					break;
				}
				if (di < dj)
					i--;
				else
					j++;
			}
			pw.println(alpha);
		}
		pw.close();
	}
}


#include<bits/stdc++.h>
using namespace std;
int main(void)
{
    int n, m, i;
    cin>>n;
    int a[n];
    for(i = 0; i < n; i++)
        cin>>a[i];
    sort(a, a + n, greater<int>());
    cin>>m;
    int b[m];
    for(i = 0; i < m; i++)
        cin>>b[i];
    sort(b, b + m, greater<int>());
    cout<<a[0]<<" "<<b[0]<<endl;
}


#include<bits/stdc++.h>
using namespace std;
int main(void)
{
    int n, m, i;
    cin>>n;
    int a[n];
    for(i = 0; i < n; i++)
        cin>>a[i];
    sort(a, a + n, greater<int>());
     for(i = 0; i < n; i++)
        cout<<a[i]<<" ";
        cout<<endl;
    cin>>m;
    int b[m];
    for(i = 0; i < m; i++)
        cin>>b[i];
    sort(b, b + m, greater<int>());
    cout<<a[0]<<" "<<b[0]<<endl;
}


#include<bits/stdc++.h>
using namespace std;
int main(void)
{
    int na, nb, i;
    cin>>na;
    int a[na];
    for(i = 0; i < na; i++)
    {
        cin>>a[i];
    }
    cin>>nb;
    int b[nb];
    for(i = 0; i < nb; i++)
    {
        cin>>b[i];
    }
    for(i = 0; i < nb> na ? nb : na; i++)
    {
        if(a[i]+b[i] != a[i] && a[i]+b[i] != b[i])
            cout<<a[i]<<" "<<b[i];
        break;
    }

}


#include<bits/stdc++.h>
using namespace std;
int main(void)
{
    int na, nb, i;
    cin>>na;
    int a[na];
    for(i = 0; i < na; i++)
    {
        cin>>a[i];
    }
    sort(a, a + na);
    cin>>nb;
    int b[nb];
    for(i = 0; i < nb; i++)
    {
        cin>>b[i];
    }
    sort(b, b + nb);
    for(i = 0; i < nb > na ? nb : na; i++)
    {
        if(a[i]+b[i] != a[i] && a[i]+b[i] != b[i])
            cout<<a[i]<<" "<<b[i];
        break;
    }

}


#include<bits/stdc++.h>
using namespace std;
int main(void)
{
    int na, nb, i;
    cin>>na;
    int a[na];
    for(i = 0; i < na; i++)
    {
        cin>>a[i];
    }
    sort(a, a + na);
    cin>>nb;
    int b[nb];
    for(i = 0; i < nb; i++)
    {
        cin>>b[i];
    }
    sort(b, b + nb);
    for(i = 0; i < nb > na ? nb : na; i++)
    {
        if(a[i]+b[i] != a[i] && a[i]+b[i] != b[i])
        {
            cout<<a[i]<<" "<<b[i];
            break;
        }
    }
}


#include <bits/stdc++.h>

const int N = 1e5;

int a[N], b[N];
int in1, in2;

bool flag;

int main() {

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

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

  for (int i = 0; i < in1; i++) {
    for (int j = 0; j < in2; j++) {

      flag = 0;
      int temp = a[i] + b[j];

      for (int k = 0; k < in1; k++) {
        if (temp == a[k]) {
          flag = true;
          break;
        }
      }

      if (flag) break;

      for (int k = 0; k < in2; k++) {
        if (temp == b[k]) {
          flag = true;
          break;
        }
      }

      if (!flag) {
        std::cout << a[i] << ' ' << b[j];
      }
    }
  }
  return 0;
}


#include <bits/stdc++.h>

const int N = 1e5;

int a[N], b[N];
int in1, in2;

bool flag;

int main() {

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

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

  for (int i = 0; i < in1; i++) {
    for (int j = 0; j < in2; j++) {

      flag = 0;
      int temp = a[i] + b[j];

      for (int k = 0; k < in1; k++) {
        if (temp == a[k]) {
          flag++;
          break;
        }
      }

      if (flag) break;

      for (int k = 0; k < in2; k++) {
        if (temp == b[k]) {
          flag++;
          break;
        }
      }

      if (!flag) {
        std::cout << a[i] << ' ' << b[j];
      }
    }
  }
  return 0;
}


#include <bits/stdc++.h>

const int N = 1e5;

int a[N], b[N];
int in1, in2;

bool flag;

int main() {

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

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

  for (int i = 0; i < in1; i++) {
    for (int j = 0; j < in2; j++) {

      flag = 0;
      int temp = a[i] + b[j];

      for (int k = 0; k < in1; k++) {
        if (temp == a[k]) {
          flag = true;
          break;
        }
      }

      if (flag) break;

      for (int k = 0; k < in2; k++) {
        if (temp == b[k]) {
          flag = true;
          break;
        }
      }

      if (!flag) {
        std::cout << a[i] << ' ' << b[j];
        return 0;
      }
    }
  }
  return 0;
}


#include <bits/stdc++.h>

const int N = 1e5;

int a[N], b[N];
int in1, int2;

bool falg;

int main() {

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

  std::cin >> in2;
  for (int i = 0; i < in2) {
    std::cin >> b[i];
  }

  for (int i = 0; i < in1; i++) {
    for (int j = 0; j < in2; j++) {

      flag = 0;
      int temp = a[i] + b[j];

      for (int k = 0; k < in1; k++) {
        if (temp == a[k]) {
          falg++;
          break;
        }
      }

      if (flag) break;

      for (int k = 0; k < in2; k++) {
        if (temp == b[k]) {
          falg++;
          break;
        }
      }

      if (!flag) {
        std::cout << a[i] << ' ' << b[j];
      }
    }
  }
  return 0;
}


#include <bits/stdc++.h>

const int N = 1e5;

int a[N], b[N];
int in1, in2;

bool falg;

int main() {

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

  std::cin >> in2;
  for (int i = 0; i < in2) {
    std::cin >> b[i];
  }

  for (int i = 0; i < in1; i++) {
    for (int j = 0; j < in2; j++) {

      flag = 0;
      int temp = a[i] + b[j];

      for (int k = 0; k < in1; k++) {
        if (temp == a[k]) {
          falg++;
          break;
        }
      }

      if (flag) break;

      for (int k = 0; k < in2; k++) {
        if (temp == b[k]) {
          falg++;
          break;
        }
      }

      if (!flag) {
        std::cout << a[i] << ' ' << b[j];
      }
    }
  }
  return 0;
}


#include <bits/stdc++.h>

const int N = 1e5;

int a[N], b[N];
int in1, in2;

bool flag;

int main() {

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

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

  for (int i = 0; i < in1; i++) {
    for (int j = 0; j < in2; j++) {

      flag = 0;
      int temp = a[i] + b[j];

      for (int k = 0; k < in1; k++) {
        if (temp == a[k]) {
          falg++;
          break;
        }
      }

      if (flag) break;

      for (int k = 0; k < in2; k++) {
        if (temp == b[k]) {
          falg++;
          break;
        }
      }

      if (!flag) {
        std::cout << a[i] << ' ' << b[j];
      }
    }
  }
  return 0;
}


#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int main()
{
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n,m;
    int a[101],b[101];
    cin>>n;
    for (int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    cin>>m;
    for (int k=0;k<m;k++)
    {
        cin>>b[k];
    }
    long long x;int a1,b1;bool f1=true,f2=true,f=false;

    for (int i=0;i<n;i++)
    {
    for (int k=0;k<m;k++)
    {
        f1=true,f2=true;
        x=(a[i]+b[k]);
        for (int i=0;i<n;i++)
        {
            if (x==a[i])
            {
                f1=false;
                break;
            }
        }

        for (int i=0;i<m;i++)
        {
            if (x==b[i])
            {
                f2=false;

            }
        }

            if (f1&&f2)
            {
                cout << a[i] << " " << b[i] <<endl;
                return 0;
            }
    }

    }

cout<<a1<<" "<<b1;

}


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

long long x;
int a1,b1;
bool f1=true,f2=true;
int n,m;
int a[101],b[101];

int main()
{
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin>>n;
    for (int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    cin>>m;
    for (int k=0;k<m;k++)
    {
        cin>>b[k];
    }

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

        f1=true,f2=true;
         for(x=0; x<n;x++)
            {
                if(a[i]+b[j]== a[x])
                {
                  f1=false;
                }
            }

            for(c=0; c<m; c++){
                if(a[i]+b[j]==b[x])
                {
                  f2=false;
                }

            }

        if (f1&&f2)
        {
            cout << a[i] << " " << b[i] <<endl;
            return 0;
        }

    }

    }

return 0;
}


#include <iostream>
using namespace std;

bool flag1 = true ;
bool flag2 = true ;

int main()
{
    int a[100], b[100], n , m , r ,s;
    cin>>n;
    int i , j ,x ,c , sum=0;
    for(i=0; i<n; i++){
        cin>>a[i];}
    cin>>m;
    for(j=0;j<m;j++){
        cin>>b[j];}
    for(i=0; i<n;i++){
        for(j=0; j<m; j++){
            sum=a[i]+b[j];

            for(x=0; x<n;x++)
            {
                if(sum== a[x])
                {
                  flag1=false;
                }
            }

            for(c=0; c<m; c++){
                if(sum == b[c])
                {
                     flag2=false;
                }

            }

             if(flag1&&flag2)
             {
                 cout << a[i] << " " << b[j]<<endl;
                 return 0;
             }

             sum = 0;
             flag1=true;
             flag2=true;

            }

            }

    return 0;
}


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

int a1,b1;
bool f1=true,f2=true;
int n,m;
int a[101],b[101];

int main()
{
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin>>n;
    for (int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    cin>>m;
    for (int k=0;k<m;k++)
    {
        cin>>b[k];
    }

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

        f1=true,f2=true;
         for(int x=0; x<n;x++)
            {
                if(a[i]+b[j]== a[x])
                {
                  f1=false;
                }
            }

            for(int y=0; y<m; y++){
                if(a[i]+b[j]==b[y])
                {
                  f2=false;
                }

            }

        if (f1&&f2)
        {
            cout << a[i] << " " << b[i] <<endl;
            return 0;
        }

    }

    }

return 0;
}


#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int main()
{
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n,m;
    int a[101],b[101];
    cin>>n;
    for (int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    cin>>m;
    for (int k=0;k<m;k++)
    {
        cin>>b[k];
    }
    long long x;int a1,b1;bool f1=true,f2=true,f=false;

    for (int i=0;i<n;i++)
    {
    for (int k=0;k<m;k++)
    {
        f1=true,f2=true;
        x=(a[i]+b[k]);
        for (int i=0;i<n;i++)
        {
            if (x==a[i])
            {
                f1=false;
                break;
            }
        }

        for (int i=0;i<m;i++)
        {
            if (x==b[i])
            {
                f2=false;
                break;
            }
        }
            if (f1==true&&f2==true)
            {
                    a1=a[i],b1=b[i];
                    f=true;
                    break;
            }
    }

    if (f==true)
    {
        break;
    }

    }

cout<<a1<<" "<<b1;

}


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

int main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    int m;
    cin>>m;
    int b[m];
    for(int i=0;i<m;i++)
        cin>>b[i];
    int sum;
    int flag=2;
    int l,r,c;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            sum=a[i]+b[j];
            // cout<<a[i]<<" "<<b[j]<<" "<<sum <<endl;

            for(int k=0;k<n;k++)
            {
            	// cout<<sum<<" "<<a[k]<<endl;
                if(sum==a[k])
                {

                    flag=0;
                }

            }
            // cout<<1<<" "<<flag<<endl;
            for(int k=0;k<m;k++)
            {
                if(sum==b[k])
                {
                    flag=0;
                }

            }

            if(flag==2)
            {

            	c=3;
            	l=a[i];
            	r=b[j];

            }

        }
    }
    if(c==3)
        cout<<l<<" "<<r<<endl;
}


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

        int main()
        {
        #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif

            int n;
            cin>>n;
            int a[n];
            for(int i=0;i<n;i++)
                cin>>a[i];
            int m;
            cin>>m;
            int b[m];
            for(int i=0;i<m;i++)
                cin>>b[i];
            int sum;
            int flag=2;
            int l,r,c=0;
            for(int i=0;i<n;i++)
            {
                for(int j=0;j<m;j++)
                {
                    sum=a[i]+b[j];
                   	flag=2;
                    for(int k=0;k<n;k++)
                    {
                    	// cout<<sum<<" "<<a[k]<<endl;
                        if(sum==a[k])
                        {

                            flag=0;
                        }

                    }
                    // cout<<1<<" "<<flag<<endl;
                    if(flag==2)
                    {
                    	for(int k=0;k<m;k++)
                    	{
                        	if(sum==b[k])
                        	{
                            	flag=0;
                        	}

                    	}
                    }

                    if(flag==2)
                    {
            			c=1;
                    	l=a[i];
                    	r=b[j];
                    	break;
                    	// cout<<l<<" "<<r<<endl;

                    }

                }

                if(c)
                	break;

            }
            if(c==1)
            	cout<<l<<" "<<r<<endl;

        }


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

    int main()
    {
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif

        int n;
        cin>>n;
        int a[n];
        for(int i=0;i<n;i++)
            cin>>a[i];
        int m;
        cin>>m;
        int b[m];
        for(int i=0;i<m;i++)
            cin>>b[i];
        int sum;
        int flag=2;
        int l,r,c;
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                sum=a[i]+b[j];
               	flag=2;
                for(int k=0;k<n;k++)
                {
                	// cout<<sum<<" "<<a[k]<<endl;
                    if(sum==a[k])
                    {

                        flag=0;
                    }

                }
                // cout<<1<<" "<<flag<<endl;
                if(flag==2)
                {
                	for(int k=0;k<m;k++)
                	{
                    	if(sum==b[k])
                    	{
                        	flag=0;
                    	}

                	}
                }

                if(flag==2)
                {
        			c=1;
                	l=a[i];
                	r=b[j];
                	break;
                	// cout<<l<<" "<<r<<endl;

                }

            }

            if(c)
            	break;

        }
        if(c==1)
        	cout<<l<<" "<<r<<endl;

    }


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

int main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    int m;
    cin>>m;
    int b[m];
    for(int i=0;i<m;i++)
        cin>>b[i];
    int sum;
    int flag=2;
    int l,r,c;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            sum=a[i]+b[j];
            // cout<<a[i]<<" "<<b[j]<<" "<<sum <<endl;

            for(int k=0;k<n;k++)
            {
            	// cout<<sum<<" "<<a[k]<<endl;
                if(sum==a[k])
                {

                    flag=0;
                }

            }
            // cout<<1<<" "<<flag<<endl;
            for(int k=0;k<m;k++)
            {
                if(sum==b[k])
                {
                    flag=0;
                }

            }

            if(flag==2)
            {

            	l=a[i];
            	r=b[j];
            	cout<<l<<" "<<r<<endl;
            	break;

            }

        }
        if(flag==2)
        	break;
    }

}


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

int main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    int m;
    cin>>m;
    int b[m];
    for(int i=0;i<m;i++)
        cin>>b[i];
    int sum;
    int flag=0;
    int l,r;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            sum=a[i]+b[j];
            l=a[i];
            r=b[j];
            for(int i=0;i<n;i++)
            {
            for(int j=0;j<m;j++)
            {
                if(sum==a[i] || sum== b[j])
                    flag=1;
            }
            }
        }
    }
    if(flag==0)
        cout<<l<<" "<<r<<endl;
}


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

int main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    int m;
    cin>>m;
    int b[m];
    for(int i=0;i<m;i++)
        cin>>b[i];
    int sum;
    int flag=0;
    int l,r;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            sum=a[i]+b[j];
            l=a[i];
            r=b[j];
            for(int i=0;i<n;i++)
            {
            for(int j=0;j<m;j++)
            {
                if(sum!=a[i] && sum!= b[j])
                    flag=1;
            }
            }
        }
    }
    if(flag==1)
        cout<<l<<" "<<r<<endl;
}


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

int main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    int m;
    cin>>m;
    int b[m];
    for(int i=0;i<m;i++)
        cin>>b[i];
    int sum;
    int flag=0;
    int l,r;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            sum=a[i]+b[j];
            l=a[i];
            r=b[j];
            for(int i=0;i<n;i++)
            {
            for(int j=0;j<m;j++)
            {
                if(sum!=a[i] || sum!= b[j])
                    flag=1;
            }
            }
        }
    }
    if(flag==1)
        cout<<l<<" "<<r<<endl;
}


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

int main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    int m;
    cin>>m;
    int b[m];
    for(int i=0;i<m;i++)
        cin>>b[i];
    int sum;
    int flag=2;
    int l,r,c;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            sum=a[i]+b[j];

            for(int k=0;k<n;k++)
            {
            	// cout<<sum<<" "<<a[k]<<endl;
                if(sum==a[k])
                {

                    flag=0;
                }

            }
            // cout<<1<<" "<<flag<<endl;
            if(flag==2)
            {
            	for(int k=0;k<m;k++)
            	{
                	if(sum==b[k])
                	{
                    	flag=0;
                	}

            	}
            }

            if(flag==2)
            {
    			c=1;
            	l=a[i];
            	r=b[j];
            	break;
            	// cout<<l<<" "<<r<<endl;

            }

        }

        if(c)
        	break;

    }
    if(c==1)
    	cout<<l<<" "<<r<<endl;

}


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

int main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    int m;
    cin>>m;
    int b[m];
    for(int i=0;i<m;i++)
        cin>>b[i];
    int sum;
    int flag=1;
    int l,r;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            sum=a[i]+b[j];
            l=a[i];
            r=b[j];
            for(int k=0;k<n;k++)
            {
                if(sum==a[k])
                    flag=0;

            }
             for(int k=0;k<m;k++)
            {
                if(sum==b[k])
                    flag=0;
            }
            if(flag==1)
            	break;

        }
        if( flag==1)
        	break;
    }
    if(flag==1)
        cout<<l<<" "<<r<<endl;
}


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

    int main()
    {
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif

        int n;
        cin>>n;
        int a[n];
        for(int i=0;i<n;i++)
            cin>>a[i];
        int m;
        cin>>m;
        int b[m];
        for(int i=0;i<m;i++)
            cin>>b[i];
        int sum;
        int flag=2;
        int l,r,c;
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                sum=a[i]+b[j];
               	flag=2;
                for(int k=0;k<n;k++)
                {

                    if(sum==a[k])
                    {

                        flag=0;
                    }

                }
                // cout<<1<<" "<<flag<<endl;
                if(flag==2)
                {
                	for(int k=0;k<m;k++)
                	{
                    	if(sum==b[k])
                    	{
                        	flag=0;
                    	}

                	}
                }

                if(flag==2)
                {
        			c=1;
                	l=a[i];
                	r=b[j];
             //   	break;
                	// cout<<l<<" "<<r<<endl;

                }

            }

            //if(c)
            	//break;

        }
        if(c==1)
        	cout<<l<<" "<<r<<endl;

    }


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

int main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    int m;
    cin>>m;
    int b[m];
    for(int i=0;i<m;i++)
        cin>>b[i];
    int sum;
    int flag=0;
    int l,r;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            sum=a[i]+b[j];

            for(int k=0;k<n;k++)
            {
                if(sum!=a[k] && sum !=b[k])
                {
                    flag=1;
                     l=a[i];
            		r=b[j];
                }

            }

        }
    }
    if(flag==1)
        cout<<l<<" "<<r<<endl;
}


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

int main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    int m;
    cin>>m;
    int b[m];
    for(int i=0;i<m;i++)
        cin>>b[i];
    int sum;
    int flag=2;
    int l,r,c;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            sum=a[i]+b[j];

            for(int k=0;k<n;k++)
            {
            	// cout<<sum<<" "<<a[k]<<endl;
                if(sum==a[k])
                {

                    flag=0;
                }

            }
            // cout<<1<<" "<<flag<<endl;
            if(flag==2)
            {
            	for(int k=0;k<m;k++)
            	{
                	if(sum==b[k])
                	{
                    	flag=0;
                	}

            	}
            }

            if(flag==2)
            {
    			c=1;
            	l=a[i];
            	r=b[j];
            	// cout<<l<<" "<<r<<endl;

            }

        }

    }
    if(c==1)
    	cout<<l<<" "<<r<<endl;

}


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

int main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    int m;
    cin>>m;
    int b[m];
    for(int i=0;i<m;i++)
        cin>>b[i];
    int sum;
    int flag=2;
    int l,r,c;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            sum=a[i]+b[j];

            for(int k=0;k<n;k++)
            {
            	// cout<<sum<<" "<<a[k]<<endl;
                if(sum==a[k])
                {

                    flag=0;
                }

            }
            // cout<<1<<" "<<flag<<endl;
            if(flag!=0)
            {
            	for(int k=0;k<m;k++)
            	{
                	if(sum==b[k])
                	{
                    	flag=0;
                	}

            	}
            }

            if(flag==2)
            {
    			c=1;
            	l=a[i];
            	r=b[j];
            	// cout<<l<<" "<<r<<endl;

            }

        }

    }
    if(c==1)
    	cout<<l<<" "<<r<<endl;

}


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

int main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    int m;
    cin>>m;
    int b[m];
    for(int i=0;i<m;i++)
        cin>>b[i];
    int sum;
    int flag=0;
    int l,r;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            sum=a[i]+b[j];

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

            }
            if(flag==1)
            {
            	 for(int k=0;k<m;k++)
            {
                if(sum!=a[k])
                {
                    flag=2;
                     r=b[j];
                }

            }
            }

        }
    }
    if(flag==2)
        cout<<l<<" "<<r<<endl;
}


# include <bits/stdc++.h>
# define ll long long
# define fi first
# define se second
# define pb push_back
# define pf push_front
# define For(i, a, b) for( int i = a; i < b; i++ )
# define in insert
# define all(a) a.begin(),a.end()
# define pi pair < int, int >
# define DEBUG
# define readfile(file) freopen ( (file + ".in").c_str(), "r", stdin)
# define writefile(file) freopen ( (file + ".out").c_str(), "w", stdout)
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL)
# define LARGE 150005
# define SET(file) readfile(file);writefile(file);

using namespace std;

int main() {
    // Author: _Dilshod_
    speed;
    int n, m, x;
    int mx1 = 0, mx2 = 0;
    cin >> n;
    For ( i, 0, n ) {
        cin >> x;
        mx1 = max( mx1, x );
    }
    cin >> m;
    For ( i, 0, m ) {
        cin >> x;
        mx2 = max( mx2, x );
    }
    cout << mx1 << ' ' << mx2 << endl;
}


# include <bits/stdc++.h>
# define ll long long
# define fi first
# define se second
# define pb push_back
# define pf push_front
# define For(i, a, b) for( int i = a; i < b; i++ )
# define in insert
# define all(a) a.begin(),a.end()
# define pi pair < int, int >
# define DEBUG
# define readfile(file) freopen ( (file + ".in").c_str(), "r", stdin)
# define writefile(file) freopen ( (file + ".out").c_str(), "w", stdout)
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL)
# define LARGE 150005
# define SET(file) readfile(file);writefile(file);

using namespace std;

int main() {
    // Author: _Dilshod_
    speed;
    int n, m, x;
    int mx1 = 0, mx2 = 0;
    cin >> n;
    For ( i, 0, n ) {
        cin >> x;
        mx1 = max( mx1, x );
    }
    For ( i, 0, m ) {
        cin >> x;
        mx2 = max( mx2, x );
    }
    cout << mx1 + mx2 << endl;
}


# include <bits/stdc++.h>
# define ll long long
# define fi first
# define se second
# define pb push_back
# define pf push_front
# define For(i, a, b) for( int i = a; i < b; i++ )
# define in insert
# define all(a) a.begin(),a.end()
# define pi pair < int, int >
# define DEBUG
# define readfile(file) freopen ( (file + ".in").c_str(), "r", stdin)
# define writefile(file) freopen ( (file + ".out").c_str(), "w", stdout)
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL)
# define LARGE 150005
# define SET(file) readfile(file);writefile(file);

using namespace std;

int main() {
    // Author: _Dilshod_
    speed;
    int n, m;
    int mx1 = 0, mx2 = 0;
    cin >> n;
    vector < int > vc1(n);
    For ( i, 0, n ) {
        cin >> vc1[i];
        mx1 = max( mx1, vc1[i] );
    }
    cin >> m;
    vector < int > vc2(m);
    For ( i, 0, m ) {
        cin >> vc2[i];
        mx2 = max( mx2, vc2[i] );
    }
    cout << mx1 + mx2;
}


# include <bits/stdc++.h>
# define ll long long
# define fi first
# define se second
# define pb push_back
# define pf push_front
# define For(i, a, b) for( int i = a; i < b; i++ )
# define in insert
# define all(a) a.begin(),a.end()
# define pi pair < int, int >
# define DEBUG
# define readfile(file) freopen ( (file + ".in").c_str(), "r", stdin)
# define writefile(file) freopen ( (file + ".out").c_str(), "w", stdout)
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL)
# define LARGE 150005
# define SET(file) readfile(file);writefile(file);

using namespace std;

int main() {
    // Author: _Dilshod_
    speed;
    int n, m;
    int mx1 = 0, mx2 = 0;
    cin >> n;
    vector < int > vc1(n);
    For ( i, 0, n ) {
        cin >> vc1[i];
        mx1 = max( mx1, vc1[i] );
    }
    cin >> m;
    vector < int > vc2(m);
    For ( i, 0, m ) {
        cin >> vc2[i];
        mx2 = max( mx2, vc2[i] );
    }
    int ans = mx1 + mx2;
    cout << ans << endl;
}


# include <bits/stdc++.h>
# define ll long long
# define fi first
# define se second
# define pb push_back
# define pf push_front
# define For(i, a, b) for( int i = a; i < b; i++ )
# define in insert
# define all(a) a.begin(),a.end()
# define pi pair < int, int >
# define DEBUG
# define readfile(file) freopen ( (file + ".in").c_str(), "r", stdin)
# define writefile(file) freopen ( (file + ".out").c_str(), "w", stdout)
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL)
# define LARGE 150005
# define SET(file) readfile(file);writefile(file);

using namespace std;

int main() {
    // Author: _Dilshod_
    speed;
    int n, m;
    int mx1 = 0, mx2 = 0;
    cin >> n;
    vector < int > vc1(n);
    For ( i, 0, n ) {
        cin >> vc1[i];
        mx1 = max( mx1, vc1[i] );
    }
    cin >> m;
    vector < int > vc2(m);
    For ( i, 0, m ) {
        cin >> vc2[i];
        mx2 = max( mx2, vc2[i] );
    }
    int ans = mx1 + mx2;
    cout << ans << endl;
    return 0;
}


# include <bits/stdc++.h>
# define ll long long
# define fi first
# define se second
# define pb push_back
# define pf push_front
# define For(i, a, b) for( int i = a; i < b; i++ )
# define in insert
# define all(a) a.begin(),a.end()
# define pi pair < int, int >
# define DEBUG
# define readfile(file) freopen ( (file + ".in").c_str(), "r", stdin)
# define writefile(file) freopen ( (file + ".out").c_str(), "w", stdout)
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL)
# define LARGE 150005
# define SET(file) readfile(file);writefile(file);

using namespace std;

int main() {
    // Author: _Dilshod_
    speed;
    int n, m;
    int mx1 = 0, mx2 = 0;
    cin >> n;
    vector < int > vc1(n + 5);
    For ( i, 0, n ) {
        cin >> vc1[i];
        mx1 = max( mx1, vc1[i] );
    }
    cin >> m;
    vector < int > vc2(m + 5);
    For ( i, 0, m ) {
        cin >> vc2[i];
        mx2 = max( mx2, vc2[i] );
    }
    int ans = mx1 + mx2;
    cout << ans << endl;
    return 0;
}


#include<iostream>
using namespace std;
#define ll long long
#define pb push_back()

void FAST() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}

int main() {
	FAST();

	int n; cin >> n;
	int arr1[1000];
	for (int i = 0; i < n; i++) cin >> arr1[i];

	int m; cin >> m;
	int arr2[ 1000];
	for (int i = 0; i < m; i++) cin >> arr2[i];

	int i, j;
	for ( i = 0; i < n; i++)
	{
		bool ok = true;
		for ( j = 0; j < m; j++)
		{
			for (int k = 0; k < n; k++) {
				if (arr1[i] + arr2[j] == arr1[k])
				{
					ok = false;
					break;
				}
			}

			for (int k = 0; k < m; k++) {
				if (arr1[i] + arr2[j] == arr1[k])
				{
					ok = false;
					break;
				}
			}

			if (ok) {
				cout << arr1[i] << " " << arr2[j] << endl;
				return 0;
			}
		}
		ok = true;
	}
	return 0;
}


#include<iostream>
#include<algorithm>
using namespace std;
#define ll long long
#define pb push_back

void FAST() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}

int main() {
	FAST();

	int arr1[1001],arr2[1001] ;

	int n; cin >> n;
	for (int i = 0; i < n; i++) cin >> arr1[i];

	int m; cin >> m;
	for (int i = 0; i < m; i++) cin >> arr2[i];

    for( int i= 0 ; i< n ; i++ )
    {
        for( int j=0 ; j< m ; j++ )
        {
            if( ! binary_search( arr1 , arr1+n , arr1[i]+arr2[j] )
                and ! binary_search( arr2 , arr2+m , arr1[i]+arr2[j] ) )
            {
                cout << arr1[i] << " " << arr2[j] << endl;
                return 0;
            }
        }
    }
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back

void FAST() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}

int main() {
	FAST();

	vector<int> arr1,arr2 ;

	int n; cin >> n;
	for (int i = 0; i < n; i++)
	{
	    int x ; cin >> x ;
	    arr1.pb(x);
	}

	int m; cin >> m;
	for (int i = 0; i < m; i++)
    {
	    int x ; cin >> x ;
	    arr2.pb(x);
	}

    for( int i= 0 ; i< n ; i++ )
    {
        for( int j=0 ; j< m ; j++ )
        {
            if( binary_search( arr1.begin() , arr1.end() , arr1[i]+arr2[j] ) == false
                and binary_search( arr2.begin() , arr2.end() , arr1[i]+arr2[j] ) == false )
            {
                cout << arr1[i] << " " << arr2[j] << endl;
                return 0;
            }
        }
    }

	return 0;
}


#include<iostream>
using namespace std;
#define ll long long
#define pb push_back()

void FAST() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}

int main() {
	FAST();

	int n; cin >> n;
	int arr1[1000];
	for (int i = 0; i < n; i++) cin >> arr1[i];

	int m; cin >> m;
	int arr2[ 1000];
	for (int i = 0; i < m; i++) cin >> arr2[i];

	int i, j;
	for ( i = 0; i < n; i++)
	{
		bool ok = true;
		for ( j = 0; j < m; j++)
		{
			for (int k = 0; k < n; k++) {
				if (arr1[i] + arr2[j] == arr1[k])
				{
					ok = false;
					break;
				}
			}

			for (int k = 0; k < m; k++) {
				if (arr1[i] + arr2[j] == arr1[k])
				{
					ok = false;
					break;
				}
			}

			if (ok) {
				cout << arr1[i] << " " << arr2[j] << endl;
				return 0;
			}
		}
	}
	return 0;
}


#include<iostream>
#include<algorithm>
using namespace std;
#define ll long long
#define pb push_back

void FAST() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}

int main() {
	FAST();

	int arr1[1001],arr2[1001] ;

	int n; cin >> n;
	for (int i = 0; i < n; i++) cin >> arr1[i];

	int m; cin >> m;
	for (int i = 0; i < m; i++) cin >> arr2[i];

    for( int i= 0 ; i< n ; i++ )
    {
        for( int j=0 ; j< m ; j++ )
        {
            bool ok1 = true , ok2 = true ;
            for( int h=0 ; h<n ; h++ )
                if( arr1[i]+arr2[j] == arr1[h]) ok1 = false ;
            for( int h=0 ; h<m ; h++ )
                if( arr1[i]+arr2[j] == arr2[h]) ok2 = false ;
            if( ok1 and ok2 )
            {
                cout << arr1[i] << " " << arr2[j] << endl;
                return 0;
            }
        }
    }
	return 0;
}


#include<iostream>
#include<algorithm>
using namespace std;
#define ll long long
#define pb push_back()

void FAST() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}

int main() {
	FAST();

	int n; cin >> n;
	int arr1[1000];
	for (int i = 0; i < n; i++) cin >> arr1[i];

	int m; cin >> m;
	int arr2[ 1000];
	for (int i = 0; i < m; i++) cin >> arr2[i];

    for( int i= 0 ; i< n ; i++ )
    {
        for( int j=0 ; j< m ; j++ )
        {
            if( ! binary_search( arr1 , arr1+n , arr1[i]+arr2[j] )
                and ! binary_search( arr1 , arr1+m , arr1[i]+arr2[j] ) )
            {
                cout << arr1[i] << " " << arr2[j] << endl;
                return 0;
            }
        }
    }
	return 0;
}


#include <bits/stdc++.h>
#define ll long long int
#define zet 1e-7
#define x first
#define y second
using namespace std;

int main(){
	ios::sync_with_stdio(0);
	int na;
	scanf("%d",&na);
	map<int> a;
	for(int i=0;i<na;i++){
		int aux;
		scanf("%d",&aux);
		a[aux] = 1;
	}
	int nb;
	scanf("%d",&nb);
	map<int> b;
	for(int i=0;i<nb;i++){
		int aux;
		scanf("%d",&aux);
		for(int w:a){
			if(map[aux+w]){
				printf("%d %d\n",w,aux);
				exit(0);
			}
		}
	}
}


#include <bits/stdc++.h>
#define ll long long int
#define zet 1e-7
#define x first
#define y second
using namespace std;

int main(){
	ios::sync_with_stdio(0);
	int na;
	scanf("%d",&na);
	map<int,int> a;
	for(int i=0;i<na;i++){
		int aux;
		scanf("%d",&aux);
		a[aux] = 1;
	}
	int nb;
	scanf("%d",&nb);
	for(int i=0;i<nb;i++){
		int aux;
		scanf("%d",&aux);
		for(auto w:a){
			if(a[aux+w.x]){
				printf("%d %d\n",w,aux);
				exit(0);
			}
		}
	}
}


#include <bits/stdc++.h>
#define ll long long int
#define zet 1e-7
#define x first
#define y second
using namespace std;
int a[1000],b[1000];
int main(){
	ios::sync_with_stdio(0);
	int na;
	scanf("%d",&na);vector<int> O,P;

	for(int i=0;i<na;i++){
		int aux;
		scanf("%d",&aux);
		O.push_back(aux);
		a[aux] = 1;
	}
	int nb;
	scanf("%d",&nb);
	for(int i=0;i<nb;i++){
		int aux;
		scanf("%d",&aux);
		b[aux] = 1;
		P.push_back(aux);

	}
	sort(O.begin(),O.end());
	sort(P.begin(),P.end());
	printf("%d %d",O.back(),P.back());
}


#include <bits/stdc++.h>
#define ll long long int
#define zet 1e-7
#define x first
#define y second
using namespace std;

int main(){
	ios::sync_with_stdio(0);
	int na;
	scanf("%d",&na);
	map<int,int> a;
	for(int i=0;i<na;i++){
		int aux;
		scanf("%d",&aux);
		a[aux] = 1;
	}
	int nb;
	scanf("%d",&nb);
	for(int i=0;i<nb;i++){
		int aux;
		scanf("%d",&aux);
		for(int w:a){
			if(map[aux+w]){
				printf("%d %d\n",w,aux);
				exit(0);
			}
		}
	}
}


#include <bits/stdc++.h>
#define ll long long int
#define zet 1e-7
#define x first
#define y second
using namespace std;

int main(){
	ios::sync_with_stdio(0);
	int na;
	scanf("%d",&na);
	map<int,int> a;
	for(int i=0;i<na;i++){
		int aux;
		scanf("%d",&aux);
		a[aux] = 1;
	}
	int nb;
	scanf("%d",&nb);
	for(int i=0;i<nb;i++){
		int aux;
		scanf("%d",&aux);
		for(auto w:a){
			if(map[aux+w.x]){
				printf("%d %d\n",w,aux);
				exit(0);
			}
		}
	}
}


#include<iostream>
using namespace std;
int a[100],b[100],c[1000],n,m;
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		c[a[i]]++;
	}
	cin>>m;
	for(int i=0;i<m;i++){
	cin>>b[i];
	c[b[i]]++;
	}
	bool check=false;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<m;j++){
			if(c[a[i]+b[j]]==0){
				cout<<a[i]<<" "<<b[j];
				check= true;
				break;
			}
		}
		if(check)break;
	}
}


#include<iostream>
using namespace std;
int a[100],b[100],c[1000],n,m;
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		c[a[i]]++;
	}
	cin>>m;
	for(int i=0;i<m;i++){
	cin>>b[i];
	c[b[i]]++;
	}
	for(int i=0;i<n;i++){
		for(int j=i+1;j<m;j++){
			if(c[a[i]+b[j]]==0){
				cout<<a[i]<<" "<<b[j];
				break;
			}
		}
	}
}


#include<iostream>
using namespace std;
int a[100],b[100],c[1000],n,m;
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		c[a[i]]++;
	}
	cin>>m;
	for(int i=0;i<m;i++){
	cin>>b[i];
	c[b[i]]++;
	}
	bool check=false;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			if(c[a[i]+b[j]]==0){
				cout<<a[i]<<" "<<b[j];
				check= true;
				break;
			}
		}
		if(check)break;
	}
}


#include<iostream>
using namespace std;
int a[100],b[100],c[1000],n,m;
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		c[a[i]]++;
	}
	cin>>m;
	for(int i=0;i<m;i++){
	cin>>b[i];
	c[b[i]]++;
	}
	for(int i=0;i<n;i++){
		for(int j=i+1;j<m;j++){
			if(c[a[i]+a[j]]==0){
				cout<<a[i]<<" "<<a[j];
				break;
			}
		}
	}
}


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

bool exist(int n , int a[], int len) {
    for(int i = 0 ; i < len ; i ++)
        if(a[i] == n) return true ;
return false ;
}
int main() {
    int m ;
    cin >> m ;
    int a[m] ;
    for(int i = 0 ; i < m ; i ++) cin >> a[i] ;

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

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


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

bool exist(int n , int a[], int len) {
    for(int i = 0 ; i < n ; i ++)
        if(a[i] == n) return true ;
return false ;
}
int main() {
    int m ;
    cin >> m ;
    int a[m] ;
    for(int i = 0 ; i < m ; i ++) cin >> a[i] ;

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

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


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

bool exist(int n , int a[], int len) {
    for(int i = 0 ; i < len ; i ++)
        if(a[i] == n) return true ;
return false ;
}
int main() {
    int m ;
    cin >> m ;
    int a[m] ;
    for(int i = 0 ; i < m ; i ++) cin >> a[i] ;

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

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


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

bool exist(int n , int a[], int len) {
    for(int i = 0 ; i < n ; i ++)
        if(a[i] == n) return true ;
return false ;
}
int main() {
    int m ;
    cin >> m ;
    int a[m] ;
    for(int i = 0 ; i < m ; i ++) cin >> a[i] ;

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

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


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

bool exist(int n , int a[], int len) {
    for(int i = 0 ; i < len ; i ++)
        if(a[i] == n) return true ;
return false ;
}
int main() {
    int m ;
    cin >> m ;
    int a[m] ;
    for(int i = 0 ; i < m ; i ++) cin >> a[i] ;

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

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


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

bool exist(int n , int a[], int len) {
    for(int i = 0 ; i < len ; i ++)
        if(a[i] == n) return true ;
return false ;
}
int main() {
    int m ;
    cin >> m ;
    int a[m] ;
    for(int i = 0 ; i < m ; i ++) cin >> a[i] ;

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

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


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

int main()
{
    int a[1000],b[1000],c[1000],n1,n2,i,k,j,flag=0;
cin>>n1;
for(i=0;i<n1;i++)
{
    cin>>a[i];
}
cin>>n2;
for(i=0;i<n2;i++)
{
    cin>>b[i];
}
sort(a,a+n1);
sort(b,b+n2);
cout<<a[n1-1]<<" "<<b[n2-1];
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define P (int)(1e9+7)
#define ceil(x, y) (x%y==0? (x/y) : (x/y+1))
#define FOR(i, N) for(int i = 0; i < N; ++i)
inline int powerMod(int a, int b)
{
    a=a%P;
    int res=1;
    while(b>0)
    {
        if(b & 1)
            res = (res * a % P) % P;
        b=b>>1;
        a=((a%P)*(a%P))%P;
    }
    return res;
}
int main() {
	// your code goes here
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);*/
	int T=1;
	//cin>>T;
	while(T-->0)
	{
        int N;
        cin>>N;
        int A[N];
        FOR(i, N) cin >> A[i];
        int M;
        cin >> M;
        int B[M];
        FOR(i, M) cin >> B[i];
        sort(A, A+N);
        sort (B, B+M);
        int i = 0, j = 0;
        while(i < N && j < M)
        {
        	if (i < N-1 && (A[i+1] == A[i] || A[i]+B[j] == A[i+1])) i++;
        	else if(j < M-1 && (B[j] == B[j+1] || A[i]+B[j] == B[j+1])) j++;
        	else break;
        }
        cout << A[i]<<" "<<B[j];
	    cout<<'\n';
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define P (int)(1e9+7)
#define ceil(x, y) (x%y==0? (x/y) : (x/y+1))
#define FOR(i, N) for(int i = 0; i < N; ++i)
inline int powerMod(int a, int b)
{
    a=a%P;
    int res=1;
    while(b>0)
    {
        if(b & 1)
            res = (res * a % P) % P;
        b=b>>1;
        a=((a%P)*(a%P))%P;
    }
    return res;
}
int main() {
	// your code goes here
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);*/
	int T;
	cin>>T;
	while(T-->0)
	{
        int N;
        cin>>N;
        int A[N];
        FOR(i, N) cin >> A[i];
        int M;
        cin >> M;
        int B[N];
        FOR(i, M) cin >> B[i];
        sort(A, A+N);
        sort (B, B+M);
        int i = 0, j = 0;
        while(i < M-1 && j < N-1)
        {
        	if(A[i+1] == A[i] || A[i]+B[j] == A[i+1]) i++;
        	else if(B[j] == B[j+1] || A[i]+B[j] == B[j+1]) j++;
        	else break;
        }
        cout << A[i]<<" "<<B[j];
	    cout<<'\n';
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define P (int)(1e9+7)
#define ceil(x, y) (x%y==0? (x/y) : (x/y+1))
#define FOR(i, N) for(int i = 0; i < N; ++i)
inline int powerMod(int a, int b)
{
    a=a%P;
    int res=1;
    while(b>0)
    {
        if(b & 1)
            res = (res * a % P) % P;
        b=b>>1;
        a=((a%P)*(a%P))%P;
    }
    return res;
}
int main() {
	// your code goes here
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);*/
	int T=1;
	//cin>>T;
	while(T-->0)
	{
        int N;
        cin>>N;
        int A[N];
        FOR(i, N) cin >> A[i];
        int M;
        cin >> M;
        int B[M];
        FOR(i, M) cin >> B[i];
        sort(A, A+N);
        sort (B, B+M);
        int i = 0, j = 0;
        while(i < N-1 && j < M-1)
        {
        	if(A[i+1] == A[i] || A[i]+B[j] == A[i+1]) i++;
        	else if(B[j] == B[j+1] || A[i]+B[j] == B[j+1]) j++;
        	else break;
        }
        cout << A[i]<<" "<<B[j];
	    cout<<'\n';
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define P (int)(1e9+7)
#define ceil(x, y) (x%y==0? (x/y) : (x/y+1))
#define FOR(i, N) for(int i = 0; i < N; ++i)
inline int powerMod(int a, int b)
{
    a=a%P;
    int res=1;
    while(b>0)
    {
        if(b & 1)
            res = (res * a % P) % P;
        b=b>>1;
        a=((a%P)*(a%P))%P;
    }
    return res;
}
int main() {
	// your code goes here
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);*/
	int T=1;
	//cin>>T;
	while(T-->0)
	{
        int N;
        cin>>N;
        int A[N];
        FOR(i, N) cin >> A[i];
        int M;
        cin >> M;
        int B[M];
        FOR(i, M) cin >> B[i];
        sort(A, A+N);
        sort (B, B+M);
        cout << A[N-1] << " " << B[M-1];
        }
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define P (int)(1e9+7)
#define ceil(x, y) (x%y==0? (x/y) : (x/y+1))
#define FOR(i, N) for(int i = 0; i < N; ++i)
inline int powerMod(int a, int b)
{
    a=a%P;
    int res=1;
    while(b>0)
    {
        if(b & 1)
            res = (res * a % P) % P;
        b=b>>1;
        a=((a%P)*(a%P))%P;
    }
    return res;
}
int main() {
	// your code goes here
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);*/
	int T=1;
	//cin>>T;
	while(T-->0)
	{
        int N;
        cin>>N;
        int A[N];
        FOR(i, N) cin >> A[i];
        int M;
        cin >> M;
        int B[M];
        FOR(i, M) cin >> B[i];
        sort(A, A+N);
        sort (B, B+M);
        cout << A[N] << " " << B[M];
        }
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define P (int)(1e9+7)
#define ceil(x, y) (x%y==0? (x/y) : (x/y+1))
#define FOR(i, N) for(int i = 0; i < N; ++i)
inline int powerMod(int a, int b)
{
    a=a%P;
    int res=1;
    while(b>0)
    {
        if(b & 1)
            res = (res * a % P) % P;
        b=b>>1;
        a=((a%P)*(a%P))%P;
    }
    return res;
}
int main() {
	// your code goes here
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);*/
	int T;
	cin>>T;
	while(T-->0)
	{
        int N;
        cin>>N;
        int A[N];
        FOR(i, N) cin >> A[i];
        int M;
        cin >> M;
        int B[M];
        FOR(i, M) cin >> B[i];
        sort(A, A+N);
        sort (B, B+M);
        int i = 0, j = 0;
        while(i < N-1 && j < M-1)
        {
        	if(A[i+1] == A[i] || A[i]+B[j] == A[i+1]) i++;
        	else if(B[j] == B[j+1] || A[i]+B[j] == B[j+1]) j++;
        	else break;
        }
        cout << A[i]<<" "<<B[j];
	    cout<<'\n';
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define P (int)(1e9+7)
#define ceil(x, y) (x%y==0? (x/y) : (x/y+1))
#define FOR(i, N) for(int i = 0; i < N; ++i)
inline int powerMod(int a, int b)
{
    a=a%P;
    int res=1;
    while(b>0)
    {
        if(b & 1)
            res = (res * a % P) % P;
        b=b>>1;
        a=((a%P)*(a%P))%P;
    }
    return res;
}
int main() {
	// your code goes here
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);*/
	int T=1;
	//cin>>T;
	while(T-->0)
	{
        int N;
        cin>>N;
        int A[N];
        FOR(i, N) cin >> A[i];
        int M;
        cin >> M;
        int B[M];
        FOR(i, M) cin >> B[i];
        sort(A, A+N);
        sort (B, B+M);
        int i = 0, j = 0;
        cout << A[N] <<" "<<B[M];
	return 0;
}


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

	int n;
	cin>>n;
	int arr[n];
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	int n1;
	int a[n1];
	cin>>n1;
	for(int i=0;i<n1;i++)
	{
		cin>>a[i];
	}
	sort(arr,arr+n);
	sort(a,a+n);
	cout<<arr[n-1]<<" "<<a[n1-1];

}


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

	int n,n1;
	cin>>n;
	int arr[10000],a[1000];
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
	}

	cin>>n1;

	for(int i=0;i<n1;i++)
	{
		cin>>a[i];
	}
	sort(arr,arr+n);
	sort(a,a+n1);
	cout<<arr[n-1]<<" "<<a[n1-1];

}


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

	int n;
	cin>>n;
	int arr[n];
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	int n1;
	int a[n1];
	for(int i=0;i<n1;i++)
	{
		cin>>a[i];
	}
	sort(arr,arr+n);
	sort(a,a+n1);
	cout<<arr[n-1]<<" "<<a[n1-1];

}


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

	int n;
	cin>>n;
	int arr[n];
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sort(arr,arr+n);
	sort(a,a+n);
	cout<<arr[n-1]<<" "<<a[n-1];

}


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

	int n;
	cin>>n;
	int arr[n];
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	int n1;
	int a[n1];
	for(int i=0;i<n1;i++)
	{
		cin>>a[i];
	}
	sort(arr,arr+n);
	sort(a,a+n);
	cout<<arr[n-1]<<" "<<a[n1-1];

}


#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int a, b;
	unsigned int x[1], z[2];
	cin >> a;
	for (size_t  i= 0; i < a; i++)
	{
		cin >> x[i];
	}
	int n = sizeof(x) / sizeof(x[0]);
	sort(x, x + n);
	cin >> b;
	for (size_t i = 0; i < b; i++)
	{
		cin >> z[i];
	}
	int e = sizeof(z) / sizeof(z[0]);
	sort(z, z + e);
		cout << x[a - 1] << " " << z[b - 1] << endl;

}


#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int a, b;
	unsigned int x[100], z[100];
	cin >> a;
	for (size_t  i= 0; i < a; i++)
	{
		cin >> x[i];
	}
	int n = sizeof(x) / sizeof(x[0]);
	sort(x, x + n);
	cin >> b;
	for (size_t i = 0; i < b; i++)
	{
		cin >> z[i];
	}
	int e = sizeof(z) / sizeof(z[0]);
	sort(z, z + e);
		cout << x[a - 1] << " " << z[b - 1] << endl;

}


#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int a, b;
	unsigned int x[1], z[2];
	cin >> a;
	for (size_t  i= 0; i < a; i++)
	{
		cin >> x[i];
	}
	int n = sizeof(x) / sizeof(x[0]);
	sort(x, x + n);
	cin >> b;
	for (size_t i = 0; i < b; i++)
	{
		cin >> z[i];
	}
	int e = sizeof(z) / sizeof(z[0]);
	sort(z, z + e);
		cout << x[a - 1] << " " << z[b - 1] << endl;
		for (size_t i = 0; i < a; i++)
		{
			cout << x[i] << endl;
		}	for (size_t i = 0; i < b; i++)
		{
			cout << z[i] << endl;
		}

}


#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int a, b;
	unsigned int x[100], z[100];
	cin >> a;
	for (size_t i = 0; i < a; i++)
	{
		cin >> x[i];
	}
	int n = sizeof(x) / sizeof(x[0]);
	sort(x, x + n);
	cin >> b;
	for (size_t i = 0; i < b; i++)
	{
		cin >> z[i];
	}
	int e = sizeof(z) / sizeof(z[0]);
	sort(z, z + e);
		cout << x[a - 1] << " " << z[b - 1] << endl;
		for (size_t i = 0; i < a; i++)
		{
			cout << x[i] << endl;
		}	for (size_t i = 0; i < b; i++)
		{
			cout << z[i] << endl;
		}

}


	#include <iostream>
	using namespace std;
	int main() {
		int a, b,max1=0,max2=0;
		int x[100], z[100];
		cin >> a;
		for (size_t i = 0; i < a; i++)
		{
			cin >> x[i];
			if (x[i]>max1)
			{
				max1 = x[i];
			}
		}
		cin >> b;

		for (size_t i = 0; i < b; i++)
		{
			cin >> z[i];
			if (z[i]>max2)
			{
				max2 = z[i];
			}
		}

		cout << max1 << " " << max2 << endl;

	}


#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int a, b;
	unsigned int x[100], z[100];
	cin >> a;
	for (size_t i = 0; i < a; i++)
	{
		cin >> x[i];
	}
	int n = sizeof(x) / sizeof(x[0]);
	sort(x, x + n);
	cin >> b;
	for (size_t i = 0; i < b; i++)
	{
		cin >> z[i];
	}
	int e = sizeof(z) / sizeof(z[0]);
	sort(z, z + e);
		cout << x[a - 1] << " " << z[b - 1] << endl;

}


#include<iostream>
using namespace std;
int main(){
    int n,m;
    cin>>n;
    long long max1=0,max2=0;
    for(int i=0;i<n;i++){
        long long a;
        cin>>a;
        max1 = max(max1,a);
    }
    cin>>m;
    for(int i=0;i<m;i++){
        long long a;
        cin>>a;
        max2 = max(max2,a);
    }
    cout<<max1<<" "<<max2;
}


    #include<iostream>
    using namespace std;
    int main(){
        int n;
        cin>>n;
        int arr[n];
        for(int i=0;i<n;i++){
            cin>>arr[i];
        }
        int n2;
        cin>>n2;
        int arr2[n];
        for(int i=0;i<n;i++){
            cin>>arr2[i];
        }
        for(int i=0;i<n;i++){
            for(int j=0;j<n2;j++){
                int a = arr[i]+arr2[j];
                bool check=1;
                for(int ii=0;ii<n;ii++){
                    if(arr[i] == a){
                        check=0;
                        break;
                    }
                }
                for(int jj=0;jj<n2;jj++){
                    if(arr2[i] == a){
                        check=0;
                        break;
                    }
                }
                if(check){
                    cout<<arr[i]<<" "<<arr2[j];
                    return 0;
                }
            }
        }
    }


#include<iostream>
using namespace std;
int main(){
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    int n2;
    cin>>n2;
    int arr2[n];
    for(int i=0;i<n;i++){
        cin>>arr2[i];
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n2;j++){
            int a = arr[i]=arr[j];
            bool check=1;
            for(int ii=0;ii<n;ii++){
                if(arr[i] == a){
                    check=0;
                    break;
                }
            }
            for(int jj=0;jj<n2;jj++){
                if(arr2[i] == a){
                    check=0;
                    break;
                }
            }
            if(check){
                cout<<arr[i]<<" "<<arr2[j];
                return 0;
            }
        }
    }
}


    #include<iostream>
    using namespace std;
    int main(){
        long long n;
        cin>>n;
        long long arr[n];
        for(int i=0;i<n;i++){
            cin>>arr[i];
        }
        long long n2;
        cin>>n2;
        long long arr2[n];
        for(int i=0;i<n;i++){
            cin>>arr2[i];
        }
        for(int i=0;i<n;i++){
            for(int j=0;j<n2;j++){
                int a = arr[i]+arr2[j];
                bool check=1;
                for(int ii=0;ii<n;ii++){
                    if(arr[i] == a){
                        check=0;
                        break;
                    }
                }
                for(int jj=0;jj<n2;jj++){
                    if(arr2[i] == a){
                        check=0;
                        break;
                    }
                }
                if(check){
                    cout<<arr[i]<<" "<<arr2[j];
                    return 0;
                }
            }
        }
    }


#include<iostream>
using namespace std;
int main(){
    int n;
    cin>>n;
    long long max1=0,max2=0;
    for(int i=0;i<n;i++){
        long long a;
        cin>>a;
        max1 = max(max1,a);
    }
    int m;
    for(int i=0;i<m;i++){
        long long a;
        cin>>a;
        max2 = max(max2,a);
    }

    cout<<max1<<" "<<max2;
}


#include<bits/stdc++.h>
using  namespace std;
int find(int p,int a[],int n,int b[],int m)
{
    for(int i=0;i<n;i++)
    {
        if(a[i]==p)
        {
            return 0;
        }
    }
    for(int i=0;i<m;i++)
    {
        if(b[i]==p)
        {
            return 0;
        }
    }
    return 1;

}
int foo(int x,int y,int a[],int b[],int n,int m)
{
    int f=0;
    int z=0;
    for(int i=0;i<n;i++)
    {
        if(a[i]==y)
        {
            f=1;
            break;
        }
    }
     for(int i=0;i<m;i++)
    {
        if(b[i]==x)
        {
            z=1;
            break;
        }
    }
    if(f && z)
    {
        return 1;
    }
    else
    return 0;
}
int  main()
{
   int a[101],b[109];
   int n,m;
   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 f=0;
   for(int i=0;i<n;i++)
   {
       for(int j=0;j<m;j++)
       {
          if(foo(a[i],b[j],a,b,n,m))
          {
           int sum=a[i]+b[j];
           if(find(sum,a,n,b,m))
           {
               cout<<a[i]<<" "<<b[i];
               f=1;
               break;
           }
          }
       }
       if(f)
       break;
   }
   return 0;

}


#include<bits/stdc++.h>
using namespace std;
int find(int x,int a[],int n,int y,int b[],int m)
{
    int p=0;
    int f=0;
    for(int i=0;i<n;i++)
    {
        if(a[i]==y)
        {
            f=1;
            break;
        }
    }
    for(int i=0;i<m;i++)
    {
        if(b[i]==x)
        {
            p=1;
            break;
        }
    }
    if(p&& f)
    return 1;
    else
    return 0;

}
int search(int x,int a[],int n,int b[],int m)
{
    for(int i=0;i<n;i++)
    {
        if(a[i]==x)
        return 0;
    }
     for(int i=0;i<m;i++)
    {
        if(b[i]==x)
        return 0;
    }
    return 1;
}
int main()
{
    int n,m;
    int a[105],b[105];
    int f=0;
    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++)
        {
            if(find(a[i],a,n,b[j],b,m))
            {
                int sum=a[i]+b[j];
                if(search(sum,a,n,b,m))
                {
                    cout<<a[i]<<" "<<b[j];
                    f=1;
                    break;
                }
            }

        }
        if(f)
            break;
    }
    return 0;
}


#include<bits/stdc++.h>
using  namespace std;
int find(int p,int a[],int n,int b[],int m)
{
    for(int i=0;i<n;i++)
    {
        if(a[i]==p)
        {
            return 0;
        }
    }
    for(int i=0;i<m;i++)
    {
        if(b[i]==p)
        {
            return 0;
        }
    }
    return 1;

}
int  main()
{
   int a[101],b[109];
   int n,m;
   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 f=0;
   for(int i=0;i<n;i++)
   {
       for(int j=0;j<m;j++)
       {
           int sum=a[i]+b[j];
           if(find(sum,a,n,b,m))
           {
               cout<<a[i]<<" "<<b[i];
               f=1;
               break;
           }
       }
       if(f)
       break;
   }
   return 0;

}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    int a[105],b[105];
    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<bits/stdc++.h>
using namespace std;
int main()
{
   int a[105],b[105];
   int n,m;
   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[n-1];

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int search(int x,int a[],int n,int b[],int m)
{
    for(int i=0;i<n;i++)
    {
        if(a[i]==x)
        return 0;
    }
     for(int i=0;i<m;i++)
    {
        if(b[i]==x)
        return 0;
    }
    return 1;
}
int main()
{
    int n,m;
    int a[105],b[105];
    int f=0;
    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 sum=a[i]+b[j];
                if(search(sum,a,n,b,m))
                {
                    cout<<a[i]<<" "<<b[j];
                    f=1;
                    break;
                }

        }
        if(f)
            break;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a[100],b[100];
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int m;
    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;
}


#define READ_VL vector<int>a; int x; for (auto i = 0 ; i < n ; i++) { cin >> x; a.push_back(x);}
#define READSORT_VL vector<int>a; int x; for (auto i = 0 ; i < n ; i++) { cin >> x; a.push_back(x);} sort(a.begin(),a.end());

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

bool isprime(long long n){ if (n%2==0) {return false;} for (auto i=3;i*i<=n;i+=2) {if (n%i==0) { return false; }} return true;}
long long digitsum(long long n) { long long sum=0; while (n > 0){sum+=n%10;n/=10;} return sum;}

int main() {
	long long t,n,p,i,x;

	cin >> t;
	while(t--){
		bool one=true;
		cin >> n;
		cin >> p;
		for (auto j = 1 ; j < n ; j++){
			cin >> i;
			p^=i;
		}

		if (p == 0)
			cout << n << endl;
		else
			cout << 1 << endl;

	}
}


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

int main(){
    int t;
    cin>>t;
    while(t!=0)
    {
        long n,ans;
        int ctr=0;
        cin>>n;
        long long arr[n];
        for(long i=0;i<n;i++)
        {
            cin>>arr[i];
        }
        for(long i=1;i<n;i++)
        {
            if(arr[i]==arr[i-1])
            ctr=0;
            else
            {ctr=1;
            break;}
        }
        if(ctr==0)
        ans=n;
        else
        ans=1;
        cout<<ans<<endl;
        t=t-1;
    }
    return 0;
}


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

int main(){
    int t;
    cin>>t;
    while(t!=0)
    {
        long n,ans=1;
        cin>>n;
        long long arr[n],arr1[n],arr2[n],ctr=0;
        for(long i=0;i<n;i++)
        {
            cin>>arr[i];
        }
        for(long i=0;i<n;i++)
        {
            ctr=ctr+arr[i];
            arr1[i]=ctr;
        }
        for(long i=1;i<n;i++)
        {
            if((arr1[i]==2*arr1[i-1])&&(arr[i]==arr[i-1]))
            ans=ans+1;
        }
        cout<<ans<<endl;
        t=t-1;
    }
    return 0;
}


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

int main(){
    int t;
    cin>>t;
    while(t!=0)
    {
        long n;
        cin>>n;
        long long ctr;
        vector<long long> v;
        long i;
        for(i=0;i<n;i++)
        {
            cin>>ctr;
            cin>>v.push_back(ctr);
        }
        long li,lf;
        li=1;
        lf=0;
        ctr=0;
        long long temp;
        while(li!=lf)
        {
            li=v.size();
            i=0;
            while(i<v.size()-1)
            {
            if(v[i]!=v[i+1])
            {
                temp=v[i]+v[i+1];
                v.erase(v.begin()+i-1,v.begin()+i);
                v.insert(v.begin()+i-1,temp);
            }
            i=i+1;}
            lf=v.size();
        }
        t=t-1;
    }
    return 0;
}


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

int main(){
    int t;
    cin>>t;
    while(t!=0)
    {
        long n;
        cin>>n;
        long long ctr;
        vector<long long> v;
        long i;
        for(i=0;i<n;i++)
        {
            cin>>ctr;
            v.push_back(ctr);
        }
        long li,lf;
        li=1;
        lf=0;
        ctr=0;
        long long temp;
        while(li!=lf)
        {
            li=v.size();
            i=0;
            while(i<v.size()-1)
            {
            if(v[i]!=v[i+1])
            {
                temp=v[i]+v[i+1];
                v.erase(v.begin()+i-1,v.begin()+i);
                v.insert(v.begin()+i-1,temp);
            }
            i=i+1;}
            lf=v.size();
        }
        cout<<v.size()<<endl;
        t=t-1;
    }
    return 0;
}


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

int main(){
    int t;
    cin>>t;
    while(t!=0)
    {
        long n;
        cin>>n;
        long long ctr;
        vector<long long> v;
        long i;
        for(i=0;i<n;i++)
        {
            cin>>ctr;
            v.push_back(ctr);
        }
        long li,lf;
        li=1;
        lf=0;
        ctr=0;
        long long temp;
        while(li!=lf)
        {
            li=v.size();
            i=0;
            while(i<v.size()-1)
            {
            if(v[i]!=v[i+1])
            {
                temp=v[i]+v[i+1];
                v.erase(v.begin()+i-1,v.begin()+i);
                v.insert(v.begin()+i-1,temp);
            }
            i=i+1;}
            lf=v.size();
        }
        t=t-1;
    }
    return 0;
}


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

int main(){
    int t;
    cin>>t;
    while(t!=0)
    {
        long n;
        cin>>n
        vector<long long> v;
        long i,ctr;
        for(i=0;i<n;i++)
        {
            cin>>ctr;
            cin>>v.push_back(ctr);
        }
        long li,lf;
        li=1;
        lf=0;
        ctr=0;
        long long temp;
        while(li!=lf)
        {
            li=v.size();
            i=0;
            while(i<v.size()-1)
            {
            if(v[i]!=v[i+1])
            {
                temp=v[i]+v[i+1];
                v.erase(v.begin()+i-1,v.begin()+i);
                v.insert(v.begin()+i-1,temp);
            }
            i=i+1;}
            lf=v.size();
        }
        t=t-1;
    }
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int t;
    cin >> t;

    long long n;

    long long a[n];

    for (int z = 0; z < t; z++){
        cin >> n;

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

        long long Length ;
        for (long long v = 0; v <= (n - 2); v++){
            Length = 1;

            if ((a[v]) == (a[v + 1])){
                Length++;
            }
        }

        if (Length == n){
            cout << n << endl;
        }

        else {
            cout << "1" << endl;
        }
    }

        // cout << Length << endl;

    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int t;
    cin >> t;

    int n;

    int a[n];

    for (int z = 0; z < t; z++){
        cin >> n;

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

        int Length ;
        for (int v = 1; v < n; v++){
            Length = 1;

            if ((a[v]) == (a[0])){
                Length++;
            }
        }

        if (Length == n){
            cout << n << endl;
        }

        else {
            cout << "1" << endl;
        }
    }

        // cout << Length << endl;

    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int t;
    cin >> t;

    int n;

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

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

        int Length ;
        for (int v = 1; v < n; v++){
            Length = 1;

            if ((a[v]) == (a[0])){
                Length++;
            }
        }

        if (Length == n){
            cout << n << endl;
        }

        else {
            cout << "1" << endl;
        }
    }

        // cout << Length << endl;

    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int t;
    cin >> t;

    int n;

    int a[n];

    for (int z = 0; z < t; z++){
        cin >> n;

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

        int Length ;
        for (int v = 0; v <= (n - 2); v++){
            Length = 1;

            if ((a[v]) == (a[v + 1])){
                Length++;
            }
        }

        if (Length == n){
            cout << n << endl;
        }

        else {
            cout << "1" << endl;
        }
    }

        // cout << Length << endl;

    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int t;
    cin >> t;

    int n;

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

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

        int Length = 1;
        for (int v = 0; v <= n-1; v++){

            if ((a[v]) == (a[v+1])){
                Length++;
            }

            // cout << Length << endl;

        }

        if (Length == n){
            cout << n << endl;
        }

        else {
            cout << "1" << endl;
        }

    }

    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int t;
    cin >> t;

    int n;

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

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

        int Length = 1;
        for (int v = 0; v <= n-2; v++){

            if ((a[v]) == (a[v+1])){
                Length++;
            }

            // cout << Length << endl;

        }

        if (Length == n){
            cout << n << endl;
        }

        else {
            cout << "1" << endl;
        }

    }

    return 0;
}


#include <bits/stdc++.h>
#define ll long long int
#define nl '\n'
#define vi vector<ll>

using namespace std;

int main()
{
    ll t,i,n,j,k;
    cin>>t;
    for(i=0;i<t;i++)
    {
      cin>>n;
      vi v[n];
      ll g=0;
      for(j=0;j<n;j++)
      {
         cin>>v[j];
         if(v[j]>g)
         g=v[j];
      }

    ll count=0;
    for(k=0;k<n;k++)
    {
      if(v[k]==g)

          count=count+1;

      else

        break;

    }
    if(count==n)
    cout<<n<<nl;
    else
    cout<<1<<nl;
}
}


#include <bits/stdc++.h>
#define ll long long int
#define nl '\n'
#define vi vector<ll>

using namespace std;

int main()
{
    ll t,i,n,j,k;
    cin>>t;
    for(i=0;i<t;i++)
    {
      cin>>n;
      vi v(n);
      ll g=0;
      for(j=0;j<n;j++)
      {
         cin>>v[j];
         if(v[j]>g)
         g=v[j];
      }

    ll count=0;
    for(k=0;k<n;k++)
    {
      if(v[k]==g)

          count=count+1;

      else

        break;

    }
    if(count==n)
    cout<<n<<nl;
    else
    cout<<1<<nl;
}
}


#include <bits/stdc++.h>
#define ll long long int
#define nl '\n'
#define vi vector<ll>

using namespace std;

int main()
{
    ll t,i,n,j;
    cin>>t;
    for(i=0;i<t;i++)
    {
      cin>>n;
      vi v(n);
      ll g=0;
      for(j=0;j<n;j++)
      {
         cin>>v[j];
         if(v[j]>g)
         g=v[j];
      }

    ll count=0;
    for(i=0;i<n;i++)
    {
      if(v[i]==g)

          count=count+1;

      else

        break;

    }
    if(count==n)
    cout<<n<<nl;
    else
    cout<<1<<nl;
}
}


#include <bits/stdc++.h>
#define ll long long int
#define nl '\n'
#define vi vector<ll>

using namespace std;

int main()
{
    ll t,i,n,j;
    cin>>t;
    for(i=0;i<t;i++)
    {
      cin>>n;
      vi v[n];
      ll g=0;
      for(j=0;j<n;j++)
      {
         cin>>v[j];
         if(v[j]>g)
         g=v[j];
      }

    ll count=0;
    for(i=0;i<n;i++)
    {
      if(v[i]==g)

          count=count+1;

      else

        break;

    }
    if(count==n)
    cout<<n<<nl;
    else
    cout<<1<<nl;
}
}


#include <bits/stdc++.h>
#define ll long long int
#define nl '\n'
#define vi vector<ll>

using namespace std;

int main()
{
    ll t,i,n,j;
    cin>>t;
    for(i=0;i<t;i++)
    {
      cin>>n;
      vi v[n];
      ll g=0;
      for(j=0;j<n;j++)
      {
         cin>>v[j];
         if(v[j]>g)
         g=v[j];
      }
    }
    ll count=0;
    for(i=0;i<n;i++)
    {
      if(v[i]==g)

          count=count+1;

      else

        break;

    }
    if(count==n)
    cout<<n<<nl;
    else
    cout<<1<<nl;
}


#include <bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int tt;
    cin>>tt;
    while(tt--){
        int n;
        cin>>n;
        vector<int> a(n);
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
        bool ok=(*max_element(a.begin(),a.end())==*min_element(a.begin(),a.end()));
        cout<<(ok?n:1)<<'\n';
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int tt;
    cin>>tt;
    while(tt--){
        int n;
        cin>>n;
        vector<int> a(n);
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
        bool ok=(*max_element(a.begin(),a.end())==*min_element(a.begin(),a.end()));
        cout<<(ok?"YES\n":"NO\n");
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int h;
int main(){
    int tt;
    cin>>tt;
    while(tt--){
        int n;
        int a[200000];
        cin>>n;
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
        for(int i=1;i<n;i++){
            if a[0]==a[i];
            h=h+1;
        }
        if(h==n-1){
            cout<<n<<'\n';
        }
        else{
            cout<<1<<'\n';
        }
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int h;
int main(){
    int tt;
    cin>>tt;
    while(tt--){
        int n;
        int a[200000];
        cin>>n;
        for(i=0;i<n;i++){
            cin>>a[i];
        }
        for(i=1;i<n;i++){
            if (a[0]==a[i]);
            h=h+1;
        }
        if(h==n-1){
            cout<<n<<'\n';
        }
        else{
            cout<<1<<'\n';
        }
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int h;
int main(){
    int tt;
    cin>>tt;
    while(tt--){
        int n;
        int a[200000];
        cin>>n;
        for(i=0;i<n;i++){
            cin>>a[i];
        }
        for(i=1;i<n;i++){
            if a[0]==a[i];
            h=h+1;
        }
        if(h==n-1){
            cout<<n<<'\n';
        }
        else{
            cout<<1<<'\n';
        }
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int h;
int main(){
    int tt;
    cin>>tt;
    while(tt--){
        int n;
        int a[200000];
        cin>>n;
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
        for(int i=1;i<n;i++){
            if (a[0]==a[i]);
            h=h+1;
        }
        if(h==n-1){
            cout<<n<<'\n';
        }
        else{
            cout<<1<<'\n';
        }
    }
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int test;
    cin >> test;
    while(test--){
        int n, j = 0;
        cin >> n;
        int a[n];
        for(int i = 0; i < n; i++){
            cin >> a[i];
        }
        for(int i = 0 ; i < n - 1 ; i++){
            if(a[i] != a[i + 1]){
                a[i] = a[i] + a[i + 1];
                j++;
            }
            else if{
                continue;
            }
        }
        cout << (sizeof(a)/sizeof(a[0])) - j << endl;
    }
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int test;
    cin >> test;
    while(test--){
        int n, j = 0;
        cin >> n;
        int a[n];
        for(int i = 0; i < n; i++){
            cin >> a[i];
        }
        while(n--){
            for(int i = 0 ; i < n - 1 ; i+=2){
                if(a[i] != a[i + 1]){
                    a[i] = a[i] + a[i + 1];
                    j++;
                }
                else{
                    continue;
                }
            }
        }
        cout << (sizeof(a)/sizeof(a[0])) - j << endl;
    }
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int test;
    cin >> test;
    while(test--){
        int n, j = 0;
        cin >> n;
        int a[n];
        for(int i = 0; i < n; i++){
            cin >> a[i];
        }
        for(int i = 0 ; i < n - 1 ; i++){
            if(a[i] != a[i + 1]){
                a[i] = a[i] + a[i + 1];
                j++;
            }
            else{
                continue;
            }
        }
        cout << (sizeof(a)/sizeof(a[0])) - j << endl;
    }
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int test;
    cin >> test;
    while(test--){
        int n, j = 0;
        cin >> n;
        int a[n];
        for(int i = 0; i < n; i++){
            cin >> a[i];
        }
        sort(a, a + n);
        if(a[0] == a[n - 1]){
            cout << n << endl;
        }
        else{
            cout << 1 << endl;
        }
    }
    return 0;
}


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

int main()
{
    int test;
    cin >> test;
    while(test--){
        int n;
        cin >> n;
        int a[n];
        for(int i = 0; i < n; i++){
            cin >> a[i];
        }
        sort(a, a + n);
        if(a[0] == a[n - 1]){
            cout << n << endl;
        }
        else{
            cout << 1 << endl;
        }
    }
    return 0;
}


#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
#define FAST  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long int
#define ar array
#define pb push_back
#define fi(a,b) for(int i=a;i<(b);i++)
#define fj(a,b) for(int j=a;j<(b);j++)
#define fk(a,b) for(int k=a;k<(b);k++)
#define lb lower_bound
#define ub upper_bound
//hash base 177013

int main()
{
	FAST;
	//#ifndef ONLINE_JUDGE
	//	freopen("input.txt","r",stdin);
	//	freopen("output.txt","w",stdout);
	//#endif
	ll testcase;
	cin>>testcase;
	while(testcase--)
	{
		 int n;
		 cin>>n;
		 int x;
		 cin>>x;
		 bool flag=false;
		 fi(1,n)
		 {
			 int b;
			 cin>>b;
			 if(x!=b)
			 {
				 flag=true;
			 }
		 }
		 if(flag)
		 {
			 cout<<1<<'\n';
		 }
		 else
		 {
			 cout<<n<<'\n';
		 }

	}
}


#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
#define FAST  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long int
#define ar array
#define pb push_back
#define fi(a,b) for(int i=a;i<(b);i++)
#define fj(a,b) for(int j=a;j<(b);j++)
#define fk(a,b) for(int k=a;k<(b);k++)
#define lb lower_bound
#define ub upper_bound
//hash base 177013

int main()
{
	FAST;
	//#ifndef ONLINE_JUDGE
	//	freopen("input.txt","r",stdin);
	//	freopen("output.txt","w",stdout);
	//#endif
	ll testcase;
	cin>>testcase;
	while(testcase--)
	{
		int n;
		cin>>n;
		vector<ll> a;
		fi(0,n)
		{
			ll x;
			cin>>x;
			a.pb(x);
		}
		int ans=n;
		bool flag=false;
		fi(0,n-1)
		{
			if(a[i]!=a[i+1])
			{
				ans--;
				a[i+1]=a[i]+a[i+1];
			}
			else
			{
				fj(i,n)
				{
					if(a[j]!=a[i])
					{
						flag=true;
						break;
					}
				}
				break;
			}
		}
		if(flag)
		{
			cout<<1<<'\n';
		}
		else
		{
			cout<<ans<<'\n';
		}
	}
}


#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
#define FAST  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long int
#define ar array
#define pb push_back
#define fi(a,b) for(int i=a;i<(b);i++)
#define fj(a,b) for(int j=a;j<(b);j++)
#define fk(a,b) for(int k=a;k<(b);k++)
#define lb lower_bound
#define ub upper_bound
//hash base 177013

int main()
{
	FAST;
	//#ifndef ONLINE_JUDGE
	//	freopen("input.txt","r",stdin);
	//	freopen("output.txt","w",stdout);
	//#endif
	ll testcase;
	cin>>testcase;
	while(testcase--)
	{
		int n;
		cin>>n;
		vector<int> a;
		fi(0,n)
		{
			int x;
			cin>>x;
			a.pb(x);
		}
		int ans=n;
		bool flag=false;
		fi(0,n-1)
		{
			if(a[i]!=a[i+1])
			{
				ans--;
				a[i+1]=a[i]+a[i+1];
			}
			else
			{
				fj(i,n)
				{
					if(a[j]!=a[i])
					{
						flag=true;
						break;
					}
				}
				break;
			}
			//fk(0,n)
			//{
				//cout<<a[k]<<' ';
			//}
			//cout<<'\n';
		}
		if(flag)
		{
			cout<<1<<'\n';
		}
		else
		{
			cout<<ans<<'\n';
		}
	}
}


#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
#define FAST  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long int
#define ar array
#define pb push_back
#define fi(a,b) for(int i=a;i<(b);i++)
#define fj(a,b) for(int j=a;j<(b);j++)
#define fk(a,b) for(int k=a;k<(b);k++)
#define lb lower_bound
#define ub upper_bound
//hash base 177013

int main()
{
	FAST;
	//#ifndef ONLINE_JUDGE
	//	freopen("input.txt","r",stdin);
	//	freopen("output.txt","w",stdout);
	//#endif
	ll testcase;
	cin>>testcase;
	while(testcase--)
	{
		int n;
		cin>>n;
		vector<ll> a;
		fi(0,n)
		{
			ll x;
			cin>>x;
			a.pb(x);
		}
		int ans=n;
		bool flag=false;
		fi(0,n-1)
		{
			if(a[i]!=a[i+1])
			{
				ans--;
				a[i+1]=a[i]+a[i+1];
			}
			else
			{
				fj(i,n)
				{
					if(a[j]!=a[i])
					{
						flag=true;
						break;
					}
				}
				if(flag) break;
			}
		}
		if(flag)
		{
			cout<<1<<'\n';
		}
		else
		{
			cout<<ans<<'\n';
		}
	}
}


#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
#define FAST  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long int
#define ar array
#define pb push_back
#define fi(a,b) for(int i=a;i<(b);i++)
#define fj(a,b) for(int j=a;j<(b);j++)
#define fk(a,b) for(int k=a;k<(b);k++)
#define lb lower_bound
#define ub upper_bound
//hash base 177013

int main()
{
	FAST;
	//#ifndef ONLINE_JUDGE
	//	freopen("input.txt","r",stdin);
	//	freopen("output.txt","w",stdout);
	//#endif
	ll testcase;
	cin>>testcase;
	while(testcase--)
	{
		int n;
		cin>>n;
		vector<int> a;
		fi(0,n)
		{
			int x;
			cin>>x;
			a.pb(x);
		}
		int mini=1e9+7;
		while(1)
		{
			bool flag=false;
			vector<int> x;
			fi(0,(int)a.size()-1){
				if(a[i]!=a[i+1])
				{
					x.pb(a[i]+a[i+1]);
					flag=true;
					i++;
				}
			}
			mini=min(mini,(int)a.size());
			a.clear();
			a=x;
			if(!flag) break;
		}
		cout<<mini<<'\n';

	}
}


#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
#define FAST  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long int
#define ar array
#define pb push_back
#define fi(a,b) for(int i=a;i<(b);i++)
#define fj(a,b) for(int j=a;j<(b);j++)
#define fk(a,b) for(int k=a;k<(b);k++)
#define lb lower_bound
#define ub upper_bound
//hash base 177013

int main()
{
	FAST;
	//#ifndef ONLINE_JUDGE
	//	freopen("input.txt","r",stdin);
	//	freopen("output.txt","w",stdout);
	//#endif
	ll testcase;
	cin>>testcase;
	while(testcase--)
	{
		int n;
		cin>>n;
		vector<int> a;
		fi(0,n)
		{
			int x;
			cin>>x;
			a.pb(x);
		}
		int ans=n;
		bool flag=false;
		fi(0,n-1)
		{
			if(a[i]!=a[i+1])
			{
				ans--;
				a[i+1]=a[i]+a[i+1];
			}
			else
			{
				fj(i,n)
				{
					if(a[j]!=a[i])
					{
						flag=true;
						break;
					}
				}
			}
			//fk(0,n)
			//{
				//cout<<a[k]<<' ';
			//}
			//cout<<'\n';
		}
		if(flag)
		{
			cout<<1<<'\n';
		}
		else
		{
			cout<<ans<<'\n';
		}
	}
}


#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
#define FAST  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long int
#define ar array
#define pb push_back
#define fi(a,b) for(int i=a;i<(b);i++)
#define fj(a,b) for(int j=a;j<(b);j++)
#define fk(a,b) for(int k=a;k<(b);k++)
#define lb lower_bound
#define ub upper_bound
//hash base 177013

int main()
{
	FAST;
	//#ifndef ONLINE_JUDGE
	//	freopen("input.txt","r",stdin);
	//	freopen("output.txt","w",stdout);
	//#endif
	ll testcase;
	cin>>testcase;
	while(testcase--)
	{
		int n;
		cin>>n;
		vector<ll> a;
		fi(0,n)
		{
			ll x;
			cin>>x;
			a.pb(x);
		}
		if(n==1)
		{
			cout<<1<<'\n';
			continue;
		}
		int ans=n;
		bool flag=false;
		fi(0,n-1)
		{
			if(a[i]!=a[i+1])
			{
				ans--;
				a[i+1]=a[i]+a[i+1];
			}
			else
			{
				fj(i,n)
				{
					if(a[j]!=a[i])
					{
						flag=true;
						break;
					}
				}
				//if(flag) break;
				break;
			}
		}
		if(flag)
		{
			cout<<1<<'\n';
		}
		else
		{
			cout<<ans<<'\n';
		}
	}
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;

//#define for(i,a,b) for(int i=a ; i<=b ; i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
const int N = (int)1e6 + 7;

//std::priority_queue<int>q;
//vector<int>iterator it;
//ll a[N];
//vector<int>v;
int main()
{
  set<int>set;
  int t,n,a[200005],k;
  cin>>t;
  while(t--)
  {
    cin>>n;
   for(int i=0;i<n;i++)
   {
      cin>>k;
      set.insert(k);

   }
  int size=set.size();
  if (size==n)
  cout<<n<<endl;
  else
  cout<<1<<endl;

  }
   return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;

//#define for(i,a,b) for(int i=a ; i<=b ; i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
const int N = (int)1e6 + 7;

//std::priority_queue<int>q;
//vector<int>iterator it;
//ll a[N];
//vector<int>v;
int main()
{
  set<int>set;
  int t,n,a[200005],k;
  cin>>t;
  while(t--)
  {
    cin>>n;
   for(int i=0;i<n;i++)
   {
      cin>>k;
      set.insert(k);

   }
  int size=set.size();
  if (size<n)
  cout<<1<<endl;
  else
  cout<<n<<endl;

  }
   return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;

//#define for(i,a,b) for(int i=a ; i<=b ; i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
const int N = (int)1e6 + 7;

//std::priority_queue<int>q;
//vector<int>iterator it;
//ll a[N];
//vector<int>v;
int main()
{
  set<int>set;
  int t,n,a[200005],k;
  cin>>t;
  while(t--)
  {
    cin>>n;
   for(int i=0;i<n;i++)
   {
      cin>>k;
      set.insert(k);

   }
  int size=set.size();
  if (k==n)
  cout<<n<<endl;
  else
  cout<<1<<endl;

  }
   return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;

//#define for(i,a,b) for(int i=a ; i<=b ; i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
const int N = (int)1e6 + 7;

//std::priority_queue<int>q;
//vector<int>iterator it;
//ll a[N];
//vector<int>v;
int main()
{
  set<int>set;
  int t,n,a[200005],k;
  cin>>t;
  while(t--)
  {
    cin>>n;
   for(int i=0;i<n;i++)
   {
      cin>>k;
      set.insert(k);

   }
  int size=set.size();
  if (size==1)
  cout<<n<<endl;
  else
  cout<<1<<endl;
  set.clear();

  }
   return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;

//#define for(i,a,b) for(int i=a ; i<=b ; i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
const int N = (int)1e6 + 7;

//std::priority_queue<int>q;
//vector<int>iterator it;
//ll a[N];
//vector<int>v;
int main()
{

  int t,n;
  cin>>t;
  while(t--)
  {

    cin>>n;
    vector<int> v(n);
   for(int i=0;i<n;i++)  cin>>v[i];
    cout<< (*min_element(v.begin(),v.end())==*max_element(v.begin(),v.end())?n:1) << endl;

  }
   return 0;
}