#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1e5 + 5;
deque<long long> num;
long long f[maxn], s[maxn], arr[maxn];
long long n, q, Max = 0, ci, a, b, temp;
int main() {
  cin >> n >> q;
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &temp);
    if (temp > Max) Max = temp;
    num.push_back(temp);
    if (i == 1) f[0] = temp;
    if (i == 2) s[0] = temp;
  }
  while (1) {
    a = num.front();
    num.pop_front();
    b = num.front();
    num.pop_front();
    if (a == Max) {
      num.push_front(b);
      num.push_front(a);
      break;
    } else {
      ci++;
      f[ci] = a;
      s[ci] = b;
      if (a > b) {
        num.push_front(a);
        num.push_back(b);
      } else {
        num.push_front(b);
        num.push_back(a);
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    arr[i] = num.front();
    num.pop_front();
  }
  for (int i = 1; i <= q; i++) {
    cin >> temp;
    if (temp <= ci) {
      cout << f[temp] << " " << s[temp] << endl;
    } else {
      temp -= ci;
      temp %= (n - 1);
      if (temp != 0)
        cout << Max << " " << arr[temp + 1] << endl;
      else
        cout << Max << " " << arr[n] << endl;
    }
  }
  return 0;
}
