#include <bits/stdc++.h>
using namespace std;
#pragma warning(disable : 4996)
const int INF = 1e9;
const long long LINF = 1LL << 32;
const int MOD = 1000000007;
int main() {
  int N, Q;
  scanf("%d %d", &N, &Q);
  deque<int> dq;
  int maxValue = -1;
  for (int i = 0; i < N; i++) {
    int a;
    scanf("%d", &a);
    dq.push_back(a);
    maxValue = max(maxValue, a);
  }
  map<int, pair<int, int>> answer;
  int maxIndex = 0;
  while (true) {
    int first = dq.front();
    dq.pop_front();
    int second = dq.front();
    dq.pop_front();
    if (first == maxValue) {
      dq.push_front(second);
      dq.push_front(first);
      break;
    }
    maxIndex++;
    answer[maxIndex] = {first, second};
    if (second > first) {
      swap(first, second);
    }
    dq.push_front(first);
    dq.push_back(second);
  }
  int arr[100000];
  for (int i = 0; i < N; i++) {
    arr[i] = dq.front();
    dq.pop_front();
  }
  for (int i = 0; i < Q; i++) {
    long long m;
    scanf("%lld", &m);
    if (m <= maxIndex)
      printf("%d %d\n", answer[m].first, answer[m].second);
    else {
      printf("%d %d\n", maxValue, arr[(m - (maxIndex + 1)) % (N - 1) + 1]);
    }
  }
  return 0;
}
