#include <bits/stdc++.h>
using namespace std;
long long n, i, m, a, b, nmaxpoz, nmax, p, c;
deque<long long> v;
pair<long long, long long> q[200005];
int main() {
  cin >> n >> m;
  for (i = 1; i <= n; i++) {
    cin >> a;
    v.push_back(a);
    if (a > nmax) {
      nmax = a;
      nmaxpoz = i;
    }
  }
  for (i = 1; i <= 2 * n; i++) {
    a = v.front();
    v.pop_front();
    b = v.front();
    v.pop_front();
    q[i] = {a, b};
    if (a < b) swap(a, b);
    v.push_back(b);
    v.push_front(a);
  }
  for (i = 1; i <= m; i++) {
    cin >> a;
    if (a <= nmaxpoz)
      cout << q[a].first << ' ' << q[a].second << "\n";
    else
      cout << q[(a - nmaxpoz) % (n - 1) + nmaxpoz].first << " "
           << q[(a - nmaxpoz) % (n - 1) + nmaxpoz].second << '\n';
  }
  return 0;
}
