解法:
#include<iostream>
#include<vector>
using namespace std;
int main() {
int n, m, k;
cin >> n;
vector<char> man(n);
for (int i = 0; i < n; i++) cin >> man[i];
cin >> m;
vector<char> woman(m);
for (int i = 0; i < m; i++) cin >> woman[i];
cin >> k;
cout << man[(k-1)%n] << " " << woman[(k - 1) % m];
return 0;
}