#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 7;
pair<int, int> od[maxn];
int n, q;
long long tmp;
deque<int> a;
int main() {
  scanf("%d%d", &n, &q);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &tmp);
    a.push_back(tmp);
  }
  for (int i = 1; i < n; i++) {
    int aa = a[0], bb = a[1];
    od[i].first = aa, od[i].second = bb;
    a.pop_front(), a.pop_front();
    if (aa > bb)
      a.push_front(aa), a.push_back(bb);
    else
      a.push_front(bb), a.push_back(aa);
  }
  while (q--) {
    scanf("%lld", &tmp);
    if (tmp < n)
      printf("%d %d\n", od[tmp].first, od[tmp].second);
    else
      printf("%d %d\n", a.front(),
             a[tmp % (n - 1) == 0 ? n - 1 : tmp % (n - 1)]);
  }
  return 0;
}
