#include <bits/stdc++.h>
using namespace std;
long long int n, q, m;
long long int a[100000];
deque<long long int> b;
long long int maxa[100000];
int main() {
  cin >> n >> q;
  cin >> a[0];
  maxa[0] = a[0];
  b.push_back(a[0]);
  for (long long int i = 1; i < n; ++i) {
    cin >> a[i];
    b.push_back(a[i]);
    maxa[i] = max(a[i], maxa[i - 1]);
  }
  for (long long int i = 1; i < n; ++i) {
    if (b[0] < b[1]) {
      b.push_back(b[0]);
      b.pop_front();
    } else {
      long long int t = b[0];
      b.pop_front();
      b.push_back(b[0]);
      b.pop_front();
      b.push_front(t);
    }
  }
  for (long long int i = 0; i < q; ++i) {
    cin >> m;
    long long int l, r = -1;
    if (m >= n) {
      l = maxa[n - 1];
      r = b[1 + (m - n) % (n - 1)];
    } else {
      l = maxa[m - 1];
      r = a[m];
    }
    cout << l << " " << r << endl;
  }
  return 0;
}
