#include <bits/stdc++.h>
using namespace std;
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << '\n'; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
const int oo = 2e9 + 100;
const int N = 1e5 + 100;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, q;
  cin >> n >> q;
  vector<int> a(n);
  for (int& e : a) {
    cin >> e;
  }
  vector<long long> m(q);
  for (long long& e : m) {
    cin >> e;
  }
  int op = 0;
  int mx = *max_element(a.begin(), a.end());
  vector<pair<int, int> > ans(n + 10);
  deque<int> dq(a.begin(), a.end());
  for (op = 1; dq.front() != mx; ++op) {
    int a = dq.front();
    dq.pop_front();
    int b = dq.front();
    dq.pop_front();
    ans[op] = {a, b};
    if (a <= b) swap(a, b);
    dq.push_front(a);
    dq.push_back(b);
  }
  a = vector<int>(dq.begin(), dq.end());
  for (int i = 0; i < q; ++i) {
    if (m[i] < op) {
      cout << ans[m[i]].first << ' ' << ans[m[i]].second << '\n';
    } else {
      m[i] -= op;
      m[i] %= (n - 1);
      cout << a[0] << ' ' << a[m[i] + 1] << '\n';
    }
  }
  return 0;
}
