#include <bits/stdc++.h>
using namespace std;
const int N = 110;
int n, m;
int a[N][N];
int sum_r[N], sum_c[N];
int op_r[N], op_c[N];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) {
      scanf("%d", a[i] + j);
      sum_r[i] += a[i][j];
      sum_c[j] += a[i][j];
    }
  while (true) {
    int found = 0;
    for (int i = 0; i < n; ++i) {
      if (sum_r[i] >= 0) continue;
      found = 1;
      sum_r[i] = -sum_r[i];
      op_r[i] ^= 1;
      for (int j = 0; j < m; ++j) {
        a[i][j] = -a[i][j];
        sum_c[j] += 2 * a[i][j];
      }
    }
    for (int i = 0; i < m; ++i) {
      if (sum_c[i] >= 0) continue;
      found = 1;
      sum_c[i] = -sum_c[i];
      op_c[i] ^= 1;
      for (int j = 0; j < n; ++j) {
        a[j][i] = -a[j][i];
        sum_r[j] += 2 * a[j][i];
      }
    }
    if (!found) break;
  }
  int s = 0;
  for (int i = 0; i < n; ++i) s += op_r[i];
  printf("%d ", s);
  for (int i = 0; i < n; ++i)
    if (op_r[i]) printf("%d ", i + 1);
  printf("\n");
  s = 0;
  for (int i = 0; i < m; ++i) s += op_c[i];
  printf("%d ", s);
  for (int i = 0; i < m; ++i)
    if (op_c[i]) printf("%d ", i + 1);
  printf("\n");
  return 0;
}
