#include <bits/stdc++.h>
using namespace std;
int n, a[128][128], m;
bool frow[128], fcol[128];
int srow[128], scol[128];
bool f() {
  for (int i = 0; i < n; i++) {
    if (srow[i] < 0) {
      frow[i] = !frow[i];
      for (int x = 0; x < m; x++) {
        scol[x] -= 2 * a[i][x];
        a[i][x] *= -1;
      }
      srow[i] *= -1;
      return 1;
    }
  }
  for (int i = 0; i < m; i++) {
    if (scol[i] < 0) {
      fcol[i] = !fcol[i];
      for (int y = 0; y < n; y++) {
        srow[y] -= 2 * a[y][i];
        a[y][i] *= -1;
      }
      scol[i] *= -1;
      return 1;
    }
  }
  return 0;
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
      srow[i] += a[i][j];
      scol[j] += a[i][j];
    }
  }
  while (f()) {
  }
  int cntR = 0, cntC = 0;
  for (int i = 0; i < n; i++) {
    if (frow[i]) {
      cntR++;
    }
  }
  for (int i = 0; i < m; i++) {
    if (fcol[i]) {
      cntC++;
    }
  }
  cout << cntR << "\n";
  for (int i = 0; i < n; i++) {
    if (frow[i]) {
      cout << i + 1 << " ";
    }
  }
  cout << "\n";
  cout << cntC << "\n";
  for (int i = 0; i < m; i++) {
    if (fcol[i]) {
      cout << i + 1 << " ";
    }
  }
  cout << "\n";
  return 0;
}
