#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, q;
  cin >> n >> q;
  vector<int> V(n);
  for (int i = 0; i < n; ++i) cin >> V[i];
  vector<pair<int, int> > A, B;
  for (int i = 1; i <= n; ++i) {
    A.push_back({V[0], V[i]});
    if (V[0] < V[i]) swap(V[0], V[i]);
    V.push_back(V[i]);
  }
  for (int i = n; i < 2 * n; ++i) B.push_back({V[0], V[i]});
  for (int i = 0; i < q; ++i) {
    long long m;
    cin >> m;
    m--;
    if (m < n)
      cout << A[m].first << " " << A[m].second << "\n";
    else
      cout << B[m % (n - 1)].first << " " << B[m % (n - 1)].second << "\n";
  }
  return 0;
}
