#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  long long int n, q;
  cin >> n >> q;
  vector<long long int> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  vector<pair<long long int, long long int>> q1(n);
  vector<pair<long long int, long long int>> q2(n);
  q1[1] = {v[0], v[1]};
  int k = 2;
  for (int i = 2; i < n; i++) {
    q1[k++] = {max(q1[k - 1].first, q1[k - 1].second), v[i]};
  }
  int p = max(q1[k - 1].first, q1[k - 1].second);
  for (int i = 1; i < n; i++) {
    q2[i] = {p, min(q1[i].first, q1[i].second)};
  }
  for (int i = 0; i < q; i++) {
    long long int d;
    cin >> d;
    if (d < n)
      cout << q1[d].first << " " << q1[d].second << endl;
    else {
      d %= (n - 1);
      if (d == 0) d = n - 1;
      cout << q2[d].first << " " << q2[d].second << endl;
    }
  }
}
