#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(0);
  long long n, vq;
  cin >> n >> vq;
  deque<long long> ss;
  long long ma = -1, i = -1;
  for (long long q = 0; q < n; q++) {
    long long v;
    cin >> v;
    ss.push_back(v);
    if (v > ma) {
      ma = v;
      i = q;
    }
  }
  vector<pair<long long, long long>> ot(i);
  for (long long q = 0; q < i; q++) {
    long long g = ss.front();
    ss.pop_front();
    long long g1 = ss.front();
    ss.pop_front();
    ot[q].first = g;
    ot[q].second = g1;
    ss.push_front(max(g, g1));
    ss.push_back(min(g, g1));
  }
  vector<long long> ot1(n - 1);
  for (long long q = 0; q < n - 1; q++) {
    ot1[n - 2 - q] = ss.back();
    ss.pop_back();
  }
  for (long long q = 0; q < vq; q++) {
    long long m;
    cin >> m;
    if (m < i + 1) {
      cout << ot[m - 1].first << " " << ot[m - 1].second << "\n";
    } else {
      m = m - i - 1;
      m = m % (n - 1);
      cout << ma << " " << ot1[m] << "\n";
    }
  }
  return 0;
}
