#include <bits/stdc++.h>
using namespace std;
const long long M = 1e9 + 1;
bool f = false;
map<string, int> mp, mp_2;
set<long long> st;
string s, p;
deque<long long> Q, Q_2;
vector<pair<long long, long long> > v, v_2;
long long tt, a, b, sum = 0, n, d = 1000000, m, q, t, c;
void dp() {
  while (t--) {
    long long A = Q.at(0);
    long long B = Q.at(1);
    v.push_back(make_pair(A, B));
    Q.pop_front();
    Q.pop_front();
    if (B >= A) {
      Q.push_front(B);
      Q.push_back(A);
    } else {
      Q.push_front(A);
      Q.push_back(B);
    }
  }
  while (c--) {
    long long A = Q.at(0);
    long long B = Q.at(1);
    v_2.push_back(make_pair(A, B));
    Q.pop_front();
    Q.pop_front();
    if (B >= A) {
      Q.push_front(B);
      Q.push_back(A);
    } else {
      Q.push_front(A);
      Q.push_back(B);
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> a >> q;
  t = a;
  c = a;
  n = a;
  while (a--) {
    cin >> b;
    Q.push_back(b);
  }
  dp();
  while (q--) {
    cin >> m;
    if (n >= m) {
      cout << v[m - 1].first << " " << v[m - 1].second << endl;
    } else {
      m = (m - n) % (n - 1);
      if (m == 0) {
        m = n - 2;
      } else
        m--;
      cout << v_2[m].first << " " << v_2[m].second << endl;
    }
  }
  return 0;
}
