#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 7;
vector<int> v[N];
int n, q, c[N], g[N], w[N], lt[N], rt[N], f1[N], f2[N], g1[N][3], g2[N][3];
map<int, int> p;
inline int read() {
  int num = 0;
  char g = getchar();
  while (g < 48 || 57 < g) g = getchar();
  while (47 < g && g < 58)
    num = (num << 1) + (num << 3) + g - 48, g = getchar();
  return num;
}
inline int lowbit(int u) { return (u & (-u)); }
inline void addx(int u) {
  while (u <= n) w[u]++, u += lowbit(u);
}
inline int getans(int u) {
  int ans = 0;
  while (u > 0) ans += w[u], u -= lowbit(u);
  return ans;
}
namespace sub1 {
int ret, f[N];
inline void init() {
  for (int i = 1; i <= 4 * n; i++) f[i] = 0;
}
inline void getmax(int l, int r, int t, int ql, int qr, int c) {
  if (l == ql && r == qr) {
    f[t] = c;
    return;
  }
  int d = (l + r) >> 1;
  if (ql <= d) getmax(l, d, t << 1, ql, min(d, qr), c);
  if (d + 1 <= qr) getmax(d + 1, r, t << 1 | 1, max(d + 1, ql), qr, c);
  f[t] = max(f[t << 1], f[t << 1 | 1]);
}
inline int getans(int l, int r, int t, int ql, int qr, int z) {
  if (l == ql && r == qr) {
    if (l == r) {
      if (f[t] >= z) {
        ret = f[t];
        return l;
      }
      return 0;
    }
    if (f[t] < z) return 0;
    int d = (l + r) >> 1;
    if (f[t << 1] >= z) return getans(l, d, t << 1, l, d, z);
    return getans(d + 1, r, t << 1 | 1, d + 1, r, z);
  }
  int ans = 0, d = (l + r) >> 1;
  if (ql <= d) ans = getans(l, d, t << 1, ql, min(d, qr), z);
  if (ans > 0) return ans;
  if (d + 1 <= qr) ans = getans(d + 1, r, t << 1 | 1, max(d + 1, ql), qr, z);
  return ans;
}
}  // namespace sub1
namespace sub2 {
int ret, f[N];
inline void init() {
  for (int i = 1; i <= 4 * n; i++) f[i] = n + 1;
}
inline void getmin(int l, int r, int t, int ql, int qr, int c) {
  if (l == ql && r == qr) {
    f[t] = c;
    return;
  }
  int d = (l + r) >> 1;
  if (ql <= d) getmin(l, d, t << 1, ql, min(d, qr), c);
  if (d + 1 <= qr) getmin(d + 1, r, t << 1 | 1, max(d + 1, ql), qr, c);
  f[t] = min(f[t << 1], f[t << 1 | 1]);
}
inline int getans(int l, int r, int t, int ql, int qr, int z) {
  if (l == ql && r == qr) {
    if (l == r) {
      if (f[t] <= z) {
        ret = f[t];
        return l;
      }
      return 0;
    }
    if (f[t] > z) return 0;
    int d = (l + r) >> 1;
    if (f[t << 1 | 1] <= z) return getans(d + 1, r, t << 1 | 1, d + 1, r, z);
    return getans(l, d, t << 1, l, d, z);
  }
  int ans = 0, d = (l + r) >> 1;
  if (d + 1 <= qr) ans = getans(d + 1, r, t << 1 | 1, max(d + 1, ql), qr, z);
  if (ans > 0) return ans;
  if (ql <= d) ans = getans(l, d, t << 1, ql, min(d, qr), z);
  return ans;
}
}  // namespace sub2
int main() {
  n = read(), q = read();
  for (int i = 1; i <= n; i++) g[i] = c[i] = read();
  sort(g + 1, g + n + 1);
  for (int i = 1; i <= n; i++) p[g[i]] = i;
  for (int i = 1; i <= n; i++) v[p[c[i]]].push_back(i);
  for (int i = 1; i <= n; i++)
    f1[i] = f1[i - 1] + (c[i] <= c[i + 1]),
    f2[i] = f2[i - 1] + (c[i] >= c[i + 1]);
  sub1::init(), sub2::init();
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < v[i].size(); j++) {
      if (!getans(v[i][j])) continue;
      int l = 1, r = v[i][j] - 1, pos = 0;
      while (l <= r) {
        int d = (l + r) >> 1;
        if (getans(d) != getans(v[i][j]))
          pos = d, l = d + 1;
        else
          r = d - 1;
      }
      lt[v[i][j]] = pos + 1;
      sub1::getmax(1, n, 1, v[i][j], v[i][j], lt[v[i][j]]);
    }
    for (int j = 0; j < v[i].size(); j++) {
      int c = getans(n);
      if (getans(v[i][j]) == c) continue;
      int l = v[i][j] + 1, r = n, pos = n;
      while (l <= r) {
        int d = (l + r) >> 1;
        if (getans(d) != getans(v[i][j]))
          pos = d, r = d - 1;
        else
          l = d + 1;
      }
      rt[v[i][j]] = pos;
      sub2::getmin(1, n, 1, v[i][j], v[i][j], rt[v[i][j]]);
    }
    for (int j = 0; j < v[i].size(); j++) addx(v[i][j]);
    for (int j = 0; j < v[i].size(); j++) {
      int l = 1, r = v[i][j] - 1, pos = 0;
      if (getans(v[i][j]) == v[i][j]) continue;
      while (l <= r) {
        int d = (l + r) >> 1;
        if (getans(v[i][j]) != getans(d) + v[i][j] - d)
          pos = d, l = d + 1;
        else
          r = d - 1;
      }
      pos++;
      int c = 0;
      if (pos - 1 >= 1) c = sub2::getans(1, n, 1, 1, pos - 1, v[i][j]);
      if (c > 0) {
        g1[v[i][j]][0] = pos;
        g1[v[i][j]][1] = c;
        g1[v[i][j]][2] = sub2::ret;
      }
    }
    for (int j = 0; j < v[i].size(); j++) {
      int l = v[i][j] + 1, r = n, pos = 0;
      while (l <= r) {
        int d = (l + r) >> 1;
        if (getans(v[i][j]) != getans(d) + v[i][j] - d)
          pos = d, r = d - 1;
        else
          l = d + 1;
      }
      if (pos == 0) continue;
      int c = 0;
      if (pos + 1 <= n) c = sub1::getans(1, n, 1, pos + 1, n, v[i][j]);
      if (c > 0) {
        g2[v[i][j]][0] = pos;
        g2[v[i][j]][1] = c;
        g2[v[i][j]][2] = sub1::ret;
      }
    }
  }
  for (int i = 1; i <= n; i++) sort(g1[i], g1[i] + 3), sort(g2[i], g2[i] + 3);
  sub1::init(), sub2::init();
  for (int i = 1; i <= n; i++)
    if (g1[i][0]) sub1::getmax(1, n, 1, i, i, g1[i][0]);
  for (int i = 1; i <= n; i++)
    if (g2[i][2]) sub2::getmin(1, n, 1, i, i, g2[i][2]);
  while (q--) {
    int l = read(), r = read();
    if (f2[r - 1] - f2[l - 1] == r - l || f1[r - 1] - f1[l - 1] == r - l) {
      puts("0");
      puts("");
      continue;
    }
    int a = sub1::getans(1, n, 1, l, r, l);
    if (a > 0) {
      puts("4");
      printf("%d %d %d %d\n", g1[a][0], g1[a][1], g1[a][2], a);
      continue;
    }
    int b = sub2::getans(1, n, 1, l, r, r);
    if (b > 0) {
      puts("4");
      printf("%d %d %d %d\n", b, g2[b][0], g2[b][1], g2[b][2]);
      continue;
    }
    a = l + 2, b = r;
    int p = 0;
    while (a <= b) {
      int d = (a + b) >> 1;
      if (f1[d - 1] - f1[l - 1] == d - l || f2[d - 1] - f2[l - 1] == d - l)
        a = d + 1;
      else
        b = d - 1, p = d;
    }
    puts("3");
    printf("%d %d %d\n", l, p - 1, p);
  }
  return 0;
}
