#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(NULL);
  std::cout.tie(NULL);
  long long t = 1;
  while (t--) {
    long long n, m;
    cin >> n >> m;
    long long ar[n];
    vector<long long> sh;
    vector<pair<long long, long long>> st;
    for (long long i = 0; i < n; i++) cin >> ar[i];
    long long cur = ar[0];
    for (long long i = 1; i < n; i++) {
      if (ar[i] <= cur) {
        sh.push_back(ar[i]);
      } else
        sh.push_back(cur);
      st.push_back({cur, ar[i]});
      cur = max(cur, ar[i]);
    }
    for (long long i = 0; i < m; i++) {
      long long in;
      cin >> in;
      if (in < n) {
        cout << st[in - 1].first << " " << st[in - 1].second << "\n";
      } else {
        in = in % (n - 1);
        if (in == 0) in = n - 1;
        cout << cur << " " << sh[in - 1] << "\n";
      }
    }
  }
  return 0;
}
