#include <bits/stdc++.h>
using namespace std;
pair<long long, long long> findIndex(
    long long move, long long n,
    map<long long, pair<long long, long long> > &mp, vector<long long> &a) {
  pair<long long, long long> ans;
  if (move >= n - 1) {
    long long leftMove = move - (n - 1);
    long long index = (leftMove % (n - 1));
    ans = make_pair(a[0], a[index + 1]);
  } else {
    ans = mp[move];
  }
  return ans;
}
int main() {
  long long n, q;
  scanf("%lld%lld", &n, &q);
  deque<long long> dq;
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) {
    scanf("%lld", &a[i]);
    dq.push_back(a[i]);
  }
  map<long long, pair<long long, long long> > mp;
  for (long long i = 0; i < n - 1; i++) {
    long long fst = dq.front();
    dq.pop_front();
    long long snd = dq.front();
    dq.pop_front();
    pair<long long, long long> pr = make_pair(fst, snd);
    mp[i] = pr;
    if (fst < snd) {
      dq.push_front(snd);
      dq.push_back(fst);
    } else {
      dq.push_front(fst);
      dq.push_back(snd);
    }
  }
  a.clear();
  while (!dq.empty()) {
    a.push_back(dq.front());
    dq.pop_front();
  }
  mp[n - 1] = make_pair(a[0], a[1]);
  while (q--) {
    long long x;
    scanf("%lld", &x);
    pair<long long, long long> ans = findIndex(x - 1, n, mp, a);
    printf("%lld %lld\n", ans.first, ans.second);
  }
}
