#include <bits/stdc++.h>
using namespace std;
const long long MAX_N = 3e5 + 15, MOD = 1e9 + 7;
long long n, k;
long long Arr[3 * MAX_N];
long long L, R;
pair<long long, long long> ans[MAX_N];
int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  cin >> n >> k;
  for (long long i = 0; i < n; i++) cin >> Arr[i];
  L = 0, R = n - 1;
  for (long long i = 0; i < n; i++) {
    ans[i + 1] = {Arr[L], Arr[L + 1]};
    if (Arr[L] <= Arr[L + 1]) {
      Arr[R + 1] = Arr[L];
      L++, R++;
    } else {
      Arr[R + 1] = Arr[L + 1];
      Arr[L + 1] = Arr[L];
      L++, R++;
    }
  }
  for (long long i = 0; i < k; i++) {
    long long m;
    cin >> m;
    if (m <= n) {
      cout << ans[m].first << " " << ans[m].second << "\n";
      continue;
    }
    m -= n;
    m--;
    m %= n - 1;
    cout << Arr[L] << " " << Arr[L + 1 + m] << "\n";
  }
  return 0;
}
