#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5;
const long long mod = 1e9 + 7;
int a[maxn + 1];
int ans1[maxn + 1];
int ans2[maxn + 1];
int main() {
  int i, j, n, q, x, y, maxv = 0;
  scanf("%d %d", &n, &q);
  deque<int> dq;
  for (i = 1; i <= n; ++i) {
    scanf("%d", &x);
    maxv = max(maxv, x);
    dq.push_back(x);
  }
  x = dq.front();
  dq.pop_front();
  y = dq.front();
  dq.pop_front();
  int k = 1;
  while (x != maxv and y != maxv) {
    ans1[k] = x;
    ans2[k] = y;
    if (x > y) {
      dq.push_back(y);
      dq.push_front(x);
    } else {
      dq.push_back(x);
      dq.push_front(y);
    }
    k++;
    x = dq.front();
    dq.pop_front();
    y = dq.front();
    dq.pop_front();
  }
  ans1[k] = x;
  ans2[k] = y;
  if (x > y) {
    dq.push_back(y);
    dq.push_front(x);
  } else {
    dq.push_back(x);
    dq.push_front(y);
  }
  for (i = 1; i <= n; ++i) {
    a[i] = dq.front();
    dq.pop_front();
  }
  while (q--) {
    long long m;
    scanf("%lld", &m);
    if (m <= k) {
      printf("%d %d\n", ans1[m], ans2[m]);
    } else {
      m -= k;
      m %= (n - 1);
      if (m)
        printf("%d %d\n", a[1], a[m + 1]);
      else
        printf("%d %d\n", a[1], a[n]);
    }
  }
  return 0;
}
