#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using PP = pair<ll, P>;
const ll n_ = 3e5 + 100, inf = 1e18, mod = 1e9 + 7, sqrtN = 333, p = 11;
ll n, m, tc = 1, idx = 1, a, b, c;
P A[n_];
void solve() {
  cin >> n >> m;
  list<ll> dq;
  vector<ll> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    dq.push_back(v[i]);
  }
  sort(v.begin(), v.end());
  ll x = v[n - 1], y = -1;
  for (int i = 0; i <= 2 * n; i++) {
    a = dq.front();
    dq.pop_front();
    b = dq.front();
    dq.pop_front();
    if (a == x && y < 0) y = i;
    A[i] = {a, b};
    if (a > b) {
      dq.push_front(a);
      dq.push_back(b);
    } else {
      swap(a, b);
      dq.push_front(a);
      dq.push_back(b);
    }
  }
  while (m--) {
    cin >> a;
    a--;
    if (a <= y)
      cout << A[a].first << ' ' << A[a].second << '\n';
    else {
      a -= y;
      a %= (n - 1);
      cout << A[a + y].first << ' ' << A[a + y].second << '\n';
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  while (tc--) solve();
}
