#include <bits/stdc++.h>
using namespace std;
void solve();
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout << fixed << setprecision(10);
  long long t = 1;
  while (t--) solve();
  return 0;
}
void solve() {
  long long n, q;
  cin >> n >> q;
  vector<long long> a(n);
  for (long long i = 0; i < (long long)n; i++) cin >> a[i];
  long long mx = *max_element((a).begin(), (a).end());
  deque<long long> d;
  for (long long i = 0; i < (long long)n; i++) d.push_back(a[i]);
  vector<pair<long long, long long> > ops;
  ops.push_back({d[0], d[1]});
  while (d[0] != mx) {
    long long a = d[0];
    long long b = d[1];
    if (a < b) swap(a, b);
    d.pop_front();
    d.pop_front();
    d.push_front(a);
    d.push_back(b);
    pair<long long, long long> pus(d[0], d[1]);
    ops.push_back(pus);
  }
  long long l = ops.size();
  cerr << ("l") << " --- " << (l) << "\n";
  for (long long i = 0; i < (long long)q; i++) {
    long long t;
    cin >> t;
    if (t < l)
      cout << ops[t - 1].first << " " << ops[t - 1].second << "\n";
    else {
      t = t - l;
      t = t % (n - 1);
      t++;
      cout << d[0] << " " << d[t] << "\n";
    }
  }
}
