#include <bits/stdc++.h>
using namespace std;
template <class T1, class T2>
ostream& operator<<(ostream& out, pair<T1, T2> p) {
  out << '(' << p.first << ',' << p.second << ')';
  return out;
}
template <class T1, class T2>
istream& operator>>(istream& in, pair<T1, T2>& p) {
  in >> p.first >> p.second;
  return in;
}
template <class T>
istream& operator>>(istream& in, vector<T>& v) {
  for (auto& x : v) in >> x;
  return in;
}
template <class T>
ostream& operator<<(ostream& out, vector<vector<T>>& v) {
  for (auto& x : v) out << x << '\n';
  return out;
}
template <class T>
ostream& operator<<(ostream& out, vector<T>& v) {
  for (auto x : v) out << x << ' ';
  return out;
}
long long gcd(long long a, long long b) {
  if (b > a) swap(a, b);
  return (b ? gcd(b, a % b) : a);
}
const long double pi = 2 * asin(1);
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cerr.setstate(ios::failbit);
  int n, q;
  cin >> n >> q;
  vector<long long> v(n);
  cin >> v;
  long long i = 0;
  int mx = *max_element(v.begin(), v.end());
  map<long long, pair<int, int>> m;
  while (1) {
    if (v[i] == mx) break;
    m[i + 1] = make_pair(v[i], v[i + 1]);
    if (v[i] > v[i + 1]) swap(v[i], v[i + 1]);
    v.push_back(v[i]);
    i++;
  }
  cerr << v << ' ' << i << '\n';
  while (q--) {
    long long x;
    cin >> x;
    if (m.count(x))
      cout << m[x].first << ' ' << m[x].second << '\n';
    else {
      x -= i + 1;
      cout << v[i] << ' ' << v[x % (n - 1) + i + 1] << '\n';
    }
  }
}
