#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 5;
const long long INF = 1e9;
const long long mod = 1e9 + 7;
long long n, q, arr[N], maxi, letak;
deque<long long> dq;
vector<long long> vec;
vector<pair<long long, long long> > v;
void f() {
  long long a = dq.front();
  dq.pop_front();
  long long b = dq.front();
  dq.pop_front();
  dq.push_front(max(a, b));
  dq.push_back(min(a, b));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> q;
  for (long long i = 1; i <= n; i++) {
    cin >> arr[i];
    dq.push_back(arr[i]);
    if (arr[i] > maxi) {
      maxi = arr[i];
      letak = i;
    }
  }
  for (long long i = 1; i < letak; i++) {
    long long a = dq.front();
    dq.pop_front();
    v.push_back({a, dq.front()});
    dq.push_front(a);
    f();
  }
  for (long long i = 1; i <= n; i++) {
    if (i != 1) vec.push_back(dq.front());
    dq.pop_front();
  }
  while (q--) {
    long long x;
    cin >> x;
    if (x < letak)
      cout << v[x - 1].first << " " << v[x - 1].second << endl;
    else {
      long long kode = (x - (letak - 1)) % (n - 1);
      cout << maxi << " " << vec[(kode - 1 == -1) ? n - 2 : kode - 1] << endl;
    }
  }
}
