#include <bits/stdc++.h>
template <typename T>
T Max(T x, T y) {
  return x > y ? x : y;
}
template <typename T>
T Min(T x, T y) {
  return x < y ? x : y;
}
template <typename T>
T Abs(T x) {
  return x < 0 ? -x : x;
}
template <typename T>
T &read(T &r) {
  r = 0;
  bool w = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') w = ch == '-' ? 1 : 0, ch = getchar();
  while (ch >= '0' && ch <= '9')
    r = (r << 3) + (r << 1) + (ch ^ 48), ch = getchar();
  return r = w ? -r : r;
}
const int N = 1000010;
int n, a[N << 1], mx, p, b[N], ans1[N], ans2[N];
signed main() {
  read(n);
  int q;
  read(q);
  for (int i = 1; i <= n; ++i) b[i] = read(a[i]), mx = Max(mx, a[i]);
  p = 2;
  int pn = n;
  ans1[1] = a[1];
  ans2[1] = a[2];
  while (a[1] != mx) {
    if (a[1] > a[p])
      a[++pn] = a[p];
    else
      std::swap(a[1], a[p]), a[++pn] = a[p];
    ans1[p] = a[1];
    ans2[p] = a[p + 1];
    ++p;
  }
  --p;
  for (int i = 1; i <= q; ++i) {
    long long m;
    read(m);
    if (m < p)
      printf("%d %d\n", ans1[m], ans2[m]);
    else {
      printf("%d %d\n", mx,
             a[p +
               ((m - p + 1) % (n - 1) == 0 ? (n - 1) : (m - p + 1) % (n - 1))]);
    }
  }
  return 0;
}
