#include <bits/stdc++.h>
using namespace std;
const int MAXN = 300005;
const int MOD = 1000000007;
int N, Q;
deque<int> d;
pair<long long, long long> ans[MAXN];
pair<long long, long long> M[MAXN];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> Q;
  int mx = -1;
  for (int i = (1); i <= (N); i++) {
    int x;
    cin >> x;
    d.push_back(x);
    mx = max(mx, x);
  }
  for (int i = (1); i <= (Q); i++) {
    cin >> M[i].first;
    M[i].second = i;
  }
  sort(M + 1, M + Q + 1);
  int t = 1, a = 1;
  while (d.front() != mx) {
    int x = d[0], y = d[1];
    while (a <= Q && M[a].first < t) a++;
    while (a <= Q && M[a].first == t) {
      ans[M[a].second] = pair<long long, long long>(x, y);
      a++;
    }
    if (x > y) swap(x, y);
    d.push_back(x);
    d.pop_front();
    d.pop_front();
    d.push_front(y);
    t++;
  }
  for (int i = (a); i <= (Q); i++) {
    int id = (M[i].first - t + N - 1) % (N - 1);
    ans[M[i].second] = pair<long long, long long>(mx, d[id + 1]);
  }
  for (int i = (1); i <= (Q); i++)
    cout << ans[i].first << ' ' << ans[i].second << "\n";
}
