#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long maxn = 500005;
const long long mm = 1e+18;
long long power(long long x, long long y) {
  long long res = 1;
  x = x % mod;
  while (y > 0) {
    if (y & 1) res = (res * x) % mod;
    y = y >> 1;
    x = (x * x) % mod;
  }
  return res;
}
long long ncr(long long n, long long k) {
  long long C[k + 1];
  memset(C, 0, sizeof(C));
  C[0] = 1;
  for (long long i = 1; i <= n; i++) {
    for (long long j = min(i, k); j > 0; j--) C[j] = (C[j] + C[j - 1]) % mod;
  }
  return C[k];
}
void solve() {
  int n, q1;
  cin >> n >> q1;
  int arr[n];
  int mx = -1;
  deque<int> q;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    q.push_back(arr[i]);
    if (arr[i] > mx) {
      mx = arr[i];
    }
  }
  vector<pair<int, int>> v;
  v.push_back({0, 0});
  long long tot = 0;
  while (q.front() != mx) {
    int x1 = q.front();
    q.pop_front();
    int x2 = q.front();
    q.pop_front();
    if (x1 > x2) {
      q.push_front(x1);
      q.push_back(x2);
    } else {
      q.push_front(x2);
      q.push_back(x1);
    }
    tot++;
    v.push_back({x1, x2});
  }
  vector<int> vv;
  q.pop_front();
  while (q.size()) {
    vv.push_back(q.front());
    q.pop_front();
  }
  while (q1--) {
    long long x;
    cin >> x;
    if (x <= tot) {
      cout << v[x].first << " " << v[x].second << "\n";
    } else {
      cout << mx << " ";
      long long xx = (x - tot - 1) % (n - 1);
      cout << vv[xx] << endl;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
