#include <bits/stdc++.h>
using namespace std;
inline void prnt(bool ok) { cout << (ok ? "YES" : "NO"); }
const int ppr = 257;
const long long INF = 2e18;
const int inf = 2e9;
const int mod = 1e9 + 9;
const int N = 1e6 + 123;
const long double pi = 3.141592653589793238462643;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
long long n, a[N], b[N], q, m, mx = -1, pos;
deque<long long> d;
pair<int, int> p[N];
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> q;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
    d.push_back(a[i]);
    mx = max(mx, a[i]);
  }
  for (long long i = 1; i <= n; i++) {
    if (mx == a[i]) {
      pos = i;
      break;
    }
  }
  long long k = 0;
  while (true) {
    if (d.front() == mx) break;
    long long a = d.front();
    d.pop_front();
    long long b = d.front();
    d.pop_front();
    if (a > b)
      d.push_front(a), d.push_back(b);
    else
      d.push_front(b), d.push_back(a);
    p[++k] = make_pair(a, b);
  }
  k = 0;
  while (!d.empty()) {
    b[++k] = d.front();
    d.pop_front();
  }
  pos--;
  while (q--) {
    cin >> m;
    if (m <= pos) {
      cout << p[m].first << ' ' << p[m].second << '\n';
    } else {
      m -= pos;
      m--;
      m %= (n - 1);
      cout << b[1] << ' ' << b[1 + m + 1] << '\n';
    }
  }
  return 0;
}
