#include <bits/stdc++.h>
using namespace std;
void read() {
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
}
int n, k;
deque<int> dq;
vector<long long> q;
vector<pair<int, int> > t;
void solve() {
  int maxx = -1;
  for (int i = 0; i < n; i++) {
    maxx = max(maxx, dq[i]);
  }
  int c = 0;
  while (1) {
    if (dq.front() == maxx) break;
    t.push_back(make_pair(dq[0], dq[1]));
    c++;
    int a = dq.front();
    dq.pop_front();
    int b = dq.front();
    dq.pop_front();
    if (a > b) {
      dq.push_back(b);
      dq.push_front(a);
    } else {
      dq.push_back(a);
      dq.push_front(b);
    }
  }
  for (int i = 0; i < k; i++) {
    if (q[i] <= c) {
      cout << t[q[i] - 1].first << " " << t[q[i] - 1].second << "\n";
    } else {
      long long t1 = (q[i] - c) % (n - 1);
      if (t1 == 0) t1 = n - 1;
      cout << dq[0] << " " << dq[t1] << "\n";
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    dq.push_back(a);
  }
  for (int i = 0; i < k; i++) {
    long long a;
    cin >> a;
    q.push_back(a);
  }
  solve();
  return 0;
}
