#include <bits/stdc++.h>
using namespace std;
template <class T>
void checkmin(T &t, T x) {
  if (x < t) t = x;
}
template <class T>
void checkmax(T &t, T x) {
  if (x > t) t = x;
}
template <class T>
void _checkmin(T &t, T x) {
  if (t == -1) t = x;
  if (x < t) t = x;
}
template <class T>
void _checkmax(T &t, T x) {
  if (t == -1) t = x;
  if (x > t) t = x;
}
const int N = 105;
int m, n;
int sumx[N];
int sumy[N];
int a[N][N];
int retx[N], rety[N];
int main() {
  scanf("%d%d", &m, &n);
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= n; j++) {
      scanf("%d", &a[i][j]);
      sumx[i] += a[i][j];
      sumy[j] += a[i][j];
    }
  }
  fill(retx, retx + m + 1, 1);
  fill(rety, rety + n + 1, 1);
  for (;;) {
    bool flag = 0;
    for (int i = 1; i <= m; i++) {
      if (sumx[i] < 0) {
        sumx[i] = -sumx[i];
        for (int j = 1; j <= n; j++) {
          sumy[j] -= 2 * retx[i] * rety[j] * a[i][j];
        }
        retx[i] = -retx[i];
        flag = 1;
      }
    }
    for (int j = 1; j <= n; j++) {
      if (sumy[j] < 0) {
        sumy[j] = -sumy[j];
        for (int i = 1; i <= m; i++) {
          sumx[i] -= 2 * retx[i] * rety[j] * a[i][j];
        }
        rety[j] = -rety[j];
        flag = 1;
      }
    }
    if (!flag) break;
  }
  vector<int> vx, vy;
  for (int i = 1; i <= m; i++) {
    if (retx[i] == -1) {
      vx.push_back(i);
    }
  }
  for (int i = 1; i <= n; i++) {
    if (rety[i] == -1) {
      vy.push_back(i);
    }
  }
  printf("%d", vx.size());
  for (__typeof((vx).begin()) it = (vx).begin(); it != (vx).end(); it++) {
    printf(" %d", *it);
  }
  puts("");
  printf("%d", vy.size());
  for (__typeof((vy).begin()) it = (vy).begin(); it != (vy).end(); it++) {
    printf(" %d", *it);
  }
  puts("");
}
