#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, q;
  cin >> n >> q;
  deque<int> a;
  vector<pair<int, int>> max_i(n, {0, -1});
  for (int i = 0; i < n; i++) {
    int temp;
    cin >> temp;
    a.push_back(temp);
    if (i == 0) {
      max_i[i] = {temp, temp};
    } else {
      max_i[i] = {temp, max(max_i[i - 1].second, temp)};
    }
  }
  vector<int> modified_a(n);
  modified_a[0] = max_i[n - 1].second;
  for (int i = 1; i < n; i++) {
    modified_a[i] = min(max_i[i - 1].second, max_i[i].first);
  }
  for (int i = 0; i < q; i++) {
    long long x;
    cin >> x;
    if (x < n) {
      cout << max_i[x - 1].second << " ";
      cout << max_i[x].first;
      cout << endl;
    } else {
      cout << modified_a[0] << " ";
      cout << modified_a[x % (n - 1) == 0 ? n - 1 : x % (n - 1)];
      cout << endl;
    }
  }
  return 0;
}
