#include <bits/stdc++.h>
using namespace std;
void read(long long &x) {
  x = 0;
  char c = getchar();
  int f = 1;
  while (c < '0' || c > '9') {
    if (c == '-') f = -f;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = (x << 3) + (x << 1) + c - '0';
    c = getchar();
  }
  x *= f;
  return;
}
long long maxt(long long a, long long b) { return a > b ? a : b; }
long long mint(long long a, long long b) { return a < b ? a : b; }
void write(long long x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  if (x < 10) {
    putchar('0' + x);
    return;
  }
  write(x / 10);
  putchar(x % 10 + '0');
  return;
}
bool vis1[105], vis2[105], vis3[105], vis4[105];
long long n, m, tot, s[105][105], c[105], r[105], ans1, ans2, a1[105], a2[105];
bool check() {
  for (int i = 1; i <= n; i++)
    if (r[i] < 0) return 1;
  for (int j = 1; j <= m; j++)
    if (c[j] < 0) return 1;
  return 0;
}
int main() {
  read(n), read(m);
  long long p = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      read(s[i][j]), tot += fabs(s[i][j]) * 2, r[i] += s[i][j];
  for (int j = 1; j <= m; j++)
    for (int i = 1; i <= n; i++) c[j] += s[i][j];
  p = -tot;
  long long i = 1, j = 1, tot1 = 0;
  while (check()) {
    bool f = 0;
    while (i <= n) {
      if (r[i] < 0) {
        vis1[i] = !vis1[i];
        a1[++ans1] = i;
        p += -4 * r[i];
        r[i] = -r[i];
        for (int k = 1; k <= m; k++) {
          c[k] -= 2 * s[i][k];
          s[i][k] = -s[i][k];
        }
        f = 1;
        tot1 = 0;
        break;
      }
      i++;
    }
    while (j <= m && !f) {
      if (c[j] < 0) {
        vis2[j] = !vis2[j];
        a2[++ans2] = j;
        p += -4 * c[j];
        c[j] = -c[j];
        for (int k = 1; k <= n; k++) {
          r[k] -= 2 * s[k][j];
          s[k][j] = -s[k][j];
        }
        f = 1;
        tot1 = 0;
        break;
      }
      j++;
    }
    if (!f) tot1++;
    if (tot1 > 1) break;
    if (i > n && j > m) {
      i = 1;
      j = 1;
    }
  }
  long long p1 = 0;
  for (int i = 1; i <= ans1; i++)
    if (vis1[a1[i]]) p1++, vis1[a1[i]] = 0, vis3[i] = 1;
  write(p1);
  for (int i = 1; i <= ans1; i++)
    if (vis3[i]) {
      putchar(' ');
      write(a1[i]);
    }
  putchar('\n');
  long long p2 = 0;
  for (int i = 1; i <= ans2; i++)
    if (vis2[a2[i]]) p2++, vis2[a2[i]] = 0, vis4[i] = 1;
  write(p2);
  for (int i = 1; i <= ans2; i++)
    if (vis4[i]) {
      putchar(' ');
      write(a2[i]);
    }
}
