#include <bits/stdc++.h>
using namespace std;
const long long int inf = 3e5;
const long long MOD = 1e9 + 7;
const int MAX = 505;
using namespace std;
void solve() {
  long long n, q;
  cin >> n >> q;
  deque<int> d(n);
  for (int &i : d) {
    cin >> i;
  }
  map<int, pair<int, int> > ans;
  for (int i = 1; i < n; ++i) {
    ans[i] = {d[0], d[1]};
    if (d[0] > d[1]) {
      d.push_back(d[1]);
      d.erase(d.begin() + 1);
    } else {
      d.push_back(d[0]);
      d.erase(d.begin());
    }
  }
  while (q--) {
    long long k;
    cin >> k;
    if (k < n) {
      cout << ans[k].first << " " << ans[k].second << endl;
    } else {
      k = (k % (n - 1));
      if (k == 0) k = n - 1;
      cout << d[0] << ' ' << d[k] << endl;
    }
  }
}
int main() {
  solve();
  return 0;
}
