#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, q, max = 0, z = 0;
  cin >> n >> q;
  vector<int> a(n, 0);
  long long int x;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] > max) {
      z = i;
      max = a[i];
    }
  }
  int m[z][2];
  vector<int>::iterator it = a.begin();
  for (int i = 0; i < z; i++) {
    m[i][0] = a[0];
    m[i][1] = a[1];
    if (a[0] > a[1]) {
      a.push_back(m[i][1]);
      it = a.begin() + 1;
      a.erase(it);
    } else {
      a.push_back(m[i][0]);
      it = a.begin();
      a.erase(it);
    }
  }
  for (int i = 0; i < q; i++) {
    cin >> x;
    if (x <= z && x > 0) {
      cout << m[x - 1][0] << " " << m[x - 1][1] << endl;
    } else if (x > z) {
      x = x - z - 1;
      x = x % (n - 1);
      cout << a[0] << " " << a[x + 1] << endl;
    }
  }
}
