#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i <= b; i++)
int n, m, x;
const int N = 1e5 + 10;
int a[N], b[N];
using namespace std;
int main() {
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
cin >> n >> m >> x;
rep(i, 1, n) cin >> a[i];
rep(i, 1, m) cin >> b[i];
int i = 1, j = m;
while(a[i] + b[j] != x) {
if (a[i] + b[j] > x) j--;
else i++;
}
cout << i - 1 << " " << j - 1 << endl;
}