#include <bits/stdc++.h>
using namespace std;
const long long N = (long long)1e5 + 3;
long long n, q, mx = 1, a[N];
pair<long long, long long> res[N];
deque<long long> d;
vector<long long> bla;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> q;
  for (long long i = 1; i <= n; ++i) {
    cin >> a[i];
    d.push_back(a[i]);
    if (a[i] > a[mx]) mx = i;
  }
  long long op = 0, ile = mx - 1;
  while (--mx) {
    ++op;
    long long A = d.front();
    d.pop_front();
    long long B = d.front();
    d.pop_front();
    res[op] = {A, B};
    if (A > B) {
      d.push_front(A);
      d.push_back(B);
    } else {
      d.push_front(B);
      d.push_back(A);
    }
  }
  long long lol = d.front();
  d.pop_front();
  while (d.size()) {
    bla.push_back(d.front());
    d.pop_front();
  }
  long long si = bla.size();
  while (q--) {
    long long zap;
    cin >> zap;
    if (zap <= ile) {
      cout << res[zap].first << " " << res[zap].second << "\n";
      continue;
    }
    zap -= ile;
    zap %= si;
    zap = (zap - 1 + si) % si;
    cout << lol << " " << bla[zap] << "\n";
  }
}
