#include <bits/stdc++.h>
struct query {
  long long pos;
  int index;
  int a, b;
};
int n, q;
int a[200005];
query qu[300005];
std::deque<int> vals;
bool cmpPos(const query &q1, const query &q2) { return q1.pos < q2.pos; }
bool cmpIndex(const query &q1, const query &q2) { return q1.index < q2.index; }
int main() {
  scanf("%d %d", &n, &q);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    vals.push_back(a[i]);
  }
  for (int i = 0; i < q; i++) {
    scanf("%lld", &qu[i].pos);
    qu[i].index = i;
  }
  std::sort(qu, qu + q, cmpPos);
  int qup = 0;
  int front = vals.front();
  vals.pop_front();
  for (int i = 1; i <= n; i++) {
    while (qup < q && qu[qup].pos == i) {
      qu[qup].a = front;
      qu[qup].b = vals.front();
      qup++;
    }
    int next = vals.front();
    if (next > front) {
      std::swap(front, next);
    }
    vals.pop_front();
    vals.push_back(next);
  }
  long long prev = n + 1;
  int prevPos = 0;
  while (qup < q) {
    prevPos += (qu[qup].pos - prev) % (n - 1);
    prevPos %= (n - 1);
    qu[qup].a = front;
    qu[qup].b = vals[prevPos];
    prev = qu[qup].pos;
    qup++;
  }
  std::sort(qu, qu + q, cmpIndex);
  for (int i = 0; i < q; i++) {
    printf("%d %d\n", qu[i].a, qu[i].b);
  }
  return 0;
}
