#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, q;
  long long m;
  cin >> n >> q;
  deque<long long> dq(n);
  for (long long i = 0; i < n; i++) {
    scanf("%lld", &dq[i]);
  }
  vector<pair<long long, long long> > vv(2 * n + 100);
  long long a, b;
  for (long long i = 0; i <= n * 2 + 5; i++) {
    a = dq[0];
    b = dq[1];
    dq.pop_front(), dq.pop_front();
    if (a > b) {
      dq.push_front(a);
      dq.push_back(b);
    } else {
      dq.push_front(b);
      dq.push_back(a);
    }
    vv[i + 1] = {a, b};
  }
  for (long long i = 1; i <= q; i++) {
    scanf("%lld", &m);
    if (m <= 2 * n)
      printf("%lld %lld\n", vv[m].first, vv[m].second);
    else {
      long long idx = m % (n - 1) + (n - 1);
      printf("%lld %lld\n", vv[idx].first, vv[idx].second);
    }
  }
}
