#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 7;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const int mod = 7340033;
const double eps = 1e-8;
const double PI = acos(-1);
template <class T, class S>
inline void add(T &a, S b) {
  a += b;
  if (a >= mod) a -= mod;
}
template <class T, class S>
inline void sub(T &a, S b) {
  a -= b;
  if (a < 0) a += mod;
}
template <class T, class S>
inline bool chkmax(T &a, S b) {
  return a < b ? a = b, true : false;
}
template <class T, class S>
inline bool chkmin(T &a, S b) {
  return a > b ? a = b, true : false;
}
int n, q, a[N];
int mn, mx, maxVal;
int ans[N][2];
int who[N];
set<pair<int, int> > Set;
int main() {
  scanf("%d%d", &n, &q);
  mn = 1, mx = n;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    Set.insert(make_pair(i, a[i]));
    chkmax(maxVal, a[i]);
  }
  int cnt = 0;
  while (Set.begin()->second != maxVal) {
    cnt++;
    auto it = Set.begin();
    pair<int, int> tmp1 = *it;
    ans[cnt][0] = it->second;
    ++it;
    ans[cnt][1] = it->second;
    pair<int, int> tmp2 = *it;
    Set.erase(tmp1);
    Set.erase(tmp2);
    if (tmp1.second > tmp2.second) {
      tmp2.first = ++mx;
      Set.insert(tmp1);
      Set.insert(tmp2);
    } else {
      tmp1.first = ++mx;
      Set.insert(tmp1);
      Set.insert(tmp2);
    }
  }
  auto it = Set.begin();
  ++it;
  int p = 1;
  while (it != Set.end()) {
    who[p] = it->second;
    ++it;
    ++p;
  }
  while (q--) {
    long long m;
    scanf("%lld", &m);
    if (m <= cnt)
      printf("%d %d\n", ans[m][0], ans[m][1]);
    else {
      m -= cnt;
      m %= (n - 1);
      if (!m) m += n - 1;
      printf("%d %d\n", maxVal, who[m]);
    }
  }
  return 0;
}
