#include <bits/stdc++.h>
using namespace std;
const int N = 105;
int row[N], col[N], a[N][N], n, m;
vector<int> ans0, ans1;
bool f0[N], f1[N];
void change_row(int x) {
  row[x] = -row[x];
  for (int i = 1; i <= m; ++i) {
    a[x][i] = -a[x][i];
  }
  f0[x] ^= 1;
}
void change_col(int x) {
  col[x] = -col[x];
  for (int i = 1; i <= n; ++i) {
    a[i][x] = -a[i][x];
  }
  f1[x] ^= 1;
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      cin >> a[i][j];
    }
  }
  while (true) {
    memset(row, 0, sizeof row);
    memset(col, 0, sizeof col);
    for (int i = 1; i <= n; ++i) {
      for (int j = 1; j <= m; ++j) {
        col[j] += a[i][j];
        row[i] += a[i][j];
      }
    }
    int ind_row = -1, ind_col = -1;
    for (int i = 1; i <= n; ++i) {
      if (row[i] < 0) {
        ind_row = i;
        break;
      }
    }
    for (int i = 1; i <= m; ++i) {
      if (col[i] < 0) {
        ind_col = i;
        break;
      }
    }
    if (~ind_row) {
      change_row(ind_row);
    } else {
      if (~ind_col) {
        change_col(ind_col);
      } else {
        break;
      }
    }
  }
  for (int i = 1; i <= n; ++i)
    if (f0[i]) ans0.push_back(i);
  for (int i = 1; i <= m; ++i)
    if (f1[i]) ans1.push_back(i);
  cout << ans0.size() << ' ';
  for (int i : ans0) cout << i << ' ';
  cout << '\n';
  cout << ans1.size() << ' ';
  for (int i : ans1) cout << i << ' ';
  cout << '\n';
}
