#include <bits/stdc++.h>
using namespace std;
const int maxn = 200010;
int n, a[maxn], tu[maxn], td[maxn], mn[maxn], mx[maxn], fmn[maxn], fmx[maxn],
    lm[maxn], Q;
int oth[maxn], mna[maxn], mxa[maxn], dat[maxn * 4], val[maxn * 4][2];
set<int> vis;
multiset<int> once;
void Insert(int x) {
  once.insert(x);
  assert(once.count(x) <= 2);
  if (once.count(x) == 2) vis.insert(x);
}
int get(int x, int y) {
  if (lm[x] == lm[y]) return min(x, y);
  return (lm[x] > lm[y] ? y : x);
}
void build(int p, int l, int r) {
  if (l == r) {
    dat[p] = l;
    val[p][0] = val[p][1] = l;
    return;
  }
  int mid = (l + r) >> 1;
  build(p * 2, l, mid);
  build(p * 2 + 1, mid + 1, r);
  dat[p] = get(dat[p * 2], dat[p * 2 + 1]);
  val[p][0] = (a[val[p * 2][0]] < a[val[p * 2 + 1][0]] ? val[p * 2][0]
                                                       : val[p * 2 + 1][0]);
  val[p][1] = (a[val[p * 2][1]] > a[val[p * 2 + 1][1]] ? val[p * 2][1]
                                                       : val[p * 2 + 1][1]);
}
int query(int p, int l, int r, int L, int R) {
  if (L <= l && r <= R) return dat[p];
  int mid = (l + r) >> 1, res = n;
  if (L <= mid) res = get(res, query(p * 2, l, mid, L, R));
  if (R > mid) res = get(res, query(p * 2 + 1, mid + 1, r, L, R));
  return res;
}
int qq(int p, int l, int r, int L, int R, int w) {
  if (L <= l && r <= R) return val[p][w];
  int mid = (l + r) >> 1;
  if (R <= mid) return qq(p * 2, l, mid, L, R, w);
  if (L > mid) return qq(p * 2 + 1, mid + 1, r, L, R, w);
  int lc = qq(p * 2, l, mid, L, R, w), rc = qq(p * 2 + 1, mid + 1, r, L, R, w);
  return w ? (a[lc] > a[rc] ? lc : rc) : (a[lc] < a[rc] ? lc : rc);
}
int main() {
  scanf("%d%d", &n, &Q);
  for (int i(1), i_END(n); i <= i_END; i++) scanf("%d", &a[i]);
  int t1 = 0, t2 = 0;
  td[n] = tu[n] = n;
  lm[0] = n + 1;
  for (int i(n), i_END(1); i >= i_END; i--) {
    if (i < n) {
      if (a[i + 1] <= a[i])
        td[i] = td[i + 1];
      else
        td[i] = i;
      if (a[i + 1] >= a[i])
        tu[i] = tu[i + 1];
      else
        tu[i] = i;
    }
    while (t1 && a[i] < a[mn[t1]]) Insert(mn[t1]), --t1;
    while (t2 && a[i] > a[mx[t2]]) Insert(mx[t2]), --t2;
    if (a[i] == a[mn[t1]])
      fmn[i] = fmn[mn[t1]];
    else
      fmn[i] = mn[t1];
    if (a[i] == a[mx[t2]])
      fmx[i] = fmx[mx[t2]];
    else
      fmx[i] = mx[t2];
    mn[++t1] = i;
    mx[++t2] = i;
    if (!fmn[i] || !fmx[i]) {
      lm[i] = n + 1;
      continue;
    }
    int tmp = max(fmn[i], fmx[i]);
    auto it = vis.lower_bound(tmp);
    if (it == vis.end())
      lm[i] = n + 1;
    else
      lm[i] = *it;
  }
  build(1, 1, n);
  while (Q--) {
    int l, r;
    scanf("%d%d", &l, &r);
    if (r <= tu[l] || r <= td[l]) {
      printf("0\n");
      continue;
    }
    int pos = query(1, 1, n, l, r);
    if (lm[pos] <= r) {
      printf("4\n");
      int t1 = qq(1, 1, n, pos, lm[pos], 0), t2 = qq(1, 1, n, pos, lm[pos], 1);
      printf("%d %d %d %d\n", pos, min(t1, t2), max(t1, t2), lm[pos]);
    } else {
      printf("3\n");
      if (fmn[tu[l]] && a[tu[l]] != a[l] && fmn[tu[l]] <= r)
        printf("%d %d %d\n", l, tu[l], fmn[tu[l]]);
      else
        printf("%d %d %d\n", l, td[l], fmx[td[l]]);
    }
  }
  return 0;
}
