#include <bits/stdc++.h>
using namespace std;
queue<pair<int, int> > q;
bool vis[2][105];
pair<int, int> x;
int hasil[2][105];
vector<int> jawab[2];
int i, j, n, m, a, b, sumr[2][105], arr[105][105];
int main() {
  memset(vis, 0, sizeof(vis));
  scanf("%d %d", &n, &m);
  memset(hasil, 0, sizeof(hasil));
  memset(sumr, 0, sizeof(sumr));
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      scanf("%d", &arr[i][j]);
      sumr[0][i] += arr[i][j];
      sumr[1][j] += arr[i][j];
    }
  }
  for (i = 0; i < n; i++)
    if (sumr[0][i] < 0) q.push(make_pair(0, i));
  for (j = 0; j < m; j++)
    if (sumr[1][j] < 0) q.push(make_pair(1, j));
  while (!q.empty()) {
    x = q.front();
    q.pop();
    if (sumr[x.first][x.second] >= 0) continue;
    hasil[x.first][x.second]++;
    sumr[x.first][x.second] *= -1;
    if (x.first == 0) {
      for (j = 0; j < m; j++) {
        sumr[1][j] += arr[x.second][j] * -2;
        if (arr[x.second][j] > 0) q.push(make_pair(1, j));
        arr[x.second][j] *= -1;
      }
    } else {
      for (i = 0; i < n; i++) {
        sumr[0][i] += arr[i][x.second] * -2;
        if (arr[i][x.second] > 0) q.push(make_pair(0, i));
        arr[i][x.second] *= -1;
      }
    }
  }
  for (i = 0; i < n; i++)
    if (hasil[0][i] % 2 == 1) jawab[0].push_back(i + 1);
  for (j = 0; j < m; j++)
    if (hasil[1][j] % 2 == 1) jawab[1].push_back(j + 1);
  printf("%d", jawab[0].size());
  for (i = 0; i < jawab[0].size(); i++) printf(" %d", jawab[0][i]);
  puts("");
  printf("%d", jawab[1].size());
  for (i = 0; i < jawab[1].size(); i++) printf(" %d", jawab[1][i]);
  puts("");
}
