#include <bits/stdc++.h>
using namespace std;
long long r[107], c[107], ra[107], ca[107];
long long a[107][107];
int main() {
  long long n, m;
  scanf("%lld %lld", &n, &m);
  for (int i = (1); i < (n + 1); i++) {
    for (int j = (1); j < (m + 1); j++) {
      scanf("%lld", &a[i][j]);
      r[i] += a[i][j];
      c[j] += a[i][j];
    }
  }
  queue<pair<long long, long long> > q;
  for (int i = (1); i < (n + 1); i++) {
    if (r[i] < 0) {
      q.push(make_pair(i, 0));
    }
  }
  for (int i = (1); i < (m + 1); i++) {
    if (c[i] < 0) {
      q.push(make_pair(i, 1));
    }
  }
  while (!q.empty()) {
    pair<long long, long long> now = q.front();
    q.pop();
    if (now.second == 0 && r[now.first] >= 0) continue;
    if (now.second == 1 && c[now.first] >= 0) continue;
    if (now.second == 0) {
      ra[now.first] ^= 1;
      r[now.first] = -r[now.first];
      for (int i = (1); i < (m + 1); i++) {
        c[i] -= 2 * a[now.first][i];
        if (c[i] < 0) {
          q.push(make_pair(i, 1));
        }
        a[now.first][i] = -a[now.first][i];
      }
    } else {
      ca[now.first] ^= 1;
      c[now.first] = -c[now.first];
      for (int i = (1); i < (n + 1); i++) {
        r[i] -= 2 * a[i][now.first];
        if (r[i] < 0) {
          q.push(make_pair(i, 0));
        }
        a[i][now.first] = -a[i][now.first];
      }
    }
  }
  long long cnt = 0;
  for (int i = (1); i < (n + 1); i++) {
    if (ra[i]) cnt++;
  }
  printf("%lld ", cnt);
  for (int i = (1); i < (n + 1); i++) {
    if (ra[i]) printf("%lld ", i);
  }
  cout << endl;
  cnt = 0;
  for (int i = (1); i < (m + 1); i++) {
    if (ca[i]) cnt++;
  }
  printf("%lld ", cnt);
  for (int i = (1); i < (m + 1); i++) {
    if (ca[i]) printf("%lld ", i);
  }
  cout << endl;
}
