#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
using namespace std;
long long n, q;
long long fin[100005];
deque<long long> dq;
pair<long long, long long> arr[100005];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> q;
  for (int i = 0; i < (n); i++) {
    long long a;
    cin >> a;
    dq.push_back(a);
  }
  for (int i = 0; i < (n - 1); i++) {
    arr[i].first = dq.front();
    dq.pop_front();
    arr[i].second = dq.front();
    dq.pop_front();
    dq.push_back(min(arr[i].first, arr[i].second));
    dq.push_front(max(arr[i].first, arr[i].second));
  }
  for (int i = 0; i < (n); i++) {
    fin[i] = dq.front();
    dq.pop_front();
  }
  for (int i = 0; i < (q); i++) {
    long long m;
    cin >> m;
    if (m < n) {
      cout << arr[m - 1].first << " " << arr[m - 1].second << "\n";
      continue;
    }
    m -= n;
    m %= (n - 1);
    cout << fin[0] << " " << fin[1 + m] << "\n";
  }
  return 0;
}
