#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  deque<int> ar;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    ar.push_back(a);
  }
  int maxi = -1;
  for (int i = 0; i < n; i++)
    if (ar[i] > maxi) maxi = ar[i];
  int cont = 0;
  vector<pair<int, int> > matriz;
  while (ar[0] != maxi) {
    int a = ar.front();
    ar.pop_front();
    int b = ar.front();
    ar.pop_front();
    matriz.push_back({a, b});
    cont += 1;
    if (a >= b) {
      ar.push_front(a);
      ar.push_back(b);
    } else {
      ar.push_front(b);
      ar.push_back(a);
    }
  }
  for (int i = 0; i < k; i++) {
    long long query;
    cin >> query;
    if (query > cont) {
      if ((query - cont) % (n - 1) == 0)
        cout << maxi << " " << ar[n - 1] << endl;
      else {
        cout << maxi << " " << ar[(query - cont) % (n - 1)] << endl;
      }
    } else {
      if (query == 0) continue;
      cout << matriz[query - 1].first << " " << matriz[query - 1].second
           << endl;
    }
  }
  return 0;
}
