#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5, mod = 1e9 + 7;
int A[N], B[N], C[N];
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, q;
  cin >> n >> q;
  for (int i = 0; i < n; i++) cin >> A[i];
  int mx1 = -1, mx2 = -1, checked = 0, ind1 = 0, ind2 = 0;
  for (int i = 0; i < n; i++)
    if (mx1 < A[i]) mx1 = A[i], ind1 = i;
  for (int i = 0; i < n; i++)
    if (mx2 < A[i]) {
      if (A[i] == mx1 && !checked)
        checked++;
      else
        mx2 = A[i], ind2 = i;
    }
  B[0] = A[0], C[0] = A[1];
  int ptr = 0;
  for (int i = 1; i < 2 * n; i++) {
    if (A[ptr] <= A[ptr + 1]) {
      A[ptr + n] = A[ptr];
      ptr++;
    } else {
      A[ptr + n] = A[ptr + 1];
      A[ptr + 1] = A[ptr];
      ptr++;
    }
    B[i] = A[ptr], C[i] = A[ptr + 1];
  }
  while (q--) {
    long long x;
    cin >> x;
    x--;
    if (x < 1ll * ind1)
      cout << B[x] << ' ' << C[x] << '\n';
    else {
      long long ind = ind1 + ((x - ind1) % (n - 1));
      cout << B[ind] << ' ' << C[ind] << '\n';
    }
  }
}
