#include<bits/stdc++.h>
using namespace std;
const int N = 100005;
int a[N], b[N];
int main(){
int n, m, x;
cin>>n>>m>>x;
for(int i = 0; i < n; i++) cin>>a[i];
for(int i = 0; i < m; i++) cin>>b[i];
int l = 0, r = m-1;
while(a[l] + b[r] != x){
while(a[l] + b[r] > x) r--;
while(a[l] + b[r] < x) l++;
}
cout<<l<<" "<<r<<endl;
return 0;
}