#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
using ll = long long;
using db = long double;
const int N = 1 << 17, MOD = 1e9 + 7;
deque<int> dq;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, q;
  cin >> n >> q;
  dq.resize(n);
  int mx = 0;
  for (auto& x : dq) {
    cin >> x;
    mx = max(mx, x);
  }
  int offset = 0;
  vector<pair<int, int>> vp;
  while (dq.front() != mx) {
    auto x = dq.front();
    dq.pop_front();
    auto y = dq.front();
    dq.pop_front();
    vp.push_back({x, y});
    if (x > y) {
      dq.push_front(x);
      dq.push_back(y);
    } else {
      dq.push_front(y);
      dq.push_back(x);
    }
    offset++;
  }
  for (int i = 0; i < q; i++) {
    ll m;
    cin >> m;
    m--;
    if (m >= offset) {
      m -= offset;
      cout << mx << ' ' << dq[m % (n - 1) + 1] << '\n';
    } else {
      cout << vp[m].first << ' ' << vp[m].second << '\n';
    }
  }
  return 0;
}
