#include <bits/stdc++.h>
using namespace std;
deque<int> nums;
void operation() {
  int hold_1 = nums[0];
  int hold_2 = nums[1];
  nums.pop_front();
  nums.pop_front();
  nums.push_front(max(hold_1, hold_2));
  nums.push_back(min(hold_1, hold_2));
}
int main() {
  int n;
  int q;
  long long quers[300010];
  pair<int, int> dp[100010];
  int quer = 0;
  int hold;
  scanf("%d%d", &n, &q);
  for (int i = 0; i < n; i++) {
    scanf("%d", &hold);
    nums.push_back(hold);
  }
  for (int i = 0; i < q; i++) {
    scanf("%lld", &quers[i]);
  }
  for (int i = 0; i < n - 1; i++) {
    dp[i].first = nums[0];
    dp[i].second = nums[1];
    operation();
  }
  for (int i = 0; i < q; i++) {
    if (quers[i] < n) {
      printf("%d %d\n", dp[quers[i] - 1].first, dp[quers[i] - 1].second);
    } else {
      if ((quers[i] - n + 1) % (n - 1) == 0) {
        printf("%d %d\n", nums[0], nums[n - 1]);
      } else {
        printf("%d %d\n", nums[0], nums[(quers[i] - n + 1) % (n - 1)]);
      }
    }
  }
}
