#include <bits/stdc++.h>
using namespace std;
int n, m, x, threshold, large;
int ans[200020][2];
std::deque<int> dq;
long long k;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &x);
    dq.push_back(x);
  }
  int large = dq[0];
  for (int i = 1; i <= n; ++i)
    if (dq[i - 1] > large) large = dq[i - 1];
  threshold = 0;
  while (dq.front() != large) {
    int A = dq.front();
    dq.pop_front();
    int B = dq.front();
    dq.pop_front();
    ans[++threshold][0] = A;
    ans[threshold][1] = B;
    if (A < B) swap(A, B);
    dq.push_front(A);
    dq.push_back(B);
  }
  while (m--) {
    cin >> k;
    if (k <= threshold) {
      printf("%d %d\n", ans[k][0], ans[k][1]);
    } else {
      k -= threshold;
      k %= (n - 1);
      if (!k) k = n - 1;
      printf("%d %d\n", dq.front(), dq[k]);
    }
  }
  return 0;
}
