#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, q, num;
  cin >> n >> q;
  vector<int> a(n), b(n), c(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  b[0] = a[0];
  for (int i = 1; i < n; ++i) {
    b[i] = max(a[i], b[i - 1]);
    if (b[i] == a[i])
      c[i - 1] = b[i - 1];
    else
      c[i - 1] = a[i];
  }
  while (q--) {
    cin >> num;
    if (num < n)
      cout << b[num - 1] << " " << a[num] << endl;
    else
      cout << b[n - 1] << " " << c[(num - 1) % (n - 1)] << endl;
  }
}
