#include <bits/stdc++.h>
using namespace std;
pair<long long, long long> ans[100005];
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, q;
  cin >> n >> q;
  long long a[n];
  for (long long i = 0; i < n; i++) cin >> a[i];
  long long A = a[0], B;
  vector<long long> ans1;
  for (long long i = 1; i < n; i++) {
    B = a[i];
    ans[i] = {A, B};
    ans1.push_back(min(A, B));
    A = max(A, B);
  }
  while (q--) {
    long long x;
    cin >> x;
    if (x < n) {
      cout << ans[x].first << " " << ans[x].second << "\n";
    } else {
      x--;
      x %= (n - 1);
      cout << A << " " << ans1[x] << "\n";
    }
  }
}
