#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long maxN = 2e5 + 1;
const long long mx = 1e5 + 1;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long n, q, a;
  cin >> n >> q;
  deque<long long> dq;
  long long mx = 0;
  for (long long i = 0; i < n; i++) {
    cin >> a;
    dq.push_back(a);
    mx = max(mx, a);
  }
  map<long long, pair<long long, long long>> mp;
  long long arr[q];
  for (long long i = 0; i < q; i++) cin >> arr[i];
  long long cnt = 0, i = 1;
  while (dq.front() != mx) {
    long long x = dq.front();
    if (x == mx) break;
    cnt++;
    dq.pop_front();
    long long y = dq.front();
    dq.pop_front();
    mp[i] = {x, y};
    if (x > y)
      dq.push_front(x), dq.push_back(y);
    else
      dq.push_front(y), dq.push_back(x);
    i++;
  }
  for (long long i = 0; i < q; i++) {
    if (mp.find(arr[i]) != mp.end())
      cout << mp[arr[i]].first << " " << mp[arr[i]].second << "\n";
    else {
      long long r;
      arr[i] -= cnt;
      r = (arr[i] % (n - 1));
      if (r == 0)
        cout << mx << " " << dq.at(dq.size() - 1) << "\n";
      else
        cout << mx << " " << dq.at(r) << "\n";
    }
  }
  return 0;
}
