#include <bits/stdc++.h>
using namespace std;
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.second < b.second);
}
int main() {
  int n, q;
  cin >> n >> q;
  vector<long long> a(n);
  long long max = -1;
  int loc;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] > max) {
      max = a[i];
      loc = i;
    }
  }
  vector<pair<long long, long long>> re;
  vector<long long> cur = a;
  re.push_back({cur[0], cur[1]});
  for (int i = 1; i <= loc; i++) {
    if (cur[0] < cur[1]) {
      long long r = cur[0];
      cur.erase(cur.begin());
      cur.push_back(r);
    } else {
      long long r = cur[1];
      cur.erase(cur.begin() + 1);
      cur.push_back(r);
    }
    re.push_back({cur[0], cur[1]});
  }
  while (q--) {
    long long m;
    cin >> m;
    if (m < loc + 1) {
      cout << re[m - 1].first << " " << re[m - 1].second << endl;
    } else {
      m -= loc;
      cout << re[loc].first << " ";
      int r = m % (n - 1);
      if (r == 0)
        cout << cur[n - 1] << endl;
      else
        cout << cur[r] << endl;
    }
  }
  return 0;
}
