#include <bits/stdc++.h>
using namespace std;
deque<int> dq;
pair<int, int> r[100002];
int main() {
  int n, m;
  cin >> n >> m;
  int maxx = 0;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    dq.push_back(a);
    maxx = max(a, maxx);
  }
  int k = 0;
  while (dq.front() != maxx) {
    r[k].first = dq[0];
    r[k].second = dq[1];
    k++;
    int x = dq.front();
    dq.pop_front();
    int y = dq.front();
    dq.pop_front();
    dq.push_back(min(x, y));
    dq.push_front(max(x, y));
  }
  while (m--) {
    long long a;
    cin >> a;
    if (a <= k) {
      cout << r[a - 1].first << " " << r[a - 1].second << endl;
      continue;
    }
    int idx = (a - k) % (n - 1);
    if (idx == 0) {
      cout << maxx << " " << dq[n - 1] << endl;
    } else {
      cout << maxx << " " << dq[idx] << endl;
    }
  }
}
