#include <bits/stdc++.h>
using namespace std;
int a[100001];
int b[100001];
int main(int argc, char const *argv[]) {
  int n, q;
  scanf("%d %d", &n, &q);
  deque<int> d;
  int mx = -1, value;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &value);
    d.push_back(value);
  }
  mx = *max_element(d.begin(), d.end());
  int sz = 0, A, B;
  while (d[0] != mx) {
    A = d.front();
    d.pop_front();
    B = d.front();
    d.pop_front();
    a[sz] = A;
    b[sz] = B;
    sz++;
    if (A > B)
      d.push_front(A), d.push_back(B);
    else
      d.push_front(B), d.push_back(A);
  }
  long long v;
  while (q--) {
    scanf("%lld", &v);
    if (v <= sz) {
      v--;
      printf("%d %d\n", a[v], b[v]);
    } else {
      v -= sz;
      v %= (n - 1);
      printf("%d %d\n", d[0], v ? d[v] : d[n - 1]);
    }
  }
  return 0;
}
