#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
const long long LL_INF = 0x3f3f3f3f3f3f3f3f;
template <typename T>
T gcd(T a, T b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
long long power(long long a, long long b, long long m = 1000000007) {
  long long answer = 1;
  while (b) {
    if (b & 1) answer = (answer * a) % m;
    b /= 2;
    a = (a * a) % m;
  }
  return answer;
}
using namespace std;
void ctrl() { cout << "Control\n"; }
signed main() {
  long long n, query;
  cin >> n >> query;
  deque<long long> q;
  long long mx = 0;
  for (register long long i = 0; i < n; i += 1) {
    long long x;
    cin >> x;
    q.push_back(x);
    mx = max(mx, x);
  }
  long long k = 1;
  vector<pair<long long, long long> > ans;
  while (q.front() != mx) {
    long long x = q.front();
    q.pop_front();
    long long y = q.front();
    q.pop_front();
    ans.push_back(make_pair(x, y));
    if (x < y) {
      swap(x, y);
    }
    q.push_back(y);
    q.push_front(x);
  }
  long long A[n + 1];
  long long i = 0;
  long long tx = q.front();
  q.pop_front();
  while (!q.empty()) {
    long long x = q.front();
    A[i++] = x;
    q.pop_front();
  }
  for (long long i = 0; i < query; i++) {
    long long x;
    cin >> x;
    if (x <= ans.size()) {
      cout << ans[x - 1].first << " " << ans[x - 1].second << endl;
    } else {
      x = x - (long long)(ans.size()) - 1;
      x = x % (n - 1);
      if (x < 0) x += (n - 1);
      cout << tx << " " << A[x] << endl;
    }
  }
  return 0;
}
