#include <bits/stdc++.h>
using namespace std;
int mp[120][120];
int sumx[120];
int sumy[120];
int ans1[120];
int ans2[120];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) scanf("%d", &mp[i][j]);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      sumx[i] += mp[i][j];
      sumy[j] += mp[i][j];
    }
  }
  while (1) {
    int flag = 0;
    for (int i = 1; i <= n; i++) {
      if (sumx[i] < 0) {
        for (int j = 1; j <= m; j++) {
          sumy[j] = sumy[j] - 2 * (mp[i][j]);
          mp[i][j] = -mp[i][j];
        }
        ans1[i] ^= 1;
        sumx[i] = -sumx[i];
        flag = 1;
      }
    }
    if (flag) continue;
    for (int j = 1; j <= m; j++) {
      if (sumy[j] < 0) {
        for (int i = 1; i <= n; i++) {
          sumx[i] = sumx[i] - 2 * (mp[i][j]);
          mp[i][j] = -mp[i][j];
        }
        ans2[j] ^= 1;
        sumy[j] = -sumy[j];
        flag = 1;
      }
    }
    if (flag == 0) break;
  }
  int Ans1 = 0;
  for (int i = 1; i <= 110; i++) {
    if (ans1[i]) Ans1 += 1;
  }
  int Ans2 = 0;
  for (int i = 1; i <= 110; i++) {
    if (ans2[i]) Ans2 += 1;
  }
  cout << Ans1 << " ";
  for (int i = 1; i <= 110; i++)
    if (ans1[i]) cout << i << " ";
  cout << endl;
  cout << Ans2 << " ";
  for (int i = 1; i <= 110; i++)
    if (ans2[i]) cout << i << " ";
  cout << endl;
}
