#include <bits/stdc++.h>
using namespace std;
void pr_vint(vector<int> &v) {
  for (int i = 0; i < v.size(); ++i) cout << v[i] << " ";
  cout << '\n';
}
int main() {
  long long n, k, mx = -1;
  cin >> n >> k;
  deque<long long> v;
  long long C;
  for (int i = 0; i < n; ++i) {
    cin >> C;
    v.push_back(C);
    mx = max(mx, C);
  }
  vector<pair<long long, long long> > ans, cyc;
  while (v[0] != mx) {
    ans.push_back({v[0], v[1]});
    long long nwmn = min(v[0], v[1]), nwmx = max(v[0], v[1]);
    v.pop_front();
    v.pop_front();
    v.push_front(nwmx);
    v.push_back(nwmn);
  }
  cyc.push_back({v[0], v[1]});
  long long nwmn = min(v[0], v[1]), nwmx = max(v[0], v[1]);
  v.pop_front();
  v.pop_front();
  v.push_front(nwmx);
  v.push_back(nwmn);
  for (int i = 0; i < n - 2; ++i) {
    cyc.push_back({v[0], v[1]});
    long long nwmn = min(v[0], v[1]), nwmx = max(v[0], v[1]);
    v.pop_front();
    v.pop_front();
    v.push_front(nwmx);
    v.push_back(nwmn);
  }
  long long C1;
  for (int i = 0; i < k; ++i) {
    cin >> C1;
    if (C1 <= (long long)ans.size())
      cout << ans[C1 - 1].first << " " << ans[C1 - 1].second << '\n';
    else
      cout
          << cyc[(C1 - (long long)ans.size() - 1) % (long long)cyc.size()].first
          << " "
          << cyc[(C1 - (long long)ans.size() - 1) % (long long)cyc.size()]
                 .second
          << '\n';
  }
  return 0;
}
