#include <bits/stdc++.h>
using namespace std;
const int mm = 1000000007;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long n;
  cin >> n;
  long long q;
  cin >> q;
  long long a[n];
  deque<long long> qwe;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    qwe.push_back(a[i]);
  }
  vector<pair<long long, long long>> bn;
  for (long long i = 0; i < n; i++) {
    long long a, b;
    a = qwe.front();
    qwe.pop_front();
    b = qwe.front();
    qwe.pop_front();
    bn.push_back({a, b});
    if (a > b) {
      qwe.push_front(a);
      qwe.push_back(b);
    } else {
      qwe.push_front(b);
      qwe.push_back(a);
    }
  }
  vector<pair<long long, long long>> an;
  for (long long i = 0; i < n; i++) {
    long long a, b;
    a = qwe.front();
    qwe.pop_front();
    b = qwe.front();
    qwe.pop_front();
    an.push_back({a, b});
    if (a > b) {
      qwe.push_front(a);
      qwe.push_back(b);
    } else {
      qwe.push_front(b);
      qwe.push_back(a);
    }
  }
  while (q--) {
    long long x;
    cin >> x;
    if (x <= n) {
      cout << bn[x - 1].first << " " << bn[x - 1].second << "\n";
    } else {
      x -= n;
      x -= 1;
      x %= (n - 1);
      cout << an[x].first << " " << an[x].second << "\n";
    }
  }
  return 0;
}
