#include <bits/stdc++.h>
using namespace std;
deque<int> dq;
int a[100005], b[100005];
int main() {
  int n, q, p;
  scanf("%d %d", &n, &q);
  for (int i = 1; i <= n; i++) scanf("%d", &p), dq.push_back(p);
  for (int i = 1; i <= n; i++) {
    int x = dq.front();
    dq.pop_front();
    int y = dq.front();
    dq.pop_front();
    a[i] = x, b[i] = y;
    if (x > y) swap(x, y);
    dq.push_back(x);
    dq.push_front(y);
  }
  for (int i = 1; i <= q; i++) {
    long long int x;
    scanf("%lld", &x);
    if (x <= n)
      printf("%d %d\n", a[x], b[x]);
    else {
      long long int Rem = x - n - 1;
      int xx = dq.front();
      int yy = dq[(Rem) % (n - 1) + 1];
      printf("%d %d\n", xx, yy);
    }
  }
}
