#include <bits/stdc++.h>
using namespace std;
const int N = 105;
int a[N][N], rowst[N], colst[N], n, m;
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]);
  while (1) {
    int sum(0), br(-1), ty(-1);
    for (int i = 1; i <= n; ++i) {
      int cur(0);
      for (int j = 1; j <= m; ++j) cur += a[i][j];
      if (cur < sum) sum = cur, br = i, ty = 0;
    }
    for (int j = 1; j <= m; ++j) {
      int cur(0);
      for (int i = 1; i <= n; ++i) cur += a[i][j];
      if (cur < sum) sum = cur, br = j, ty = 1;
    }
    if (br == -1) break;
    if (ty) {
      colst[br] ^= 1;
      for (int i = 1; i <= n; ++i) a[i][br] *= -1;
    } else {
      rowst[br] ^= 1;
      for (int j = 1; j <= m; ++j) a[br][j] *= -1;
    }
  }
  int ccol(0), crow(0);
  for (int i = 1; i <= n; ++i) crow += rowst[i];
  printf("%d ", crow);
  for (int i = 1; i <= n; ++i)
    if (rowst[i]) printf("%d ", i);
  printf("\n");
  for (int j = 1; j <= m; ++j) ccol += colst[j];
  printf("%d ", ccol);
  for (int j = 1; j <= m; ++j)
    if (colst[j]) printf("%d ", j);
  printf("\n");
}
