#include <bits/stdc++.h>
using namespace std;
void printArray(int a[], int n) {
  for (int i = 0; i < n; i++) cout << a[i] << " ";
  cout << "\n";
}
void printVector(vector<int> v) {
  for (auto x : v) cout << x << " ";
  cout << "\n";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int n, q;
  cin >> n >> q;
  std::deque<int> v;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    v.push_back(a);
  }
  std::vector<int> a, b;
  for (int i = 0; i < n; i++) {
    a.push_back(v.front());
    v.pop_front();
    b.push_back(v.front());
    v.pop_front();
    v.push_front(max(a[i], b[i]));
    v.push_back(min(a[i], b[i]));
  }
  for (int i = 0; i < q; i++) {
    long long int val;
    cin >> val;
    if (val <= n)
      cout << a[val - 1] << " " << b[val - 1] << "\n";
    else {
      val -= n;
      val %= n - 1;
      if (val == 0) val = n - 1;
      cout << v[0] << " " << v[val] << "\n";
    }
  }
}
