#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int N = 1000005;
const double PI = 4 * atan(1);
const double eps = 1e-7;
pair<long long, long long> a[N];
deque<int> dq;
long long n, q;
int main() {
  ios::sync_with_stdio(0);
  cin >> n >> q;
  long long ma = 0;
  for (int i = 0; i < n; i++) {
    long long x;
    cin >> x;
    dq.push_back(x);
    ma = max(ma, x);
  }
  for (int i = 0; i < n; i++) {
    long long x = dq.front();
    dq.pop_front();
    long long y = dq.front();
    dq.pop_front();
    a[i] = make_pair(x, y);
    if (x > y) {
      dq.push_front(x);
      dq.push_back(y);
    } else {
      dq.push_front(y);
      dq.push_back(x);
    }
  }
  while (q--) {
    long long m;
    cin >> m;
    if (m <= n) {
      cout << a[m - 1].first << " " << a[m - 1].second << endl;
    } else {
      m -= n;
      cout << ma << " " << dq[(m - 1) % (n - 1) + 1] << endl;
    }
  }
  return 0;
}
