#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, q;
  while (cin >> n >> q) {
    queue<int> qu;
    int MAX = 0;
    int M;
    int a[100005];
    int b[100005];
    int c[100005];
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      if (MAX <= a[i]) {
        MAX = a[i];
        M = i;
      }
    }
    b[0] = c[0] = a[0];
    for (int j = 1; j < n; j++) {
      b[j] = max(b[j - 1], a[j]);
      c[j - 1] = min(b[j - 1], a[j]);
    }
    while (q--) {
      long long m;
      cin >> m;
      if (m < n)
        cout << b[m - 1] << ' ' << a[m] << endl;
      else
        cout << MAX << ' ' << c[(m - 1) % (n - 1)] << endl;
    }
  }
}
