#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
using ll = long long;
using ull = unsigned long long;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, q;
  cin >> n >> q;
  vector<int> arr(n);
  for (int i = 0; i < n; ++i) cin >> arr[i];
  const ll maxPos = max_element(arr.begin(), arr.end()) - arr.begin();
  vector<vector<int>> res(n);
  deque<int> tarr(arr.begin(), arr.end());
  for (int i = 0; i < maxPos; ++i) {
    int A = tarr[0];
    int B = tarr[1];
    res[i].push_back(A);
    res[i].push_back(B);
    tarr.pop_front();
    tarr.pop_front();
    if (A > B) {
      tarr.push_front(A);
      tarr.push_back(B);
    } else {
      tarr.push_front(B);
      tarr.push_back(A);
    }
  }
  tarr.pop_front();
  vector<vector<int>> ans(q);
  for (int test = 0; test < q; ++test) {
    ll m;
    cin >> m;
    if (m <= maxPos)
      ans[test] = res[m - 1];
    else {
      ans[test].push_back(arr[maxPos]);
      ans[test].push_back(tarr[(m - maxPos - 1) % (n - 1)]);
    }
  }
  for (int i = 0; i < q; ++i) cout << ans[i][0] << " " << ans[i][1] << '\n';
  return 0;
}
