#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const long long int inf = 1LL << 32;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, q;
  cin >> n >> q;
  int a[n];
  deque<int> dq;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    dq.push_back(a[i]);
  }
  int mx = *max_element(a, a + n), i;
  for (int j = 0; j < n; ++j)
    if (a[j] == mx) {
      i = j;
      break;
    }
  vector<pair<int, int> > v(i + 1);
  v[0].first = a[0];
  v[0].second = a[1];
  int x, y;
  for (int j = 1; j < i + 1; j++) {
    x = dq.front();
    dq.pop_front();
    y = dq.front();
    dq.pop_front();
    v[j].first = max(x, y);
    dq.push_back(min(x, y));
    v[j].second = dq.front();
    dq.push_front(max(x, y));
  }
  i = 0;
  while (dq.size() > 0) {
    a[i] = dq.front();
    dq.pop_front();
    i++;
  }
  long long int m;
  i = v.size() - 1;
  while (q--) {
    cin >> m;
    m--;
    if (m <= i)
      cout << v[m].first << " " << v[m].second << endl;
    else
      cout << mx << " "
           << a[(m - (long long int)i) % (long long int)(n - 1) + 1LL] << endl;
  }
}
