#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
deque<long long> dq;
long long ans[N][2];
long long l[N];
int main() {
  long long n, q;
  cin >> n >> q;
  for (int i = 0; i < n; i++) {
    long long g;
    cin >> g;
    dq.push_back(g);
  }
  ans[1][0] = dq.front();
  dq.pop_front();
  ans[1][1] = dq.front();
  dq.push_front(ans[1][0]);
  for (int i = 2; i <= n; i++) {
    long long a, b;
    a = dq.front();
    dq.pop_front();
    b = dq.front();
    dq.pop_front();
    if (a > b) {
      dq.push_front(a);
      dq.push_back(b);
    } else {
      dq.push_front(b);
      dq.push_back(a);
    }
    ans[i][0] = dq.front();
    dq.pop_front();
    ans[i][1] = dq.front();
    dq.push_front(ans[i][0]);
  }
  for (int i = 0; i < n; i++) {
    l[i] = dq.front();
    dq.pop_front();
  }
  for (int i = 0; i < q; i++) {
    long long num;
    cin >> num;
    if (num <= n) {
      cout << ans[num][0] << " " << ans[num][1] << endl;
      continue;
    }
    num = (num - n) % (n - 1);
    cout << l[0] << " " << l[1 + num] << endl;
  }
}
