#include <bits/stdc++.h>
using namespace std;
long long a[1900005], A[900005], B[900005];
int main() {
  long long n, q, i, x, y;
  cin >> n >> q;
  for (i = 0; i < n; i++) cin >> a[i];
  for (i = 0; i < 900003; i++) {
    x = i + 1;
    A[x] = a[i];
    B[x] = a[x];
    y = i + n;
    if (a[i] > a[x]) {
      a[y] = a[x];
      a[x] = a[i];
    } else
      a[y] = a[i];
  }
  y = 0;
  for (i = 0; i < n; i++)
    if (a[i] > a[y]) y = i;
  y++;
  n--;
  while (q) {
    cin >> x;
    if (x > y)
      cout << A[x % n + n] << " " << B[x % n + n] << endl;
    else
      cout << A[x] << " " << B[x] << endl;
    q--;
  }
  return 0;
}
