#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, q;
  cin >> n >> q;
  deque<long long int> d;
  long long int ma = 0;
  for (long long int i = 0; i < n; i++) {
    long long int x;
    cin >> x;
    d.push_back(x);
    ma = max(ma, x);
  }
  vector<pair<long long int, long long int> > v;
  v.push_back(make_pair(-1, -1));
  while (d.front() != ma && !d.empty()) {
    long long int x = d.front();
    d.pop_front();
    long long int y = d.front();
    d.pop_front();
    v.push_back(make_pair(x, y));
    if (x < y) swap(x, y);
    d.push_front(x);
    d.push_back(y);
  }
  vector<long long int> a;
  auto it = d.begin();
  it++;
  while (it != d.end()) {
    a.push_back(*it);
    it++;
  }
  long long int z = v.size() - 1;
  n--;
  for (long long int i = 0; i < q; i++) {
    long long int m;
    cin >> m;
    if (m <= z)
      cout << v[m].first << " " << v[m].second << endl;
    else {
      long long int c = m - z - 1;
      cout << ma << " " << a[c % n] << endl;
    }
  }
  return 0;
}
