#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int gi() {
  int x = 0, o = 1;
  char ch = getchar();
  while ((ch < '0' || ch > '9') && ch != '-') ch = getchar();
  if (ch == '-') o = -1, ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return x * o;
}
struct dat {
  int len, x, y, z, w;
  int getr() const {
    if (!len) return 1e9;
    if (len == 3) return z;
    return w;
  }
  bool operator<(const dat &A) const { return getr() > A.getr(); }
  void print() {
    if (len == 3)
      cout << 3 << '\n' << x << ' ' << y << ' ' << z << '\n';
    else
      cout << 4 << '\n' << x << ' ' << y << ' ' << z << ' ' << w << '\n';
  }
} ans3[N], ans4[N];
int n, q, a[N];
void solve3() {
  static int L[N], R[N], st[N];
  int tp = 0;
  for (int i = 1; i <= n; i++) {
    while (tp && a[st[tp]] <= a[i]) --tp;
    L[i] = st[tp];
    st[++tp] = i;
  }
  tp = 0;
  for (int i = n; i; i--) {
    while (tp && a[st[tp]] <= a[i]) --tp;
    R[i] = st[tp];
    st[++tp] = i;
  }
  for (int i = 1; i <= n; i++)
    if (L[i] && R[i]) ans3[L[i]] = max(ans3[L[i]], (dat){3, L[i], i, R[i], 0});
  tp = 0;
  for (int i = 1; i <= n; i++) {
    while (tp && a[st[tp]] >= a[i]) --tp;
    L[i] = st[tp];
    st[++tp] = i;
  }
  tp = 0;
  for (int i = n; i; i--) {
    while (tp && a[st[tp]] >= a[i]) --tp;
    R[i] = st[tp];
    st[++tp] = i;
  }
  for (int i = 1; i <= n; i++)
    if (L[i] && R[i]) ans3[L[i]] = max(ans3[L[i]], (dat){3, L[i], i, R[i], 0});
}
bool cmp1(int x, int y) { return a[x] < a[y]; }
bool cmp2(int x, int y) { return a[x] > a[y]; }
void solve4() {
  static int st1[N], st2[N], occ[N];
  set<int> can;
  int tp1 = 0, tp2 = 0;
  for (int i = n; i; i--) {
    while (tp1 && a[st1[tp1]] > a[i]) {
      int tmp = st1[tp1];
      --occ[tmp];
      if (!occ[tmp]) can.insert(tmp);
      --tp1;
    }
    st1[++tp1] = i;
    while (tp2 && a[st2[tp2]] < a[i]) {
      int tmp = st2[tp2];
      --occ[tmp];
      if (!occ[tmp]) can.insert(tmp);
      --tp2;
    }
    st2[++tp2] = i;
    occ[i] = 2;
    int p = st1[lower_bound(st1 + 1, st1 + tp1 + 1, i, cmp1) - st1 - 1];
    int q = st2[lower_bound(st2 + 1, st2 + tp2 + 1, i, cmp2) - st2 - 1];
    if (p && q) {
      auto it = can.lower_bound(max(p, q) + 1);
      if (it != can.end()) {
        int t = *it;
        p = *lower_bound(st1 + 1, st1 + tp1 + 1, t, greater<int>());
        q = *lower_bound(st2 + 1, st2 + tp2 + 1, t, greater<int>());
        ans4[i] = (dat){4, i, min(p, q), max(p, q), t};
      }
    }
  }
}
int main() {
  cin >> n >> q;
  for (int i = 1; i <= n; i++) a[i] = gi();
  solve3();
  solve4();
  for (int i = n - 1; i; i--) {
    ans3[i] = max(ans3[i], ans3[i + 1]);
    ans4[i] = max(ans4[i], ans4[i + 1]);
  }
  for (int i = 1; i <= q; i++) {
    int l = gi(), r = gi();
    if (ans4[l].getr() <= r)
      ans4[l].print();
    else if (ans3[l].getr() <= r)
      ans3[l].print();
    else
      puts("0");
  }
  return 0;
}
