#include <bits/stdc++.h>
using namespace std;
int n, m, a[111][111], xc[111], yc[111], x[111], y[111];
set<int> rx, ry;
int xx(int c) {
  xc[c]++;
  x[c] *= -1;
  for (int i = 1; i <= m; i++) {
    y[i] -= 2 * a[c][i];
    a[c][i] *= -1;
  }
  return 1;
}
int yy(int c) {
  yc[c]++;
  y[c] *= -1;
  for (int i = 1; i <= n; i++) {
    x[i] -= 2 * a[i][c];
    a[i][c] *= -1;
  }
  return 1;
}
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]);
      x[i] += a[i][j];
      y[j] += a[i][j];
    }
  }
  while (1) {
    int flag = 0;
    for (int i = 1; i <= n; i++) {
      if (x[i] < 0) {
        flag = xx(i);
        break;
      }
    }
    if (flag) continue;
    for (int i = 1; i <= m; i++) {
      if (y[i] < 0) {
        flag = yy(i);
        break;
      }
    }
    if (!flag) break;
  }
  for (int i = 1; i <= n; i++)
    if (xc[i] % 2) rx.insert(i);
  for (int i = 1; i <= m; i++)
    if (yc[i] % 2) ry.insert(i);
  printf("%d ", (int)rx.size());
  for (auto next : rx) printf("%d ", next);
  puts("");
  printf("%d ", (int)ry.size());
  for (auto next : ry) printf("%d ", next);
  return 0;
}
