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

using namespace std;

double findmed(vector<int> a, int b){
    if(b % 2 == 0){
        nth_element(a.begin(), a.begin() + b / 2, a.end());

        nth_element(a.begin(), a.begin() + (b - 1) / 2, a.end());

        return (double)(a[(b - 1) / 2] + a[b / 2]) / 2.0;
    }else{
        nth_element(a.begin(), a.begin() + b / 2, a.end());
        
        return (double)a[b / 2];
    }
}

int main()
{
    int inputa, inputb, temp, temp1 = 0;
    vector<int> veca = {};
    vector<int> vecb = {};
    vector<int> vecc = {};
    
    cin >> inputa >> inputb;
    
    for(int i = 0; i < inputa; i++){
        cin >> temp;
        veca.push_back(temp);
    }
    
    for(int j = 0; j < inputb; j++){
        cin >> temp1;
        vecb.push_back(temp1);
    }
    
    vecc.push_back(inputa);
    vecc.push_back(inputb);
    double calcu = findmed(vecc, vecc.size());
    
    if(find(vecc.begin(), vecc.end(), calcu) != vecc.end()){
        cout << 0 << endl;
    }else{
        cout << round(calcu) << endl; 
    }
    
    
    double cal = findmed(veca, veca.size());
    
    if(find(veca.begin(), veca.end(), cal) != veca.end()){
        cout << 0 << endl;
    }else{
        cout << round(cal) << endl;
    }
    
    double cal1 = findmed(vecb, vecb.size());
    
    if(find(vecb.begin(), vecb.end(), cal1) != vecb.end()){
        cout << 0 << endl;
    }else{
        cout << round(cal1) << endl;
    }
    
    return 0;
}