#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, q, mx = 0, x;
  cin >> n >> q;
  deque<int> arr;
  vector<long long> que(q);
  for (int i = 0; i < n; i++) {
    cin >> x;
    arr.push_back(x);
  }
  for (int i = 0; i < q; i++) cin >> que[i];
  for (int i = 0; i < n; i++) {
    if (arr[i] >= arr[mx]) mx = i;
  }
  vector<pair<int, int> > ans;
  for (int i = 0; i < mx; i++) {
    int a, b, big, small;
    a = arr.front();
    arr.pop_front();
    b = arr.front();
    arr.pop_front();
    ans.push_back(make_pair(a, b));
    big = max(a, b);
    small = min(a, b);
    arr.push_front(big);
    arr.push_back(small);
  }
  for (int i = 0; i < q; i++) {
    if (que[i] < mx + 1)
      cout << ans[que[i] - 1].first << " " << ans[que[i] - 1].second << endl;
    else {
      que[i] -= mx;
      que[i] %= (n - 1);
      if (!que[i]) que[i] = n - 1;
      cout << arr[0] << " " << arr[que[i]] << endl;
    }
  }
  return 0;
}
