#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, q;
  cin >> n >> q;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  vector<pair<int, int>> moves(n);
  int maxi = 0;
  for (int i = 0; i < n; i++) {
    if (a[maxi] < a[i]) maxi = i;
  }
  deque<int> dq;
  for (int i = 0; i < n; i++) dq.push_back(a[i]);
  int i = 0;
  int arr[n];
  if (maxi) {
    while (true) {
      int ele1 = dq.front();
      dq.pop_front();
      int ele2 = dq.front();
      dq.pop_front();
      if (ele1 > ele2) {
        dq.push_front(ele1);
        dq.push_back(ele2);
      } else {
        dq.push_back(ele1);
        dq.push_front(ele2);
      }
      moves[i++] = {ele1, ele2};
      if (max(ele1, ele2) == a[maxi]) break;
    }
  }
  int k = 0;
  dq.pop_front();
  while (!dq.empty()) {
    arr[k++] = dq.front();
    dq.pop_front();
  }
  for (int i = 0; i < q; i++) {
    long long m;
    cin >> m;
    if (m <= maxi)
      cout << moves[m - 1].first << " " << moves[m - 1].second << "\n";
    else {
      long long rem = m - maxi;
      rem = rem % (n - 1);
      if (rem == 0) rem = n - 1;
      cout << a[maxi] << " " << arr[rem - 1] << "\n";
    }
  }
}
