#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 5e5 + 5;
int main() {
  ios ::sync_with_stdio(0), cin.tie(0);
  int n, q;
  cin >> n >> q;
  deque<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  int mx = *max_element(a.begin(), a.end());
  vector<pair<int, int> > Q;
  while (a[0] != mx) {
    int A = a.front();
    a.pop_front();
    int B = a.front();
    a.pop_front();
    Q.push_back({A, B});
    if (A < B) swap(A, B);
    a.push_front(A);
    a.push_back(B);
  }
  while (q--) {
    ll m;
    cin >> m;
    --m;
    if (m < Q.size()) {
      cout << Q[m].first << ' ' << Q[m].second << '\n';
      continue;
    }
    m -= Q.size();
    m %= (n - 1);
    ++m;
    cout << a[0] << ' ' << a[m] << '\n';
  }
  return 0;
}
