#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
int main() {
  int n, q;
  cin >> n >> q;
  vector<pair<int, int> > ans;
  deque<int> a;
  int mx = 0;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    a.push_back(x);
    mx = max(x, mx);
  }
  while (a.front() != mx) {
    ans.push_back({a[0], a[1]});
    int h = a[0];
    int j = a[1];
    a.pop_front();
    a.pop_front();
    a.push_front(max(h, j));
    a.push_back(min(h, j));
  }
  ans.push_back({a[0], a[1]});
  for (int i = 0; i < q; ++i) {
    long long m;
    cin >> m;
    m--;
    if (m < ans.size()) {
      cout << ans[m].first << " " << ans[m].second << "\n";
    } else {
      cout << a[0] << " ";
      m -= ans.size() - 1;
      long long j = (m) % (n - 1) + 1;
      cout << a[j] << "\n";
    }
  }
  return 0;
}
