#include <bits/stdc++.h>
using namespace std;
int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, i1, i2, i, ma = -1, index = -1, q;
  cin >> n >> q;
  vector<long long> a(n + 1), b;
  vector<pair<long long, long long>> ans;
  ans.push_back({0, 0});
  for (i = 1; i <= n; i++) {
    cin >> a[i];
    if (a[i] > ma) ma = a[i], index = i;
  }
  i1 = 1, i2 = 2;
  while (i1 < index && i2 <= index) {
    while (a[i2] <= a[i1] && i2 < index) {
      ans.push_back({a[i1], a[i2]});
      b.push_back(a[i2]);
      i2++;
    }
    if (i2 <= index && a[i2] > a[i1]) {
      ans.push_back({a[i1], a[i2]});
      b.push_back(a[i1]);
      i1 = i2;
      i2++;
    }
  }
  vector<long long> master;
  for (long long i = index; i <= n; i++) master.push_back(a[i]);
  for (long long i = 0; i < b.size(); i++) master.push_back(b[i]);
  for (long long i = 1; i <= q; i++) {
    long long m;
    cin >> m;
    if (m < index)
      cout << ans[m].first << " " << ans[m].second << endl;
    else {
      m = (m - (index)) % (n - 1) + 1;
      cout << master[0] << " " << master[m] << endl;
    }
  }
  return 0;
}
