#include <bits/stdc++.h>
using namespace std;
long long modexpo(long long x, long long p) {
  long long res = 1;
  x = x % 1000000007;
  while (p) {
    if (p % 2) res = res * x;
    p >>= 1;
    x = x * x % 1000000007;
    res %= 1000000007;
  }
  return res;
}
struct compare {
  bool operator()(const pair<long long, long long> a,
                  const pair<long long, long long> b) const {
    return a.first < b.first;
  }
};
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, q;
  cin >> n >> q;
  deque<long long> d;
  long long mx = -1;
  for (long long i = 0; i < n; i++) {
    long long x;
    cin >> x;
    mx = max(mx, x);
    d.push_back(x);
  }
  if (q == 0) {
    exit(0);
  }
  vector<pair<long long, long long>> v;
  pair<long long, long long> ans[q];
  for (long long i = 0; i < q; i++) {
    long long x;
    cin >> x;
    v.push_back({x, i});
    ans[i] = {-1, -1};
  }
  sort(v.begin(), v.end());
  long long j = 0;
  long long k = 0;
  for (long long i = 1; i <= v[q - 1].first && j < q; i++) {
    long long a = d.front();
    d.pop_front();
    long long b = d.front();
    d.pop_front();
    while (i == v[j].first && j < q) {
      ans[v[j].second] = {a, b};
      j++;
    }
    if (a > b) {
      d.push_front(a);
      d.push_back(b);
    } else {
      d.push_front(b);
      d.push_back(a);
    }
    k++;
    if (a == mx) {
      break;
    }
  }
  vector<long long> vx;
  d.pop_front();
  while (d.size()) {
    long long x = d.front();
    d.pop_front();
    vx.push_back(x);
  }
  for (long long i = j; i < q; i++) {
    long long cur = (v[i].first - k - 1) % vx.size();
    ans[v[i].second] = {mx, vx[cur]};
  }
  for (long long i = 0; i < q; i++) {
    cout << ans[i].first << " " << ans[i].second << endl;
  }
}
