#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, k, x;
  cin >> n >> k;
  vector<long long 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 (k--) {
    cin >> x;
    if (x < n) {
      cout << b[x - 1] << " " << a[x] << endl;
    } else {
      cout << b[n - 1] << " " << c[(x - 1) % (n - 1)] << endl;
    }
  }
}
