#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n, q, x;
  cin >> n >> q;
  vector<long long int> v(n);
  long long mx = -1, ps;
  deque<long long> dq;
  for (long long int i = 0; i < n; i++) {
    cin >> v[i];
    dq.push_back(v[i]);
    if (v[i] > mx) {
      mx = v[i];
      ps = i;
    }
  }
  vector<pair<long long int, long long int>> ans(ps + 1);
  for (long long int i = 1; i < ps + 1; i++) {
    long long v1, v2;
    v1 = dq.front();
    dq.pop_front();
    v2 = dq.front();
    dq.pop_front();
    ans[i] = {v1, v2};
    if (v1 > v2) {
      dq.push_front(v1);
      dq.push_back(v2);
    } else {
      dq.push_front(v2);
      dq.push_back(v1);
    }
  }
  vector<long long int> rem;
  for (long long int i = 0; i < n; i++) {
    rem.push_back(dq.front());
    dq.pop_front();
  }
  for (long long int i = 0; i < q; i++) {
    cin >> x;
    if (x <= ps) {
      cout << ans[x].first << " " << ans[x].second << '\n';
    } else {
      x -= ps;
      x--;
      x = x % (n - 1);
      x++;
      cout << rem[0] << " " << rem[x] << '\n';
    }
  }
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int TESTS = 1;
  while (TESTS--) {
    solve();
  }
  cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
  return 0;
}
