#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long LLINF = 1e18 + 7;
deque<int> DQ;
pair<int, int> ans[200040];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  ;
  int n, q;
  cin >> n >> q;
  int a;
  for (int i = 0; i < n; i++) {
    cin >> a;
    DQ.push_back(a);
  }
  int N = n + 6;
  for (int i = 1; i <= 2 * N + 6; i++) {
    int a, b;
    a = DQ.front();
    DQ.pop_front();
    b = DQ.front();
    DQ.pop_front();
    ans[i] = {a, b};
    if (a < b) {
      swap(a, b);
    }
    DQ.push_front(a);
    DQ.push_back(b);
  }
  long long m;
  for (int i = 0; i < q; i++) {
    cin >> m;
    if (m <= N) {
      cout << ans[m].first << " " << ans[m].second << '\n';
    } else {
      m -= N;
      int idx = m % (n - 1) + N;
      cout << ans[idx].first << " " << ans[idx].second << '\n';
    }
  }
}
