#include <stdio.h>
#include <math.h>
#include <iostream>


using namespace std;

const int inf = 1000 * 1000 * 1000;
const int size = 1000 * 1000;

int color[4][size], len[4], ans[4];

int main()
{
    int i, j, best, p1, p2, p3, p4;

    freopen("style.in", "r", stdin);
    freopen("style.out", "w", stdout);

    for (i = 0; i < 4; i++)
    {
        scanf("%d", &len[i]);
        for (j = 0; j < len[i]; j++)
            scanf("%d", &color[i][j]);
    }

    best = inf;

    for (p1 = 0; p1 < len[0]; p1++)
        for (p2 = 0; p2 < len[1]; p2++)
            for (p3 = 0; p3 < len[2]; p3++)
                for (p4 = 0; p4 < len[3]; p4++)
                    if (max(max(color[0][p1], color[1][p2]), max(color[2][p3], color[3][p4])) - min(min(color[0][p1], color[1][p2]), min(color[2][p3], color[3][p4])) < best)
                    {
                        best = max(max(color[0][p1], color[1][p2]), max(color[2][p3], color[3][p4])) - min(min(color[0][p1], color[1][p2]), min(color[2][p3], color[3][p4]));
                        ans[0] = p1;
                        ans[1] = p2;
                        ans[2] = p3;
                        ans[3] = p4;
                    }

    printf("%d %d %d %d", color[0][ans[0]], color[1][ans[1]], color[2][ans[2]], color[3][ans[3]]);

    return 0;
}
