#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, q;
  cin >> n >> q;
  int a[n];
  int maxIndex;
  int maxV = -1;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] > maxV) {
      maxV = a[i];
      maxIndex = i;
    }
  }
  int answer[maxIndex + 1][2];
  int endstate[n];
  endstate[0] = maxV;
  for (int i = maxIndex + 1; i < n; i++) {
    endstate[i - maxIndex] = a[i];
  }
  for (int i = 0; i < maxIndex + 1; i++) {
    answer[i][1] = a[i];
    if (i == 0) {
      answer[0][0] = a[0];
    } else {
      answer[i][0] = max(answer[i - 1][0], answer[i - 1][1]);
      endstate[n - (maxIndex + 1) + i] = min(answer[i][0], answer[i][1]);
    }
  }
  for (int i = 0; i < q; i++) {
    long long op;
    cin >> op;
    if (op < maxIndex + 1) {
      cout << answer[op][0] << " " << answer[op][1] << endl;
    } else {
      long long wrappedQ = ((op - (maxIndex + 1)) % (n - 1)) + 1;
      cout << maxV << " " << endstate[wrappedQ] << endl;
    }
  }
  return 0;
}
