#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int n, q;
  cin >> n >> q;
  vector<pair<int, int> > ans1;
  vector<int> ans2;
  vector<int> a(n);
  for (auto &e : a) cin >> e;
  int cur = a[0];
  for (int i = 1; i < n; i++) {
    int t = a[i];
    ans1.push_back(pair<int, int>(cur, t));
    if (t > cur) {
      swap(t, cur);
    }
    ans2.push_back(t);
  }
  int mx = *max_element((a).begin(), (a).end());
  while (q--) {
    long long m;
    cin >> m;
    --m;
    if (m < n - 1) {
      cout << ans1[m].first << ' ' << ans1[m].second << '\n';
    } else {
      cout << mx << ' ' << ans2[m % (n - 1)] << '\n';
    }
  }
  return 0;
}
