#include <bits/stdc++.h>
using namespace std;
const long long N = 800000;
long long a[N], ans[N][2];
int main() {
  ios_base::sync_with_stdio(false);
  long long n, q, i, l, r, k1, k2, k = -1e9, x = 0, y, z;
  cin >> n >> q;
  for (i = 0; i < n; i++) {
    cin >> a[i];
    k = max(k, a[i]);
  }
  l = 0;
  r = n - 1;
  while (1) {
    k1 = a[l];
    k2 = a[l + 1];
    ans[x][0] = k1;
    ans[x][1] = k2;
    x++;
    if (k1 > k2) {
      l++;
      a[l] = k1;
      r++;
      a[r] = k2;
    } else {
      l++;
      a[l] = k2;
      r++;
      a[r] = k1;
    }
    if (max(k1, k2) == k) break;
  }
  k1 = a[l];
  k2 = a[l + 1];
  ans[x][0] = k1;
  ans[x][1] = k2;
  x++;
  while (q--) {
    cin >> y;
    if ((y - 1) < x)
      cout << ans[y - 1][0] << " " << ans[y - 1][1] << endl;
    else {
      y = y - (x - 1);
      z = r - l;
      if (y % z == 0)
        y = r;
      else
        y = y % z + l;
      cout << k << " " << a[y] << endl;
    }
  }
  return 0;
}
