#include <bits/stdc++.h>
using namespace std;
int n, m;
int a[101][101];
int si[101], sj[101];
bool di[101], dj[101];
void ci(int i) {
  for (int j = 0; j < m; ++j) {
    sj[j] -= 2 * a[i][j];
    a[i][j] *= -1;
  }
  si[i] *= -1;
  di[i] = !di[i];
}
void cj(int j) {
  for (int i = 0; i < n; ++i) {
    si[i] -= 2 * a[i][j];
    a[i][j] *= -1;
  }
  sj[j] *= -1;
  dj[j] = !dj[j];
}
void print(bool d[101], int n) {
  int cnt = 0;
  for (int i = 0; i < n; ++i)
    if (d[i]) ++cnt;
  cout << cnt;
  for (int i = 0; i < n; ++i) {
    if (d[i]) cout << " " << i + 1;
  }
  cout << endl;
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      cin >> a[i][j];
      si[i] += a[i][j];
      sj[j] += a[i][j];
    }
  }
  while (true) {
    int i = min_element(si, si + n) - si;
    int j = min_element(sj, sj + m) - sj;
    if (si[i] >= 0 && sj[j] >= 0) break;
    if (si[i] < 0)
      ci(i);
    else
      cj(j);
  }
  print(di, n);
  print(dj, m);
  return 0;
}
