#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n, q;
  cin >> n >> q;
  long long int arr[n];
  long long int aftern[n];
  long long int maxi[n];
  for (long long int i = 0; i < n; i++) {
    cin >> arr[i];
    if (i == 0)
      maxi[i] = i;
    else {
      if (arr[i] > arr[maxi[i - 1]])
        maxi[i] = i;
      else
        maxi[i] = maxi[i - 1];
    }
  }
  long long int i = n - 1;
  long long int e = n - 1;
  while (i >= 0) {
    long long int maxin = maxi[i];
    for (long long int j = maxin; j < e; j++) {
      aftern[j] = arr[j + 1];
    }
    aftern[e] = arr[maxin];
    i = maxin - 1;
    e = i;
  }
  long long int max_in = maxi[n - 1];
  for (long long int i = 0; i < q; i++) {
    long long int x;
    cin >> x;
    if (x > (n - 1)) {
      long long int t = x % (n - 1);
      if (t != 0)
        cout << arr[max_in] << " " << aftern[t - 1] << "\n";
      else
        cout << arr[max_in] << " " << aftern[n - 2] << "\n";
    } else {
      cout << arr[maxi[x - 1]] << " " << arr[x] << "\n";
    }
  }
  return 0;
}
