#include <bits/stdc++.h>
using namespace std;
deque<long long> d;
vector<pair<long long, long long> > v;
int main() {
  long long n, q, m = 0;
  long long a[100001];
  cin >> n >> q;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    m = max(m, a[i]);
    d.push_back(a[i]);
  }
  long long x = a[0];
  v.push_back(make_pair(d[0], d[1]));
  while (d[0] != m) {
    if (d[0] > d[1]) {
      long long w = d[0], e = d[1];
      d.pop_front();
      d.pop_front();
      d.push_back(e);
      d.push_front(w);
    } else {
      long long w = d[0], e = d[1];
      d.pop_front();
      d.push_back(w);
    }
    v.push_back(make_pair(d[0], d[1]));
  }
  for (int i = 0; i < q; i++) {
    long long t;
    cin >> t;
    if (t <= v.size())
      cout << v[t - 1].first << " " << v[t - 1].second << endl;
    else {
      cout << d[0] << " " << d[1 + (t - v.size()) % (n - 1)] << " ";
    }
  }
}
