#include <bits/stdc++.h>
int n, m;
int rc[101], cc[101], rs[101], cs[101], a[101][101];
void work() {
  int i, j;
  for (i = 1; i <= n; i++)
    if (rs[i] < 0) {
      for (j = 1; j <= m; j++) cs[j] -= a[i][j] * 2;
      for (j = 1; j <= m; j++) a[i][j] = -a[i][j];
      rc[i]++;
      rs[i] = -rs[i];
      return;
    }
  for (j = 1; j <= m; j++)
    if (cs[j] < 0) {
      for (i = 1; i <= n; i++) rs[i] -= a[i][j] * 2;
      for (i = 1; i <= n; i++) a[i][j] = -a[i][j];
      cc[j]++;
      cs[j] = -cs[j];
      return;
    }
}
int main(int argc, char** argv) {
  int i, j, num;
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++) scanf("%d", &a[i][j]);
  memset(rc, 0, sizeof rc);
  memset(cc, 0, sizeof cc);
  memset(rs, 0, sizeof rs);
  memset(cs, 0, sizeof cs);
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++) {
      rs[i] += a[i][j];
      cs[j] += a[i][j];
    }
  num = 100 * n * m;
  while (num--) work();
  int cnt = 0;
  for (i = 1; i <= n; i++)
    if (rc[i] & 1) cnt++;
  printf("%d", cnt);
  for (i = 1; i <= n; i++)
    if (rc[i] & 1) printf(" %d", i);
  putchar('\n');
  cnt = 0;
  for (i = 1; i <= m; i++)
    if (cc[i] & 1) cnt++;
  printf("%d", cnt);
  for (i = 1; i <= m; i++)
    if (cc[i] & 1) printf(" %d", i);
  putchar('\n');
  return 0;
}
