#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 1e5 + 5;
int main(int argc, char const *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, q;
  cin >> n >> q;
  deque<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  int mx = *max_element(a.begin(), a.end());
  map<int, pair<int, int>> mp;
  for (int i = 1; i <= n; ++i) {
    int x = a[0];
    int y = a[1];
    a.pop_front();
    a.pop_front();
    a.push_front(max(x, y));
    a.push_back(min(x, y));
    mp[i] = {x, y};
    if (max(x, y) == mx) break;
  }
  while (q--) {
    ll m;
    cin >> m;
    if (m <= mp.size()) {
      cout << mp[m].first << ' ' << mp[m].second << '\n';
      continue;
    }
    m -= mp.size();
    m %= (n - 1);
    if (m == 0) m = n - 1;
    cout << mx << ' ' << a[m] << '\n';
  }
  return 0;
}
