#include <bits/stdc++.h>
using namespace std;
int a[110][110];
int row[110], column[110];
int main() {
  int n, m, sum, judge = 0;
  scanf("%d%d", &n, &m);
  memset(row, 0, sizeof(row));
  memset(column, 0, sizeof(column));
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) scanf("%d", &a[i][j]);
  while (judge == 0) {
    judge = 1;
    for (int i = 1; i <= n; i++) {
      sum = 0;
      for (int j = 1; j <= m; j++) {
        sum += a[i][j];
      }
      if (sum < 0) {
        judge = 0;
        for (int j = 1; j <= m; j++) a[i][j] *= -1;
        row[i]++;
      }
    }
    for (int j = 1; j <= m; j++) {
      sum = 0;
      for (int i = 1; i <= n; i++) {
        sum += a[i][j];
      }
      if (sum < 0) {
        judge = 0;
        for (int i = 1; i <= n; i++) a[i][j] *= -1;
        column[j]++;
      }
    }
  }
  int cntofrow = 0, cntofcolumn = 0;
  for (int i = 1; i <= n; i++) {
    if (row[i] % 2 == 1) {
      cntofrow++, row[i] = 1;
    }
  }
  for (int j = 1; j <= m; j++) {
    if (column[j] % 2 == 1) {
      cntofcolumn++, column[j] = 1;
    }
  }
  printf("%d ", cntofrow);
  for (int i = 1; i <= n; i++) {
    if (row[i] == 1) printf("%d ", i);
  }
  printf("\n");
  printf("%d ", cntofcolumn);
  for (int j = 1; j <= m; j++) {
    if (column[j] == 1) printf("%d ", j);
  }
  printf("\n");
  return 0;
}
