#include <bits/stdc++.h>
using namespace std;
long long pow(long long x, long long y, long long p) {
  long long res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long power(long long x, long long y) {
  long long res = 1;
  while (y > 0) {
    if (y & 1) res = (res * x);
    y = y >> 1;
    x = (x * x);
  }
  return res;
}
long long trans(int x) { return -x - 1; }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n;
  cin >> n;
  long long q;
  cin >> q;
  long long arr[n];
  for (long long i = 0; i < n; i++) cin >> arr[i];
  long long qu[q];
  for (long long i = 0; i < q; i++) cin >> qu[i];
  long long lower[n + 1];
  long long upper[n + 1];
  long long maxim = arr[0], j = 0;
  deque<long long> d;
  for (int i = 0; i < n; ++i) {
    d.push_back(arr[i]);
    if (maxim < arr[i]) {
      maxim = arr[i];
      j = i;
    }
  }
  long long s;
  std::vector<long long> l, u, p;
  for (int i = 1; i <= n; ++i) {
    long long xx = d.front();
    d.pop_front();
    long long yy = d.front();
    d.pop_front();
    l.push_back(xx);
    u.push_back(yy);
    d.push_front(max(xx, yy));
    d.push_back(min(xx, yy));
    if (d.front() == maxim) {
      s = i;
      d.pop_front();
      while (!d.empty()) {
        p.push_back(d.front());
        d.pop_front();
      }
      break;
    }
  }
  for (int i = 0; i < q; ++i) {
    long long qq = qu[i];
    if (qq > s) {
      cout << maxim << " " << p[(qq - s - 1) % (n - 1)] << endl;
    } else {
      cout << l[qq - 1] << " " << u[qq - 1] << endl;
    }
  }
}
