#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, q;
  cin >> n >> q;
  deque<int> deq;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    deq.push_back(a);
  }
  vector<pair<int, int>> ans;
  for (int i = 0; i < 2 * n + 7; i++) {
    int a = deq.front();
    deq.pop_front();
    int b = deq.front();
    deq.pop_front();
    ans.push_back(make_pair(a, b));
    if (b > a) {
      swap(b, a);
    }
    deq.push_front(a);
    deq.push_back(b);
  }
  while (q--) {
    long long int x;
    cin >> x;
    x--;
    if (x < 2 * n) {
      cout << ans[x].first << " " << ans[x].second << endl;
    } else {
      x -= n;
      x %= (n - 1);
      x += n;
      cout << ans[x].first << " " << ans[x].second << endl;
    }
  }
}
