#include <bits/stdc++.h>
using namespace std;
long long a[205000] = {0}, b[205000] = {0};
long long zuida[205000] = {0};
long long ci, maxx = -12345;
int ask, n;
int h, t;
int main() {
  int bj;
  cin >> n >> ask;
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    b[i] = a[i];
    if (a[i] > maxx) {
      maxx = a[i];
      bj = i;
    }
  }
  zuida[1] = a[1];
  for (int i = 2; i <= n; i++) {
    if (a[i] > zuida[i - 1]) {
      zuida[i] = a[i];
    } else
      zuida[i] = zuida[i - 1];
  }
  h = 1, t = n + 1;
  long long pd;
  pd = bj - 2 + 1;
  for (int i = 1; i <= pd; i++) {
    if (b[h] > b[h + 1]) {
      b[t] = b[h + 1];
      b[h + 1] = b[h];
      h++;
      t++;
    } else {
      b[t] = b[h];
      h++;
      t++;
    }
  }
  if (ask == 0) {
    return 0;
  }
  for (int i = 1; i <= ask; i++) {
    scanf("%lld", &ci);
    if (ci == 0) {
      cout << 0 << " " << 0 << endl;
      continue;
    }
    if (ci <= pd) {
      printf("%lld %lld\n", zuida[ci], a[ci + 1]);
    } else {
      long long yu = (ci - pd) % (n - 1);
      if (yu == 0)
        printf("%lld %lld\n", maxx, b[bj + n - 1]);
      else
        printf("%lld %lld\n", maxx, b[bj + yu]);
    }
  }
  return 0;
}
