#include <bits/stdc++.h>
using namespace std;
int a[105738];
deque<long long int> dq;
vector<pair<int, int> > v;
void op(int x, int y) {
  if (x > y) {
    dq.push_front(x);
    dq.push_back(y);
  } else {
    dq.push_front(y);
    dq.push_back(x);
  }
}
int main() {
  int n, q;
  cin >> n >> q;
  int maxi = 0;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (x > maxi) maxi = x;
    dq.push_back(x);
  }
  int x, y;
  int j = 0;
  int cnt = 0;
  if (dq.front() == maxi) {
    vector<int> temp;
    dq.pop_front();
    while (!dq.empty()) {
      int xx = dq.front();
      temp.push_back(xx);
      dq.pop_front();
    }
    int len = temp.size();
    while (q--) {
      long long int quer;
      cin >> quer;
      if (quer <= cnt) {
        cout << v[quer - 1].first << " " << v[quer - 1].second << endl;
      } else {
        quer = quer - cnt;
        quer = (quer - 1) % len;
        cout << maxi << " " << temp[quer] << endl;
      }
    }
  } else {
    while (1) {
      x = dq.front();
      dq.pop_front();
      y = dq.front();
      dq.pop_front();
      v.push_back({x, y});
      j = j + 1;
      op(x, y);
      cnt++;
      if (dq.front() == maxi) break;
    }
    vector<int> temp;
    dq.pop_front();
    while (!dq.empty()) {
      int xx = dq.front();
      temp.push_back(xx);
      dq.pop_front();
    }
    int len = temp.size();
    while (q--) {
      long long int quer;
      cin >> quer;
      if (quer <= cnt) {
        cout << v[quer - 1].first << " " << v[quer - 1].second << endl;
      } else {
        quer = quer - cnt;
        quer = (quer - 1) % len;
        cout << maxi << " " << temp[quer] << endl;
      }
    }
  }
}
