#include <bits/stdc++.h>
using namespace std;
int n, j, q, A[200005], t = -1, p;
pair<long long, int> B[300005], o[300005];
long long tt;
int main() {
  cin >> n >> q;
  for (int i = 1; i <= n; i++) {
    cin >> A[i];
    if (A[i] > t) t = A[i], p = i;
  }
  for (int i = 1; i <= q; i++) {
    cin >> tt;
    B[i] = make_pair(tt, i);
  }
  sort(B + 1, B + q + 1);
  j = 1;
  for (int i = 1; i <= p - 1; i++) {
    while (i == B[j].first && j <= q)
      o[B[j].second] = make_pair(A[i], A[i + 1]), j++;
    if (j > q) break;
    if (A[i] > A[i + 1]) swap(A[i], A[i + 1]);
    A[i + n] = A[i];
  }
  for (; j <= q; j++) {
    int pos = (B[j].first - p) % (n - 1) + p + 1;
    o[B[j].second] = make_pair(A[p], A[pos]);
  }
  for (int i = 1; i <= q; i++) cout << o[i].first << " " << o[i].second << endl;
}
