#include <bits/stdc++.h>
using namespace std;
int sr[110] = {0}, sc[110] = {0}, cr = 0, cc = 0;
bool fr[110] = {0}, fc[110] = {0};
int a[110][110];
int main() {
  int i, j, k, n, m;
  scanf("%d", &n);
  scanf("%d", &m);
  for (i = 0; i < n; ++i) {
    for (j = 0; j < m; ++j) {
      scanf("%d", &a[i][j]);
      sr[i] += a[i][j];
      sc[j] += a[i][j];
    }
  }
  while (true) {
    bool f = 0;
    for (i = 0; i < n; ++i)
      if (sr[i] < 0) {
        fr[i] = 1 - fr[i];
        cr--;
        if (fr[i]) cr += 2;
        f = 1;
        for (j = 0; j < m; ++j) {
          sr[i] -= (a[i][j] << 1);
          sc[j] -= (a[i][j] << 1);
          a[i][j] = -a[i][j];
        }
      }
    for (j = 0; j < m; ++j)
      if (sc[j] < 0) {
        fc[j] = 1 - fc[j];
        cc--;
        if (fc[j]) cc += 2;
        f = 1;
        for (i = 0; i < n; ++i) {
          sr[i] -= (a[i][j] << 1);
          sc[j] -= (a[i][j] << 1);
          a[i][j] = -a[i][j];
        }
      }
    if (!f) break;
  }
  printf("%d ", cr);
  for (i = 0; i < n; ++i)
    if (fr[i]) printf("%d ", i + 1);
  printf("\n%d ", cc);
  for (i = 0; i < m; ++i)
    if (fc[i]) printf("%d ", i + 1);
  printf("\n");
}
