#include <bits/stdc++.h>
using namespace std;
int main() {
  deque<int> d;
  int n, q, maxx = -1;
  cin >> n >> q;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    d.push_back(a);
    maxx = max(maxx, a);
  }
  vector<pair<int, int> > ele;
  while (d.front() != maxx) {
    int a1 = d.front();
    d.pop_front();
    int a2 = d.front();
    d.pop_front();
    if (a1 > a2) {
      d.push_front(a1);
      d.push_back(a2);
    } else {
      d.push_front(a2);
      d.push_back(a1);
    }
    ele.push_back(make_pair(a1, a2));
  }
  vector<int> num(n);
  int i = 0;
  for (deque<int>::iterator it = d.begin(); it != d.end(); ++it) {
    num[i] = *it;
    i++;
  }
  for (int i = 0; i < q; ++i) {
    long long m;
    cin >> m;
    if (m <= (int)ele.size()) {
      cout << ele[m - 1].first << " " << ele[m - 1].second << endl;
    } else {
      if ((m - (int)ele.size()) % (n - 1) == 0) {
        cout << num[0] << " " << num[n - 1] << endl;
      } else {
        cout << num[0] << " " << num[(m - (int)ele.size()) % (n - 1)] << endl;
      }
    }
  }
  return 0;
}
