#include <bits/stdc++.h>
using namespace std;
long long const N = 1e5 + 5;
long long const inf = 1e18 + 5;
long long const MOD = 1e9 + 7;
long long t, n, m, x, y, z, w, k;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> t;
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) cin >> a[i];
  vector<long long> tmp(n - 1);
  vector<pair<long long, long long>> ans;
  long long mx = a[0];
  long long j = 0;
  for (long long i = 1; i < n; i++) {
    x = mx;
    y = a[i];
    ans.push_back(make_pair(x, y));
    if (x > y)
      tmp[j] = y;
    else
      tmp[j] = x;
    mx = max(x, y);
    j++;
  }
  while (t--) {
    cin >> x;
    if (x < n)
      cout << ans[x - 1].first << " " << ans[x - 1].second << "\n";
    else
      cout << mx << " " << tmp[(x - 1) % (n - 1)] << "\n";
  }
  return 0;
}
