#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1e5 + 1;
const int MOD = 998244353;
const int INF = 1e9;
const long long LINF = 1e18;
void solve() {
  int n, q;
  cin >> n >> q;
  vector<int> a(n);
  int mx = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    mx = max(mx, a[i]);
  }
  deque<int> dq;
  vector<pair<int, int> > pp;
  int nmx = a[0];
  int ind = 0;
  for (int i = 1; i < n; ++i) {
    pp.push_back({nmx, a[i]});
    if (a[i] > nmx) {
      dq.push_back(nmx);
      nmx = a[i];
    } else {
      dq.push_back(a[i]);
    }
    nmx = max(nmx, a[i]);
    if (a[i] == mx) {
      ind = i;
      break;
    }
  }
  for (int i = n - 1; i >= ind + 1; --i) {
    dq.push_front(a[i]);
  }
  int ez = pp.size();
  for (int t = 0; t < q; ++t) {
    long long m;
    cin >> m;
    if (m <= ez) {
      int f = pp[m - 1].first, s = pp[m - 1].second;
      cout << f << " " << s << endl;
    } else {
      int sz = dq.size();
      cout << mx << " " << dq[(m - ez - 1) % sz] << endl;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  while (t--) {
    solve();
  }
}
