#include <iostream>
using namespace std;
const int N = 1e5 + 10;
int n, m, x;
int a[N], b[N];
int main () {
scanf("%d%d%d", &n, &m, &x);
for (int i = 0; i < n; i ++) scanf("%d", &a[i]);
for (int j = 0; j < m; j ++) scanf("%d", &b[j]);
for (int i = 0, j = m - 1; i < n; i ++) { //j初始设成m - 1 不是 j = m
while (j >= 0 && a[i] + b[j] > x) j --; //具有单调性, i增大时,a[i]增大,j减小时,b[j]减小
if (a[i] + b[j] == x) {
printf("%d %d\n", i, j);
break; //可以不加
}
}
return 0;
}