#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
const int maxn = 1e5 + 5;
int n, q, a[maxn * 2], ans[maxn][2];
int main() {
  scanf("%d %d", &n, &q);
  int mx = -1;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
    mx = max(mx, a[i]);
  }
  int l = 0, cnt = 1, len = n;
  for (; l < n && a[l] != mx; ++l, ++cnt) {
    ans[cnt][0] = a[l];
    ans[cnt][1] = a[l + 1];
    a[len++] = min(a[l], a[l + 1]);
    a[l + 1] = max(a[l], a[l + 1]);
  }
  for (int i = 0; i < q; ++i) {
    ll x;
    scanf("%lld", &x);
    if (x < cnt) {
      printf("%d %d\n", ans[x][0], ans[x][1]);
    } else {
      x -= cnt;
      int re = x % (n - 1) + 1;
      printf("%d %d\n", a[l], a[l + re]);
    }
  }
}
