#include <bits/stdc++.h>
using namespace std;
long long n, m, x, y, z;
deque<long long> dq;
long long ara[400000];
pair<long long, long long> anss[400000];
int main() {
  cin >> n;
  cin >> m;
  long long mx = 0;
  for (long long i = 1; i <= n; i++) {
    scanf("%lld", &ara[i]);
    dq.push_back(ara[i]);
    mx = max(mx, ara[i]);
  }
  long long cc = 1;
  while (dq.front() != mx) {
    long long xx = dq.front();
    dq.pop_front();
    long long yy = dq.front();
    dq.pop_front();
    anss[cc] = {xx, yy};
    cc++;
    if (xx > yy) {
      dq.push_back(yy);
      dq.push_front(xx);
    } else {
      dq.push_back(xx);
      dq.push_front(yy);
    }
  }
  for (long long i = 1; i <= n; i++) {
    ara[i] = dq.front();
    dq.pop_front();
  }
  while (m--) {
    scanf("%lld", &x);
    if (x < cc) {
      printf("%lld %lld\n", anss[x].first, anss[x].second);
    } else {
      long long xx = ara[1];
      long long yy = ara[2 + ((x - cc) % (n - 1))];
      printf("%lld %lld\n", xx, yy);
    }
  }
  return 0;
}
