#include <bits/stdc++.h>
using namespace std;
int n;
int m;
int a[123][123];
int row[123];
int col[123];
bool go() {
  for (int i = 0; i < n; ++i) {
    int sum = 0;
    for (int j = 0; j < m; ++j) {
      sum += a[i][j];
    }
    if (sum < 0) {
      for (int j = 0; j < m; ++j) {
        a[i][j] = -a[i][j];
      }
      row[i] = 1 - row[i];
      return true;
    }
  }
  for (int j = 0; j < m; ++j) {
    int sum = 0;
    for (int i = 0; i < n; ++i) {
      sum += a[i][j];
    }
    if (sum < 0) {
      for (int i = 0; i < n; ++i) {
        a[i][j] = -a[i][j];
      }
      col[j] = 1 - col[j];
      return true;
    }
  }
  return false;
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      scanf("%d", a[i] + j);
    }
  }
  memset(row, 0, sizeof row);
  memset(col, 0, sizeof col);
  while (go())
    ;
  int size_r = 0, size_c = 0;
  for (int i = 0; i < n || i < m; ++i) {
    if (i < n) {
      size_r += row[i];
    }
    if (i < m) {
      size_c += col[i];
    }
  }
  printf("%d ", size_r);
  for (int i = 0; i < n; ++i) {
    if (row[i] == 1) {
      printf("%d ", i + 1);
    }
  }
  printf("\n");
  printf("%d ", size_c);
  for (int i = 0; i < m; ++i) {
    if (col[i] == 1) {
      printf("%d ", i + 1);
    }
  }
  return 0;
}
