#include <bits/stdc++.h>
using namespace std;
int n, top;
long long q;
deque<int> Q;
int x[100010];
vector<pair<int, int> > ans;
int main() {
  int T, i, j;
  cin >> n >> T;
  for (i = 1; i <= n; i++) {
    int temp;
    scanf("%d", &temp);
    top = (top > temp ? top : temp);
    Q.push_back(temp);
  }
  int A = -1, B = -1;
  while (A != top) {
    A = Q.front();
    Q.pop_front();
    B = Q.front();
    Q.pop_front();
    if (A > B) {
      Q.push_front(A);
      Q.push_back(B);
    } else {
      Q.push_front(B);
      Q.push_back(A);
    }
    ans.push_back(make_pair(A, B));
  }
  for (i = 1; i <= n; i++) {
    x[i] = Q.front();
    Q.pop_front();
  }
  while (T--) {
    cin >> q;
    if (q <= ans.size()) {
      printf("%d %d\n", ans[q - 1].first, ans[q - 1].second);
      continue;
    }
    q -= ans.size();
    int temp;
    if (q % (n - 1) == 0)
      temp = n;
    else
      temp = q % (n - 1) + 1;
    printf("%d %d\n", x[1], x[temp]);
  }
  return 0;
}
