#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n;
  cin >> n;
  long long noq;
  cin >> noq;
  long long arr[n];
  deque<long long> q;
  for (long long i = 0; i < n; i++) {
    long long val;
    cin >> val;
    arr[i] = val;
    q.push_back(val);
  }
  long long maxi = -1;
  long long idx = -1;
  for (long long i = 0; i < n; i++) {
    if (arr[i] > maxi) {
      idx = i;
      maxi = arr[i];
    }
  }
  vector<pair<long long, long long> > vect;
  for (long long i = 0; i < idx; i++) {
    long long a = q.front();
    q.pop_front();
    long long b = q.front();
    q.pop_front();
    vect.push_back(make_pair(a, b));
    if (a > b) {
      q.push_front(a);
      q.push_back(b);
    } else {
      q.push_front(b);
      q.push_back(a);
    }
  }
  for (long long i = 0; i < n; i++) {
    long long val = q.front();
    arr[i] = val;
    q.pop_front();
  }
  for (long long i = 0; i < noq; i++) {
    long long val;
    cin >> val;
    val--;
    if (val < idx) {
      cout << vect[val].first << " " << vect[val].second << "\n";
    } else {
      long long remain = (val - idx) % (n - 1);
      cout << arr[0] << " " << arr[remain + 1] << "\n";
    }
  }
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  for (long long i = 1; i < t + 1; i++) {
    solve();
  }
  return 0;
}
