#include <bits/stdc++.h>
using namespace std;
long long a[200005], b[200005], ans[200005][2];
int main() {
  long long n, m, Max = 0;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    Max = max(Max, a[i]);
  }
  for (int i = 1; i < n; i++) {
    ans[i][0] = a[i];
    ans[i][1] = a[i + 1];
    if (a[i] > a[i + 1]) swap(a[i], a[i + 1]);
    b[i] = a[i];
  }
  while (m--) {
    long long x;
    scanf("%lld", &x);
    if (x < n)
      printf("%lld %lld\n", ans[x][0], ans[x][1]);
    else
      printf("%lld %lld\n", Max, b[x % (n - 1) == 0 ? n - 1 : x % (n - 1)]);
  }
  return 0;
}
