#include <bits/stdc++.h>
using namespace std;
void doRoutine() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  srand(322179);
}
signed main() {
  doRoutine();
  int n, q;
  cin >> n >> q;
  vector<int> a(n * 2 + 5);
  int mx = -1, mx_ptr = -1;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    if (a[i] > mx) {
      mx = a[i];
      mx_ptr = i;
    }
  }
  int start = 0;
  vector<pair<int, int> > ans(mx_ptr);
  for (int iter = 0; iter < mx_ptr; ++iter) {
    int v1 = a[start], v2 = a[start + 1];
    ans[iter] = {v1, v2};
    if (v1 > v2) {
      a[start + n] = v2;
      a[start + 1] = v1;
      ++start;
    } else {
      a[start + n] = v1;
      ++start;
    }
  }
  for (int i = 0; i < q; ++i) {
    long long id;
    cin >> id;
    --id;
    if (id < mx_ptr) {
      cout << ans[id].first << " " << ans[id].second << endl;
    } else {
      long long cnt = id - mx_ptr;
      cout << a[start + 0] << " " << a[start + cnt % (n - 1) + 1] << endl;
    }
  }
  return 0;
}
