#include <bits/stdc++.h>
struct Answer {
  int a, b;
};
int main() {
  int n, q;
  scanf("%d%d", &n, &q);
  std::deque<int> deq;
  for (int i = 0; i < n; i++) {
    int ai;
    scanf("%d", &ai);
    deq.push_back(ai);
  }
  Answer answers[n];
  for (int i = 0; i < n; i++) {
    answers[i].a = deq[0];
    answers[i].b = deq[1];
    deq.pop_front();
    deq.pop_front();
    if (answers[i].a > answers[i].b) {
      deq.push_front(answers[i].a);
      deq.push_back(answers[i].b);
    } else {
      deq.push_front(answers[i].b);
      deq.push_back(answers[i].a);
    }
  }
  for (int i = 0; i < q; i++) {
    long long mj;
    scanf("%lld", &mj);
    mj--;
    if (mj < n) {
      printf("%d %d\n", answers[mj].a, answers[mj].b);
    } else {
      printf("%d %d\n", deq[0], deq[1 + (mj - n) % (n - 1)]);
    }
  }
  return 0;
}
