#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
const int INF = 1000 * 1000 * 1000;
const double EPS = 1e-9;
const int MAXN = 101;
int a[MAXN][MAXN];
int csum[MAXN], rsum[MAXN];
bool cans[MAXN], rans[MAXN];
int main() {
  int N, M;
  scanf("%d%d", &N, &M);
  for (int i = 0; i < N; ++i)
    for (int j = 0; j < M; ++j) {
      scanf("%d", &a[i][j]);
      csum[j] += a[i][j];
      rsum[i] += a[i][j];
    }
  for (;;) {
    bool check = false;
    for (int i = 0; i < N; ++i)
      if (rsum[i] < 0) {
        rsum[i] *= -1;
        for (int j = 0; j < M; ++j) {
          csum[j] -= 2 * a[i][j];
          a[i][j] *= -1;
        }
        check = true;
        rans[i] ^= true;
        break;
      }
    if (check) continue;
    for (int j = 0; j < M; ++j)
      if (csum[j] < 0) {
        csum[j] *= -1;
        for (int i = 0; i < N; ++i) {
          rsum[i] -= 2 * a[i][j];
          a[i][j] *= -1;
        }
        check = true;
        cans[j] ^= true;
        break;
      }
    if (check) continue;
    break;
  }
  int cntr = 0;
  for (int i = 0; i < N; ++i)
    if (rans[i]) {
      ++cntr;
    }
  printf("%d ", cntr);
  for (int i = 0; i < N; ++i)
    if (rans[i]) {
      printf("%d ", i + 1);
    }
  puts("");
  int cntc = 0;
  for (int j = 0; j < M; ++j)
    if (cans[j]) {
      ++cntc;
    }
  printf("%d ", cntc);
  for (int j = 0; j < M; ++j)
    if (cans[j]) {
      printf("%d ", j + 1);
    }
  return 0;
}
