#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const int mod = 998244353;
deque<int> a;
pair<int, int> b[N], c[N];
int n;
int q;
void cal() {
  int first, second;
  for (int i = 0; i < n - 1; i++) {
    first = a.front();
    a.pop_front();
    second = a.front();
    a.pop_front();
    b[i + 1].first = first;
    b[i + 1].second = second;
    a.push_front(max(first, second));
    a.push_back(min(first, second));
  }
  first = a.front();
  a.pop_front();
  for (int i = 0; i < n - 1; i++) {
    second = a.front();
    a.pop_front();
    c[i + 1].first = first;
    c[i + 1].second = second;
  }
}
int main() {
  cin >> n >> q;
  int tmp;
  for (int i = 1; i <= n; i++) {
    cin >> tmp;
    a.push_back(tmp);
  }
  cal();
  long long t;
  while (q--) {
    cin >> t;
    if (t <= n - 1)
      cout << b[t].first << " " << b[t].second << endl;
    else {
      t %= (n - 1);
      if (t == 0) t = n - 1;
      cout << c[t].first << " " << c[t].second << endl;
    }
  }
  return 0;
}
