#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<pair<int, int> > res;
  vector<int> v, ex;
  int a1, a2, b;
  queue<int> q;
  int n, k, idx = 0, Q;
  long long int c;
  cin >> n >> Q;
  int l = n;
  int f = INT_MIN, s = INT_MIN;
  for (l = 0; l < n; l++) {
    cin >> k;
    if (k > f) {
      s = f;
      f = k;
      idx = l;
    }
    v.push_back(k);
  }
  a1 = v[0];
  for (int i = 1; i <= idx; i++) {
    a2 = v[i];
    res.push_back(make_pair(a1, a2));
    if (a1 == f && a2 == s) {
      break;
    } else {
      if (a1 < a2) {
        q.push(a1);
        a1 = a2;
      } else if (a1 == a2) {
        break;
      } else {
        q.push(a2);
      }
    }
  }
  for (int i = idx + 1; i < n; i++) {
    ex.push_back(v[i]);
  }
  while (!q.empty()) {
    ex.push_back(q.front());
    q.pop();
  }
  while (Q--) {
    int sz = res.size();
    int szz = ex.size();
    cin >> c;
    if (c <= sz)
      cout << res[c - 1].first << " " << res[c - 1].second << "\n";
    else {
      long long int df = c - sz;
      if (df % szz == 0)
        cout << v[idx] << " " << ex[szz - 1] << "\n";
      else
        cout << v[idx] << " " << ex[(df % szz) - 1] << "\n";
    }
  }
  return 0;
}
