#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
vector<int> v[200005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, q, a, b, x;
  cin >> n >> q;
  deque<int> dq;
  for (int i = 1; i <= n; i++) {
    cin >> a;
    dq.push_back(a);
  }
  for (int i = 1; i <= n * 2; i++) {
    a = dq.front();
    dq.pop_front();
    b = dq.front();
    dq.pop_front();
    v[i].push_back(a);
    v[i].push_back(b);
    if (a > b) {
      dq.push_front(a);
      dq.push_back(b);
    } else {
      dq.push_front(b);
      dq.push_back(a);
    }
  }
  long long m;
  while (q--) {
    cin >> m;
    if (m > 2 * n) {
      x = (m % (n - 1)) + (n - 1);
    } else {
      x = m;
    }
    cout << v[x][0] << " " << v[x][1] << endl;
  }
  return 0;
}
