#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
const long long p = 1e9 + 1;
deque<int> l;
vector<long long> x;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, q;
  cin >> n >> q;
  long long a;
  for (int i = 0; i < n; i++) {
    cin >> a;
    l.push_back(a);
  }
  long long b;
  long long y;
  for (int i = 0; i < n - 1; i++) {
    a = l.front();
    l.pop_front();
    b = l.front();
    l.pop_front();
    y = p * a + b;
    x.push_back(y);
    l.push_front(max(a, b));
    l.push_back(min(a, b));
  }
  int br = 0;
  a = l.front();
  l.pop_front();
  b = l.front();
  l.pop_front();
  y = p * a + b;
  x.push_back(y);
  l.push_front(max(a, b));
  l.push_back(min(a, b));
  while (y != x[br]) {
    a = l.front();
    l.pop_front();
    b = l.front();
    l.pop_front();
    y = p * a + b;
    x.push_back(y);
    l.push_front(max(a, b));
    l.push_back(min(a, b));
    br++;
  }
  x.pop_back();
  long long m;
  for (int i = 0; i < q; i++) {
    cin >> m;
    m--;
    if (m < br) {
      cout << x[m] / p << " " << x[m] % p << '\n';
    } else {
      m -= br;
      cout << x[br + (m % (n - 1))] / p << " " << x[br + (m % (n - 1))] % p
           << '\n';
    }
  }
  return 0;
}
