#include <bits/stdc++.h>
using namespace std;
int const N = 300001;
int n, qu, v[N];
int main() {
  scanf("%d%d", &n, &qu);
  deque<int> q;
  int mx = 0;
  for (int i = 0; i < n; ++i) {
    scanf("%d", v + i);
    mx = max(mx, v[i]);
    q.push_back(v[i]);
  }
  vector<int> an;
  vector<pair<int, int> > pr;
  int i = 0, prv = 0;
  while (q.front() != mx) {
    int A = q.front();
    q.pop_front();
    int B = q.front();
    q.pop_front();
    pr.push_back({A, B});
    q.push_back(min(A, B));
    q.push_front(max(A, B));
  }
  q.pop_front();
  while (!q.empty()) {
    an.push_back(q.front());
    q.pop_front();
  }
  while (qu--) {
    long long m;
    scanf("%lld", &m);
    if (m <= pr.size())
      printf("%d %d\n", pr[m - 1].first, pr[m - 1].second);
    else {
      m -= pr.size();
      i = (m - 1) % an.size();
      printf("%d %d\n", mx, an[i]);
    }
  }
}
