#include <bits/stdc++.h>
using namespace std;
int main() {
  long long m, n, k = 0, l, r, steps, mx = 0;
  vector<long long> temp{}, t{}, ar1{}, ar2{};
  cin >> n >> m;
  for (long long i = 0; i < n; i++) {
    cin >> k;
    temp.push_back(k);
  }
  t = temp;
  ar1.push_back(temp[0]);
  ar2.push_back(temp[1]);
  for (long long i = 1; i < n; i++) {
    l = temp[i - 1];
    r = temp[i];
    if (l >= r) {
      ar1.push_back(l);
      ar2.push_back(temp[i + 1]);
      temp.push_back(r);
      temp[i] = l;
      mx = l;
    } else {
      ar1.push_back(r);
      ar2.push_back(temp[i + 1]);
      temp.push_back(l);
      mx = r;
    }
  }
  if (m == 0)
    ;
  else {
    while (m--) {
      cin >> steps;
      if (steps <= n) {
        cout << ar1[steps - 1] << " " << ar2[steps - 1] << endl;
      } else {
        steps -= n;
        long long b = steps % (n - 1);
        cout << mx << " " << temp[b + n] << endl;
      }
    }
  }
}
