#include <bits/stdc++.h>
using namespace std;
inline long long Max(const long long &x, const long long &y) {
  return x > y ? x : y;
}
inline long long Min(const long long &x, const long long &y) {
  return x < y ? x : y;
}
inline void read(long long &x) {
  x = 0;
  long long f = 1;
  char s = getchar();
  while (s < '0' || s > '9') {
    if (s == '-') f = -1;
    s = getchar();
  }
  while (s >= '0' && s <= '9') {
    x = (x << 3) + (x << 1) + (s ^ 48);
    s = getchar();
  }
  x *= f;
}
long long MAX, Starttot, AS[100005], BS[100005], XHA[100005], XHB[100005];
deque<long long> Q;
int main() {
  long long n, m;
  read(n);
  read(m);
  for (register int i = 1; i <= n; ++i) {
    long long a;
    read(a);
    MAX = Max(MAX, a);
    Q.push_back(a);
  }
  while (Q.front() != MAX) {
    Starttot++;
    long long A = Q.front();
    Q.pop_front();
    long long B = Q.front();
    Q.pop_front();
    AS[Starttot] = A;
    BS[Starttot] = B;
    if (A > B) {
      Q.push_front(A);
      Q.push_back(B);
    } else {
      Q.push_front(B);
      Q.push_back(A);
    }
  }
  for (register int i = 1; i < n; ++i) {
    long long A = Q.front();
    Q.pop_front();
    long long B = Q.front();
    Q.pop_front();
    XHA[i] = A;
    XHB[i] = B;
    Q.push_front(A);
    Q.push_back(B);
  }
  while (m--) {
    long long x;
    read(x);
    if (x <= Starttot)
      printf("%lld %lld\n", AS[x], BS[x]);
    else {
      x -= Starttot;
      x %= (n - 1);
      if (!x) x = n - 1;
      printf("%lld %lld\n", XHA[x], XHB[x]);
    }
  }
  return 0;
}
