#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long N = 2e5 + 7;
long long n, q, a[N];
int main() {
  ios::sync_with_stdio(0);
  cin >> n >> q;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long Maxi = 0;
  deque<long long> dq;
  for (int i = 0; i < n; i++) {
    dq.emplace_back(a[i]);
    if (a[i] > a[Maxi]) {
      Maxi = i;
    }
  }
  vector<pair<long long, long long> > v;
  for (int i = 0; i < Maxi; i++) {
    long long A = dq.front();
    dq.pop_front();
    long long B = dq.front();
    dq.pop_front();
    v.emplace_back(make_pair(A, B));
    if (A < B) {
      swap(A, B);
    }
    dq.emplace_front(A);
    dq.emplace_back(B);
  }
  long long arr[n], idx = 0;
  while (!dq.empty()) {
    arr[idx++] = dq.front();
    dq.pop_front();
  }
  for (; q; q--) {
    long long x;
    cin >> x;
    x--;
    if (x < Maxi) {
      cout << v[x].first << " " << v[x].second << "\n";
    } else {
      x -= Maxi;
      x %= (n - 1);
      x++;
      cout << arr[0] << " " << arr[x] << "\n";
    }
  }
}
