#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m, s;
  std::ios::sync_with_stdio(false);
  while (cin >> n >> m) {
    int a[300005];
    int l2[300005];
    int nn = 0;
    for (nn; nn < n; nn++) cin >> a[nn];
    l2[0] = a[0];
    for (int i = 0; i < n - 1; i++) {
      a[nn++] = min(l2[i], a[i + 1]);
      l2[i + 1] = max(l2[i], a[i + 1]);
    }
    while (m--) {
      cin >> s;
      if (s <= n)
        cout << l2[s - 1] << " " << a[s] << endl;
      else
        cout << l2[n - 1] << " " << a[n + (s - n) % (n - 1)] << endl;
    }
  }
  return 0;
}
