#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, q, i, j, current, ma;
  cin >> n >> q;
  long long A[n];
  for (i = 0; i < n; i++) cin >> A[i];
  j = distance(A, max_element(A, A + n));
  ma = A[j];
  list<long long> solve;
  list<long long>::iterator itr;
  for (i = 0; i < n; i++) solve.push_back(A[i]);
  long long ans[j + 1][2], a, b;
  for (i = 0; i < j; i++) {
    itr = solve.begin();
    a = *itr;
    solve.pop_front();
    itr = solve.begin();
    b = *itr;
    solve.pop_front();
    solve.push_back(min(a, b));
    solve.push_front(max(a, b));
    ans[i][0] = b;
    ans[i][1] = a;
  }
  i = 0;
  itr = solve.begin();
  itr++;
  for (itr = itr; itr != solve.end(); itr++) {
    A[i] = *itr;
    i++;
  }
  for (i = 0; i < q; i++) {
    cin >> current;
    if (current <= j)
      cout << ans[current - 1][1] << " " << ans[current - 1][0] << endl;
    else {
      current = current - (j + 1);
      current = current % (n - 1);
      cout << ma << " " << A[current] << endl;
    }
  }
}
