//法1,采用map键值对查找的方法,时间复杂度是o(nlogn),find函数的时间复杂度是o(logn)
#include<iostream>
#include<vector>
#include<unordered_map>
using namespace std;
vector<int> a;
unordered_map<int,int> b;
int main(){
int n,m,x,v;
cin>>n>>m>>x;
for(int i = 0; i < n; i ++){
cin >> v;
a.push_back(v);
}
for(int i = 0; i < m; i ++){
cin >> v;
b.insert(make_pair(v,i));
}
for(int i = 0; i < n; i ++){
if (b.find(x - a[i]) != b.end()){
cout<<i<<" "<<b[x - a[i]];
return 0;
}
}
}
//法2 采用双指针算法,时间复杂度为o(m + n),利用两个数组都是单调的性质,i指针从前往后搜索,j指针从后往前
#include<iostream>
using namespace std;
const int N = 1e5 + 10;
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];
for(int i =0,j = m - 1; i <n; i ++){
while(a[i] + b[j] > x && j >=0)
j --;
if (a[i] + b[j] == x){
cout<<i<<" "<<j<<endl;
return 0;
}
}
}