#include <bits/stdc++.h>
using namespace std;
long long n, q, a[500010], m, pos, ans;
struct arr {
  long long a, b;
} b[500010];
signed main() {
  scanf("%I64d%I64d", &n, &q);
  for (long long i = 1; i <= n; i++) scanf("%I64d", &a[i]);
  ans = a[1];
  for (long long i = 1; i <= n; i++) ans = max(ans, a[i]);
  long long l = 0;
  long long r = n;
  m = 0;
  pos = -1;
  long long sum = 0;
  while (true) {
    m++;
    l++;
    b[m].a = a[l];
    b[m].b = a[l + 1];
    if (b[m].a == ans && pos == -1) pos = m;
    if (b[m].a == ans) sum++;
    if (sum == n - 1) break;
    long long t;
    if (a[l] > a[l + 1]) {
      t = a[l + 1];
      a[l + 1] = a[l];
      a[++r] = t;
    } else {
      a[++r] = a[l];
    }
  }
  for (long long i = 1; i <= q; i++) {
    long long k;
    scanf("%I64d", &k);
    if (k < pos)
      printf("%I64d %I64d\n", b[k].a, b[k].b);
    else {
      k = (k - pos + 1) % (n - 1);
      if (k == 0) k = n - 1;
      k = k + pos - 1;
      printf("%I64d %I64d\n", b[k].a, b[k].b);
    }
  }
  return 0;
}
