-
Notifications
You must be signed in to change notification settings - Fork 2
/
1284A.cpp
48 lines (43 loc) · 857 Bytes
/
1284A.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
* Author: Rushi Vachhani
* Platform: Codeforces
* Problem_ID: 1284A
* Language: C++
*/
#include<bits/stdc++.h>
using namespace std;
void solve() {
int n,m;
cin >> n >> m;
vector<string> s1, s2;
for(int i=0; i<n; i++) {
string temp;
cin >> temp;
s1.push_back(temp);
}
for(int i=0; i<m; i++) {
string temp;
cin >> temp;
s2.push_back(temp);
}
int q;
cin >> q;
vector<string> ans;
for(int i=0; i<q; i++) {
int year;
string yearName = "";
cin >> year;
yearName.append(s1[(year-1)%n]).append(s2[(year-1)%m]);
ans.push_back(yearName);
}
for(int i=0; i<q; i++) {
cout<<ans[i]<<"\n";
}
return;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
solve();
return 0;
}