#include <bits/stdc++.h>
using namespace std;
deque<long long> q;
vector<pair<long long, long long>> ans;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long i, n, qq, m, a, b, mx = 0, k;
  cin >> n >> qq;
  for (i = 0; i < n; i++) {
    cin >> a;
    mx = max(a, mx);
    q.push_back(a);
  }
  for (i = 0; i < 2 * n; i++) {
    a = q.front();
    q.pop_front();
    b = q.front();
    q.pop_front();
    ans.push_back({a, b});
    if (a < b) swap(a, b);
    if (a == mx) k = i;
    q.push_front(a);
    q.push_back(b);
  }
  for (i = 0; i < qq; i++) {
    cin >> m;
    m--;
    if (m >= 2 * n) m = (m - k) % (n - 1) + n;
    cout << ans[m].first << ' ' << ans[m].second << '\n';
  }
  return 0;
}
