#include <bits/stdc++.h>
using namespace std;
inline char gc() { return getchar(); }
template <class T>
int read(T &ans) {
  ans = 0;
  char ch = gc();
  T f = 1;
  while (!isdigit(ch)) {
    if (ch == EOF) return -1;
    if (ch == '-') f = -1;
    ch = gc();
  }
  while (isdigit(ch)) ans = ans * 10 + ch - '0', ch = gc();
  ans *= f;
  return 1;
}
template <class T1, class T2>
int read(T1 &a, T2 &b) {
  return read(a) != EOF && read(b) != EOF ? 2 : EOF;
}
template <class T1, class T2, class T3>
int read(T1 &a, T2 &b, T3 &c) {
  return read(a, b) != EOF && read(c) != EOF ? 3 : EOF;
}
const int Maxn = 1100000;
const int inf = 0x3f3f3f3f;
int n, t, a[Maxn], c[Maxn];
long long x;
pair<int, int> b[Maxn];
signed main() {
  read(n, t);
  for (int i = 1; i <= n; i++) read(a[i]);
  deque<int> q;
  for (int i = 1; i <= n; i++) q.push_back(a[i]);
  for (int i = 1; i < n; i++) {
    int x = q.front();
    q.pop_front();
    int y = q.front();
    q.pop_front();
    b[i] = make_pair(x, y);
    if (x < y) swap(x, y);
    q.push_front(x);
    q.push_back(y);
  }
  int mx = q.front();
  q.pop_front();
  for (int i = 1; i < n; i++) c[i] = q.front(), q.pop_front();
  while (t--) {
    read(x);
    if (x < n)
      printf("%d %d\n", b[x].first, b[x].second);
    else {
      x -= n;
      printf("%d %d\n", mx, c[x % (n - 1) + 1]);
    }
  }
  return 0;
}
