#include <bits/stdc++.h>
using namespace std;
const int inf_int = 1e8 + 100;
const long long inf_ll = 1e18;
const double pi = 3.1415926535898;
bool debug = 0;
const int MAXN = 4e5 + 100;
const int LOG = 25;
const int mod = 1e9 + 7;
const int MX = 5e5 + 100;
const long long MOD = 1000000000949747713ll;
int a[MAXN];
int b[MAXN];
pair<int, int> ans[MAXN];
void solve() {
  int n, q;
  cin >> n >> q;
  int mx = 0;
  deque<int> qq;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    mx = max(mx, a[i]);
    qq.push_back(a[i]);
  }
  int step = 0;
  while (true) {
    step++;
    if (qq.front() == mx) {
      break;
    }
    int a = qq.front();
    qq.pop_front();
    int b = qq.front();
    qq.pop_front();
    qq.push_front(max(a, b));
    qq.push_back(min(a, b));
    ans[step] = {a, b};
  }
  for (int i = 0; i < n; ++i) {
    b[i] = qq.front();
    qq.pop_front();
  }
  for (int i = 0; i < n; ++i) {
    if (debug) cout << b[i] << " ";
  }
  if (debug) cout << endl;
  while (q--) {
    long long x;
    cin >> x;
    if (x < step) {
      cout << ans[x].first << " " << ans[x].second << "\n";
    } else {
      cout << mx << " " << b[(x - step) % (n - 1) + 1] << endl;
    }
  }
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout.setf(ios::fixed);
  cout.precision(20);
  int t = 1;
  while (t--) solve();
  if (debug)
    cerr << endl << "time : " << (1.0 * clock() / CLOCKS_PER_SEC) << endl;
}
