#include <bits/stdc++.h>
using namespace std;
int C[105], X[105], Y[105], R[105], T[105][105], N, M, t, i, j;
int main() {
  cin >> N >> M;
  for (i = 1; i <= N; i++)
    for (j = 1; j <= M; j++) {
      cin >> T[i][j];
      R[i] += T[i][j], C[j] += T[i][j];
    }
  do {
    t = 0;
    for (i = 1; i <= N; i++)
      if (R[i] < 0) {
        for (j = 1; j <= M; j++) {
          C[j] -= 2 * T[i][j];
          T[i][j] *= -1;
        }
        Y[i] = 1 - Y[i], R[i] *= -1, t = 1;
      }
    for (j = 1; j <= M; j++)
      if (C[j] < 0) {
        for (i = 1; i <= N; i++) {
          R[i] -= 2 * T[i][j];
          T[i][j] *= -1;
        }
        X[j] = 1 - X[j], C[j] *= -1, t = 1;
      }
  } while (t);
  t = 0;
  for (i = 1; i <= N; i++) t += Y[i];
  cout << t << " ";
  for (i = 1; i <= N; i++)
    if (Y[i]) cout << i << " ";
  t = 0;
  for (i = 1; i <= M; i++) t += X[i];
  cout << "\n" << t << " ";
  for (i = 1; i <= M; i++)
    if (X[i]) cout << i << " ";
}
