#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, q, x, mx = -1, idx;
  deque<long long> d;
  map<long long, pair<long long, long long>> ma;
  cin >> n >> q;
  for (long long i = 0; i < n; i++) {
    cin >> x;
    mx = max(x, mx);
    d.push_back(x);
  }
  int maxIndex = 0;
  while (true) {
    long long first = d.front();
    d.pop_front();
    long long second = d.front();
    d.pop_front();
    if (first == mx) {
      d.push_front(second);
      d.push_front(first);
      break;
    }
    maxIndex++;
    ma[maxIndex] = {first, second};
    if (second > first) {
      swap(first, second);
    }
    d.push_front(first);
    d.push_back(second);
  }
  int a[n];
  for (int i = 0; i < n; i++) {
    a[i] = d.front();
    d.pop_front();
  }
  for (int i = 0; i < q; i++) {
    long long mj;
    cin >> mj;
    if (mj <= maxIndex) {
      cout << ma[mj].first << " " << ma[mj].second << '\n';
    } else {
      cout << mx << " " << a[(mj - (maxIndex + 1)) % (n - 1) + 1] << '\n';
    }
  }
}
