#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, q, tmp_num, max_idx, max_num = -1;
  deque<int> dq;
  cin >> n >> q;
  for (int i = 0; i < n; ++i) {
    cin >> tmp_num;
    dq.push_back(tmp_num);
    if (tmp_num > max_num) {
      max_idx = i;
    }
  }
  int *A = new int[max_idx];
  int *B = new int[max_idx];
  int tmp_A, tmp_B;
  for (int i = 0; i < max_idx; ++i) {
    tmp_A = dq[0];
    tmp_B = dq[1];
    dq.pop_front();
    dq.pop_front();
    A[i] = tmp_A;
    B[i] = tmp_B;
    if (tmp_A > tmp_B) {
      dq.push_front(tmp_A);
      dq.push_back(tmp_B);
    } else {
      dq.push_front(tmp_B);
      dq.push_back(tmp_A);
    }
  }
  long long int m;
  for (int i = 0; i < q; ++i) {
    cin >> m;
    if (m <= max_idx) {
      cout << A[m - 1] << ' ' << B[m - 1] << endl;
    } else {
      cout << dq.front() << ' ';
      m = m % (n - 1);
      if (!m) m += (n - 1);
      cout << dq[m] << endl;
    }
  }
  return 0;
}
