#include <bits/stdc++.h>
using namespace std;
const int maxn = 105;
int a[maxn][maxn], b[maxn], c[maxn], hb[maxn], hc[maxn];
int findx(int n) {
  for (int i = 1; i <= n; i++)
    if (b[i] < 0) return i;
  return 0;
}
int findy(int m) {
  for (int i = 1; i <= m; i++)
    if (c[i] < 0) return i;
  return 0;
}
int main() {
  int n, m;
  while (scanf("%d%d", &n, &m) != EOF) {
    memset(hb, 0, sizeof(hb));
    memset(hc, 0, sizeof(hc));
    memset(b, 0, sizeof(b));
    memset(c, 0, sizeof(c));
    int i, j;
    for (i = 1; i <= n; i++)
      for (j = 1; j <= m; j++) {
        scanf("%d", &a[i][j]);
        b[i] += a[i][j];
        c[j] += a[i][j];
      }
    int t1 = findx(n);
    int t2 = findy(m);
    while (t1 != 0 || t2 != 0) {
      if (t1) {
        for (j = 1; j <= m; j++) {
          a[t1][j] = -a[t1][j];
          c[j] += 2 * a[t1][j];
        }
        b[t1] = -b[t1];
        hb[t1]++;
      } else {
        for (i = 1; i <= n; i++) {
          a[i][t2] = -a[i][t2];
          b[i] += 2 * a[i][t2];
        }
        c[t2] = -c[t2];
        hc[t2]++;
      }
      t1 = findx(n);
      t2 = findy(m);
    }
    int ansx = 0;
    for (i = 1; i <= n; i++) {
      if (hb[i] % 2 == 1) ansx++;
    }
    int ansy = 0;
    for (i = 1; i <= m; i++) {
      if (hc[i] % 2 == 1) ansy++;
    }
    printf("%d ", ansx);
    for (i = 1; i <= n; i++)
      if (hb[i] % 2 == 1) printf("%d ", i);
    printf("\n");
    printf("%d ", ansy);
    for (i = 1; i <= m; i++)
      if (hc[i] % 2 == 1) printf("%d ", i);
    printf("\n");
  }
  return 0;
}
