#include <bits/stdc++.h>
using namespace std;
int n, m;
long long x;
int an[300005][2];
int s[300005];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &s[i]);
  int l = 1, r = n;
  for (int i = 1; i <= n; i++) {
    an[i][0] = s[l];
    an[i][1] = s[l + 1];
    if (s[l] < s[l + 1])
      s[r + 1] = s[l];
    else
      s[r + 1] = s[l + 1], s[l + 1] = s[l];
    l++;
    r++;
  }
  for (int i = 1; i <= m; i++) {
    scanf("%lld", &x);
    if (x <= n)
      printf("%d %d\n", an[x][0], an[x][1]);
    else {
      int tmp = (x - n - 1) % (n - 1) + 1;
      printf("%d %d\n", s[l], s[l + tmp]);
    }
  }
  return 0;
}
