#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:65000000")
using namespace std;
int mas[100][100];
bool useR[100], useC[100];
int n, m;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) scanf("%d", &mas[i][j]);
  while (true) {
    bool done = false;
    for (int i = 0; i < n; ++i) {
      int sum = 0;
      for (int j = 0; j < m; ++j) sum += mas[i][j];
      if (sum < 0) {
        done = true;
        useR[i] = !useR[i];
        for (int j = 0; j < m; ++j) mas[i][j] = -mas[i][j];
      }
    }
    for (int j = 0; j < m; ++j) {
      int sum = 0;
      for (int i = 0; i < n; ++i) sum += mas[i][j];
      if (sum < 0) {
        done = true;
        useC[j] = !useC[j];
        for (int i = 0; i < n; ++i) mas[i][j] = -mas[i][j];
      }
    }
    if (!done) break;
  }
  vector<int> row, col;
  for (int i = 0; i < n; ++i)
    if (useR[i]) row.push_back(i + 1);
  for (int j = 0; j < m; ++j)
    if (useC[j]) col.push_back(j + 1);
  printf("%d", row.size());
  for (int i = 0; i < row.size(); ++i) printf(" %d", row[i]);
  printf("\n");
  printf("%d", col.size());
  for (int i = 0; i < col.size(); ++i) printf(" %d", col[i]);
  printf("\n");
  return 0;
}
