#include <bits/stdc++.h>
using namespace std;
template <class T>
void rd(T &x) {
  int f = 1;
  x = 0;
  char c;
  while (c = getchar(), c < 48)
    if (c == '-') f = -1;
  do x = (x << 3) + (x << 1) + (c ^ 48);
  while (c = getchar(), c > 47 && c < 58);
  x *= f;
}
const int N = 105;
int n, m, a[N][N], sumx[N], sumy[N], ansx[N], ansy[N], totx, toty;
int ckx() {
  for (int i = 1; i <= n; i++)
    if (sumx[i] < 0) return i;
  return 0;
}
int cky() {
  for (int i = 1; i <= m; i++)
    if (sumy[i] < 0) return i;
  return 0;
}
int main() {
  rd(n), rd(m);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      rd(a[i][j]), sumx[i] += a[i][j], sumy[j] += a[i][j];
  int xx = ckx(), yy = cky();
  while (xx || yy) {
    if (xx) {
      ++ansx[xx];
      sumx[xx] = 0;
      for (int i = 1; i <= m; i++) {
        int v = -a[xx][i];
        sumy[i] += v - a[xx][i];
        a[xx][i] = v;
        sumx[xx] += v;
      }
    } else {
      ++ansy[yy];
      sumy[yy] = 0;
      for (int i = 1; i <= n; i++) {
        int v = -a[i][yy];
        sumx[i] += v - a[i][yy];
        a[i][yy] = v;
        sumy[yy] += v;
      }
    }
    xx = ckx(), yy = cky();
  }
  for (int i = 1; i <= n; totx += (ansx[i] & 1), i++)
    ;
  for (int i = 1; i <= m; toty += (ansy[i] & 1), i++)
    ;
  printf("%d ", totx);
  for (int i = 1; i <= n; i++)
    if (ansx[i] & 1) printf("%d ", i);
  printf("\n%d ", toty);
  for (int i = 1; i <= m; i++)
    if (ansy[i] & 1) printf("%d ", i);
  return 0;
}
