#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1.0);
void pr(deque<int> d) {
  while (!d.empty()) {
    int x = d.front();
    cout << x << " ";
    d.pop_front();
  }
  cout << '\n';
}
pair<int, int> amid[300010];
int main() {
  int n, q, mx = 0;
  vector<int> v;
  cin >> n >> q;
  deque<int> d;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    v.push_back(x);
    mx = max(mx, x);
    if (i == 0) amid[0].first = x;
    if (i == 1) amid[0].second = x;
    d.push_back(x);
  }
  for (int i = 1; i < n; i++) {
    int a = d.front();
    d.pop_front();
    int b = d.front();
    d.pop_front();
    amid[i].first = a;
    amid[i].second = b;
    if (a > b) {
      d.push_front(a);
      d.push_back(b);
      continue;
    }
    d.push_front(b);
    d.push_back(a);
  }
  v.clear();
  mx = d.front();
  d.pop_front();
  while (!d.empty()) {
    v.push_back(d.front());
    d.pop_front();
  }
  while (q--) {
    long long x;
    scanf("%lld", &x);
    if (x < n) {
      printf("%d %d\n", amid[x].first, amid[x].second);
      continue;
    }
    x -= n;
    printf("%d %d\n", mx, v[x % (n - 1)]);
  }
}
