#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimization("unroll-loops")
std::pair<int, int> DR[] = {{-1, 0}, {0, 1},   {1, 0}, {0, -1},
                            {-1, 1}, {-1, -1}, {1, 1}, {1, -1}};
using namespace std;
template <class c>
struct rge {
  c b, e;
};
template <class c>
rge<c> range(c i, c j) {
  return rge<c>{i, j};
}
template <class c>
auto dud(c* x) -> decltype(cerr << *x, 0);
template <class c>
char dud(...);
struct debug {
  ~debug() { cerr << endl; }
  template <class c>
  typename enable_if<sizeof dud<c>(0) != 1, debug&>::type operator<<(c i) {
    cerr << boolalpha << i;
    return *this;
  }
  template <class c>
  typename enable_if<sizeof dud<c>(0) == 1, debug&>::type operator<<(c i) {
    return *this << range(begin(i), end(i));
  }
  template <class c, class b>
  debug& operator<<(pair<b, c> d) {
    return *this << "(" << d.first << ", " << d.second << ")";
  }
  template <class c>
  debug& operator<<(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it;
    return *this << "]";
  }
};
long long gcd(long long a, long long b) {
  if (b) return gcd(b, a % b);
  return a;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
deque<long long> dq;
long long n, q, x, mx;
pair<long long, long long> ans[1 << 19];
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cerr.tie(0);
  cout.tie(0);
  cin >> n >> q;
  for (long long i = 1; i <= n; i++) {
    cin >> x;
    mx = max(mx, x);
    dq.push_back(x);
  }
  long long cnt = 0;
  while (1) {
    if (dq.front() == mx) break;
    cnt++;
    long long x = dq.front();
    dq.pop_front();
    long long y = dq.front();
    dq.pop_front();
    ans[cnt] = make_pair(x, y);
    if (y > x) swap(x, y);
    dq.push_back(y);
    dq.push_front(x);
  }
  vector<long long> vec;
  dq.pop_front();
  for (auto it : dq) {
    vec.push_back(it);
  }
  while (q--) {
    long long x;
    cin >> x;
    if (x <= cnt) {
      cout << ans[x].first << ' ' << ans[x].second << '\n';
    } else {
      x -= cnt;
      x--;
      cout << mx << ' ' << vec[x % (long long)((vec).size())] << '\n';
    }
  }
  return 0;
}
