#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, qu;
  cin >> n >> qu;
  long long int a[n], i;
  for (i = 0; i < n; i++) cin >> a[i];
  deque<int> q;
  map<int, pair<int, int> > m;
  long long int ma = 0, mai = -1;
  for (i = 0; i < n; i++) {
    q.push_back(a[i]);
    if (a[i] > ma) {
      ma = a[i];
      mai = i;
    }
  }
  i = 1;
  long long int t, u;
  while (q.front() != ma) {
    t = q.front();
    q.pop_front();
    u = q.front();
    q.pop_front();
    m[i++] = make_pair(t, u);
    if (t > u) {
      q.push_front(t);
      q.push_back(u);
    } else {
      q.push_front(u);
      q.push_back(t);
    }
  }
  i = 0;
  while (!q.empty()) {
    a[i++] = q.front();
    q.pop_front();
  }
  long long int j;
  for (j = 0; j < qu; j++) {
    long long int k;
    cin >> k;
    if (k < mai + 1) {
      cout << m[k].first << " " << m[k].second << endl;
    } else {
      cout << a[0] << " " << a[((k - (mai + 1)) % (n - 1)) + 1];
      cout << endl;
    }
  }
}
