#include <bits/stdc++.h>
using namespace std;
vector<long long> primes;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int n, q;
  cin >> n >> q;
  vector<pair<int, int> > ans;
  int tmp(-1);
  vector<bool> state;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    if (tmp <= x) {
      if (!i)
        tmp = x;
      else {
        ans.push_back(make_pair(tmp, x));
        tmp = x;
        state.push_back(true);
      }
    } else {
      ans.push_back(make_pair(x, tmp));
      state.push_back(false);
    }
  }
  int nw = n - 1;
  while (q--) {
    long long y;
    cin >> y;
    if (!y)
      cout << '\n';
    else {
      if (y < n) {
        if (state[y - 1])
          cout << ans[y - 1].first << " " << ans[y - 1].second << '\n';
        else
          cout << ans[y - 1].second << " " << ans[y - 1].first << '\n';
      } else {
        y -= n;
        if (!y)
          cout << tmp << " " << ans[0].first << '\n';
        else
          cout << tmp << " " << ans[y % nw].first << '\n';
      }
    }
  }
  return 0;
}
