#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  deque<int> q;
  int temp;
  int maxi = 0;
  int i;
  for (i = 0; i < n; i++) {
    cin >> temp;
    q.push_back(temp);
    if (maxi < temp) maxi = temp;
  }
  int ans[n][2];
  long long pos = 1;
  int fin[n];
  while (true) {
    int a = q.front();
    q.pop_front();
    int b = q.front();
    q.pop_front();
    ans[pos][0] = a;
    ans[pos][1] = b;
    if (a > b) {
      q.push_front(a);
      q.push_back(b);
    } else {
      q.push_front(b);
      q.push_back(a);
    }
    if (q.front() == maxi) {
      for (i = 0; i < n; i++) {
        fin[i] = q.front();
        q.pop_front();
      }
      break;
    }
    pos++;
  }
  while (k--) {
    long long m;
    cin >> m;
    if (m <= pos)
      cout << ans[m][0] << " " << ans[m][1] << endl;
    else {
      cout << maxi << " ";
      long long num = (m - pos) % (n - 1);
      if (num == 0) num = n - 1;
      cout << fin[num] << endl;
    }
  }
}
