#include <bits/stdc++.h>
using namespace std;
template <class T>
ostream& operator<<(ostream& os, vector<T> V) {
  os << "[ ";
  for (auto v : V) os << v << " ";
  return os << "]";
}
template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> P) {
  return os << "(" << P.first << "," << P.second << ")";
}
const long long Mod = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, q, x, id;
  cin >> n >> q;
  deque<long long> Q;
  for (int i = 0; i < n; i++) {
    cin >> x;
    Q.push_back(x);
  }
  map<int, pair<long long, long long> > M;
  for (int i = 1; i <= n; i++) {
    long long a = Q.front();
    Q.pop_front();
    long long b = Q.front();
    Q.pop_front();
    M[i] = make_pair((a), (b));
    if (a < b) swap(a, b);
    Q.push_front(a);
    Q.push_back(b);
  }
  vector<long long> v;
  for (int i = 0; i < n; i++) {
    v.push_back(Q.front());
    Q.pop_front();
  }
  while (q--) {
    cin >> id;
    if (id <= n)
      cout << M[id].first << " " << M[id].second << endl;
    else {
      id -= n;
      id %= (n - 1);
      if (id == 0) id = n - 1;
      cout << v[0] << " " << v[id] << endl;
    }
  }
  return 0;
}
