#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
int firsts[100005], seconds[100005];
int main() {
  int n, q, a, max_ = 0;
  cin >> n >> q;
  deque<int> dq;
  for (int i = 0; i < n; i++) {
    cin >> a;
    max_ = max(a, max_);
    dq.push_back(a);
  }
  int contador = 1;
  while (dq.front() != max_) {
    firsts[contador] = dq.front();
    dq.pop_front();
    seconds[contador] = dq.front();
    dq.pop_front();
    dq.push_front(max(firsts[contador], seconds[contador]));
    dq.push_back(min(firsts[contador], seconds[contador]));
    contador++;
  }
  long long m;
  for (int j = 0; j < q; j++) {
    cin >> m;
    if (m < contador)
      cout << firsts[m] << " " << seconds[m] << "\n";
    else
      cout << max_ << " " << dq[(m - contador) % (n - 1) + 1] << "\n";
  }
  return 0;
}
