#include <bits/stdc++.h>
using namespace std;
const int MAXX = 1e5 + 10;
int n, T, tmp, mx, pos;
pair<int, int> ans[MAXX];
deque<int> dq;
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n >> T;
  for (int i = 0; i < n; i++) cin >> tmp, dq.push_back(tmp), mx = max(tmp, mx);
  for (int i = 0; i < n; i++) {
    long long x = dq[0], y = dq[1];
    dq.pop_front(), dq.pop_front();
    ans[i].first = x, ans[i].second = y;
    if (y >= x) swap(x, y);
    dq.push_front(x), dq.push_back(y);
  }
  while (T--) {
    long long x;
    cin >> x, --x;
    if (x < n)
      cout << ans[x].first << " " << ans[x].second << endl;
    else
      cout << dq[0] << " " << dq[(x - n) % (n - 1) + 1] << endl;
  }
}
