#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
void solve() {
  int n, x, q;
  cin >> n >> q;
  deque<int> Dq;
  for (int i = 0; i < n; ++i) {
    cin >> x;
    Dq.push_back(x);
  }
  vector<pair<int, int>> Answer;
  int start1, end1;
  Answer.push_back({0, 0});
  for (int i = 0; i < n; ++i) {
    auto a = Dq.front();
    Dq.pop_front();
    auto b = Dq.front();
    Dq.pop_front();
    Answer.push_back({a, b});
    Dq.push_front(max(a, b));
    Dq.push_back(min(a, b));
  }
  int maxi = Dq.front();
  Dq.pop_front();
  while (q--) {
    long long x;
    cin >> x;
    if (x <= (Answer.size() - 1))
      cout << Answer[x].first << ' ' << Answer[x].second << '\n';
    else {
      x -= Answer.size() - 1;
      ;
      x %= (n - 1);
      ;
      x = x - 1;
      x += n - 1;
      x %= (n - 1);
      cout << maxi << ' ' << Dq[x] << '\n';
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int t = 1;
  while (t--) solve();
  return 0;
}
