#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
int mod = 1e9 + 7;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long powmod(long long a, long long b) {
  long long res = 1;
  if (a >= mod) a %= mod;
  for (; b; b >>= 1) {
    if (b & 1) res = res * a;
    if (res >= mod) res %= mod;
    a = a * a;
    if (a >= mod) a %= mod;
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  int a[300005];
  int res[300005];
  pair<int, int> ans[300005];
  int n, q;
  cin >> n >> q;
  int TOP = -1, idx = -1;
  for (long long i = (long long)(1); i < (long long)(n + 1); i++) cin >> a[i];
  for (long long i = (long long)(1); i < (long long)(n + 1); i++) {
    if (a[i] > TOP) {
      TOP = a[i];
      idx = i;
    }
  }
  long long z = n;
  for (long long i = (long long)(2); i < (long long)(idx + 1); i++) {
    ans[i - 1] = make_pair(a[1], a[i]);
    if (a[1] > a[i]) {
      a[++z] = a[i];
    } else {
      swap(a[1], a[i]);
      a[++z] = a[i];
    }
  }
  a[idx] = TOP;
  int j = 0;
  for (long long i = (long long)(idx); i < (long long)(z + 1); i++)
    res[++j] = a[i];
  while (q--) {
    long long x;
    cin >> x;
    if (x >= idx) {
      x -= (idx - 1);
      x %= (n - 1);
      cout << TOP << " ";
      if (x == 0)
        cout << res[n] << '\n';
      else
        cout << res[x + 1] << '\n';
    } else {
      cout << ans[x].first << " " << ans[x].second << '\n';
    }
  }
  return 0;
}
