#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, q;
  cin >> n >> q;
  deque<long long int> dq;
  stack<long long int> st;
  long long int p[n];
  for (long long int i = 0; i < n; i++) {
    long long int x;
    cin >> x;
    p[i] = x;
    dq.push_back(x);
    if (st.empty())
      st.push(x);
    else {
      while ((!st.empty()) && (x > st.top())) {
        st.pop();
      }
      if (st.empty()) st.push(x);
    }
  }
  long long int mx = st.top();
  long long int offset = 0;
  for (long long int i = 0; i < n; i++) {
    if (mx == p[i]) {
      offset = i;
      break;
    }
  }
  long long int count = st.size();
  long long int i = 0;
  long long int ct = 0;
  bool first = true;
  map<long long int, pair<long long int, long long int> > mp;
  long long int x = 0;
  while (ct < count && offset != 0) {
    long long int a = dq.front();
    dq.pop_front();
    long long int b = dq.front();
    dq.pop_front();
    mp[x + 1] = {a, b};
    if (a < b) swap(a, b);
    if (a == mx && a == b) {
      ct++;
    } else if (a == mx && a != b && first) {
      ct++;
      first = false;
    }
    dq.push_front(a);
    dq.push_back(b);
    x++;
  }
  long long int a[n - 1];
  dq.pop_front();
  for (long long int i = 0; i < n - 1; i++) {
    a[i] = dq.front();
    dq.pop_front();
  }
  offset += 1;
  while (q--) {
    long long int m;
    cin >> m;
    if (m <= x) {
      cout << mp[m].first << " " << mp[m].second << endl;
    } else {
      m = (m - offset) % (n - 1);
      cout << mx << " " << a[m] << endl;
    }
  }
  return 0;
}
