func_code_string: #include <bits/stdc++.h>   using namespace std;   int main() {     map<long long, pair<long long, long long> > mpl;     vector<long long> ml;     long long n, q, xi, amyor = 0;     scanf( %lld %lld , &n, &q);     deque<long long> dq;     for (int i = (0); i < int(n); i++) {       scanf( %lld , &xi);       amyor = max(amyor, xi);       dq.push_back(xi);     }     long long cnt = 0;     while (1) {       if (dq.front() == amyor) break;       long long A = dq.front();       dq.pop_front();       long long B = dq.front();       dq.pop_front();       if (B > A) {         dq.push_front(B);         dq.push_back(A);       } else {         dq.push_front(A);         dq.push_back(B);       }       mpl[cnt] = {A, B};       cnt++;     }     dq.pop_front();     while (!dq.empty()) {       ml.push_back(dq.front());       dq.pop_front();     }     while (q--) {       long long m;       scanf( %lld , &m);       if (m <= cnt) {         m--;         long long x, y;         printf( %lld %lld n , mpl[m].first, mpl[m].second);       } else {         long long N = cnt;         long long rango = (m - N);         N = ml.size();         long long D = rango % N;         if (D == 0) D = N;         D--;         m = D;         printf( %lld %lld n , amyor, ml[m]);       }     }     return 0;   }   