#include <bits/stdc++.h>
using namespace std;
int n, m;
int a[105][105];
int sumx[105], sumy[105];
int flagx[105], flagy[105];
int ans1, ans2;
inline int judge_x() {
  for (int i = 1; i <= n; i++) {
    if (sumx[i] < 0) return i;
  }
  return 0;
}
inline int judge_y() {
  for (int i = 1; i <= m; i++) {
    if (sumy[i] < 0) return i;
  }
  return 0;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      scanf("%d", &a[i][j]);
      sumx[i] += a[i][j];
      sumy[j] += a[i][j];
    }
  }
  while (1) {
    int tmpx = judge_x();
    int tmpy = judge_y();
    if (!tmpx && !tmpy) break;
    if (tmpx) {
      flagx[tmpx]++;
      sumx[tmpx] = 0;
      for (int i = 1; i <= m; i++) {
        int k = -a[tmpx][i];
        sumy[i] = sumy[i] - a[tmpx][i] + k;
        a[tmpx][i] = k;
        sumx[tmpx] += k;
      }
    } else {
      flagy[tmpy]++;
      sumy[tmpy] = 0;
      for (int i = 1; i <= n; i++) {
        int k = -a[i][tmpy];
        sumx[i] = sumx[i] - a[i][tmpy] + k;
        a[i][tmpy] = k;
        sumy[tmpy] += k;
      }
    }
  }
  for (int i = 1; i <= n; i++)
    if (flagx[i] & 1) ans1++;
  for (int i = 1; i <= m; i++)
    if (flagy[i] & 1) ans2++;
  printf("%d ", ans1);
  for (int i = 1; i <= n; i++) {
    if (flagx[i] & 1) printf("%d ", i);
  }
  printf("\n%d ", ans2);
  for (int i = 1; i <= m; i++) {
    if (flagy[i] & 1) printf("%d ", i);
  }
  printf("\n");
  return 0;
}
