#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
long long int MOD = 998244353;
bool mult = false;
const int mxN = 1e5 + 10;
vector<long long int> a;
vector<long long int> residuals;
vector<pair<long long int, long long int>> offset;
void solve(long long int caseNum) {
  long long int n, q;
  cin >> n >> q;
  long long int max = -1, pos = -1;
  for (long long int i = 0; i < n; ++i) {
    long long int next;
    cin >> next;
    a.push_back(next);
    if (a[i] > max) {
      max = a[i];
      pos = i;
    }
  }
  for (long long int i = pos + 1; i < n; ++i) residuals.push_back(a[i]);
  long long int ptr1 = 0, ptr2 = 1;
  while (ptr1 < pos + 1 && ptr2 < pos + 1) {
    if (ptr1 > ptr2) swap(ptr1, ptr2);
    offset.emplace_back(a[ptr1], a[ptr2]);
    if (a[ptr1] > a[ptr2]) {
      residuals.push_back(a[ptr2]);
      ptr2++;
    } else {
      residuals.push_back(a[ptr1]);
      ptr1 = ptr2 + 1;
    }
  }
  for (long long int i = 0; i < q; ++i) {
    long long int m;
    cin >> m;
    m--;
    if (m < offset.size()) {
      cout << offset[m].first << " " << offset[m].second << '\n';
    } else {
      m -= offset.size();
      cout << max << " " << residuals[m % residuals.size()] << '\n';
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  if (mult) {
    long long int t;
    cin >> t;
    for (long long int i = 1; i <= t; i++) solve(i);
  } else
    solve(0);
}
