#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
long long power(long long x, long long y, long long p) {
  long long res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
bool prime[1000005];
void seive(int n) {
  memset(prime, true, sizeof(prime));
  for (int p = 2; p * p <= n; p++) {
    if (prime[p] == true) {
      for (int i = p * p; i <= n; i += p) prime[i] = false;
    }
  }
}
unordered_map<long long, vector<long long>> adj;
map<long long, long long> visited;
long long cnt = 0;
long long root = 0, mx = 0;
const int mxn = 300005;
long long sub[mxn], wys[mxn];
long long tot = 0;
void dfs(long long curr, long long lvl, long long p) {
  if (adj[curr].size() == 1)
    sub[curr] = 1;
  else
    sub[curr] = 0;
  wys[curr] = 0;
  wys[curr] -= (sub[curr] * (sub[curr]));
  for (auto x : adj[curr]) {
    if (x != p) {
      dfs(x, lvl + 1, curr);
      sub[curr] += sub[x];
      wys[curr] -= (sub[x] * (sub[x]));
    }
  }
  wys[curr] += (tot * (tot));
  wys[curr] -= ((tot - sub[curr]) * (tot - sub[curr]));
  wys[curr] /= 2;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long n, q;
  cin >> n >> q;
  long long a[n], mn = 0;
  deque<long long> que;
  for (long long i = 0; i < n; i++)
    cin >> a[i], mx = max(mx, a[i]), que.push_back(a[i]);
  long long A[2 * n + 1], B[2 * n + 1], pos = 0;
  for (long long i = 1; i <= 2 * n; i++) {
    long long x, y;
    if (que.front() == mx) {
      pos = i;
      break;
    }
    x = que.front();
    que.pop_front();
    y = que.front();
    que.pop_front();
    if (x > y)
      que.push_front(x), que.push_back(y);
    else
      que.push_front(y), que.push_back(x);
    A[i] = x;
    B[i] = y;
    pos = i;
  }
  long long ind = 0;
  while (que.size() != 0) {
    a[ind] = que.front();
    que.pop_front();
    ind++;
  }
  while (q--) {
    long long m;
    cin >> m;
    if (m < pos) {
      cout << A[m] << " " << B[m] << endl;
    } else {
      long long p = m - pos;
      long long r = p % (n - 1) + 1;
      cout << mx << " " << a[r] << endl;
    }
  }
  return 0;
}
