#include <bits/stdc++.h>
using namespace std;
const long long maxn = 500005;
const long long mod = 1e9 + 7;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n, q, i, j, k;
  cin >> n >> q;
  deque<int> dq;
  long long mx = -1, ind;
  for (i = 0; i < n; i++) {
    cin >> k;
    dq.push_back(k);
    if (k > mx) {
      mx = k;
      ind = i;
    }
  }
  long long op = 1;
  map<long long, pair<int, int>> m;
  while (dq.front() != mx) {
    int f = dq.front();
    dq.pop_front();
    int s = dq.front();
    dq.pop_front();
    if (f > s) {
      dq.push_front(f);
      dq.push_back(s);
    } else {
      dq.push_front(s);
      dq.push_back(f);
    }
    m[op] = {f, s};
    ++op;
  }
  vector<int> a(n);
  for (i = 0; i < n; i++) {
    int v = dq.front();
    dq.pop_front();
    a[i] = v;
  }
  while (q--) {
    cin >> ind;
    if (ind <= m.size()) {
      cout << m[ind].first << " " << m[ind].second << "\n";
    } else {
      cout << mx << " " << a[(ind - (long long)m.size() - 1LL) % (n - 1) + 1LL]
           << "\n";
    }
  }
}
